Merge pull request #11413 from seamuslee001/CRM-21534-29
[civicrm-core.git] / Civi / Core / SettingsBag.php
index 14289499244f2cfe8061e2704c0909815102716c..2aee1eb1c205b2bf799e1f256dc67e9654f564f9 100644 (file)
@@ -352,7 +352,9 @@ class SettingsBag {
     }
     $dao->find(TRUE);
 
-    if (isset($metadata['on_change']) && !($value == 0 && ($dao->value === NULL || unserialize($dao->value) == 0))) {
+    // string comparison with 0 always return true, so to be ensure the type use ===
+    // ref - https://stackoverflow.com/questions/8671942/php-string-comparasion-to-0-integer-returns-true
+    if (isset($metadata['on_change']) && !($value === 0 && ($dao->value === NULL || unserialize($dao->value) == 0))) {
       foreach ($metadata['on_change'] as $callback) {
         call_user_func(
           \Civi\Core\Resolver::singleton()->get($callback),