From: Brion Vibber Date: Tue, 4 Jan 2011 21:09:44 +0000 (-0800) Subject: Fix ticket #2181: Can't save #000000 (black) in color fields on design page X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=af1cbc6fe32c3d181e1a6d7315634a975cb91c17;p=quix0rs-gnu-social.git Fix ticket #2181: Can't save #000000 (black) in color fields on design page It seems to have actually been saving correctly, but the update of the colors on the form success page wasn't working properly. When a design object is pulled out of the database, the numeric fields are read in as strings, so black comes back as "0". But, when we populate the new object and then stick it live, we've populated it with actual integers; with memcache on these might live for a while in the cache... The fallback code in Design::toWebColor() did a check ($color == null) which would be false for the string "0", but counts as true for the *integer* 0. Thus, the display code would initially interpret the correctly-saved black color as "use default". Changing the check to === against null and "" empty string avoids the false positive on integers, and lets us see our nice black text immediately after save. --- diff --git a/classes/Design.php b/classes/Design.php index a8fdb72191..f4834c714e 100644 --- a/classes/Design.php +++ b/classes/Design.php @@ -107,7 +107,7 @@ class Design extends Memcached_DataObject static function toWebColor($color) { - if ($color == null) { + if ($color === null || $color === '') { return null; }