OSDN Git Service

* BugTrack2/246: Should use array_key_exists($maybe, $null) here (patched by sonots).
authorhenoheno <henoheno>
Fri, 15 Jun 2007 13:48:19 +0000 (22:48 +0900)
committerumorigu <umorigu@gmail.com>
Sat, 29 Nov 2014 02:16:04 +0000 (11:16 +0900)
* Please don't memorize the $result itself.

lib/plugin.php

index bcf35a8..9c6a201 100644 (file)
@@ -72,14 +72,15 @@ function do_plugin_init($name)
 {
        static $checked = array();
 
-       if (isset($checked[$name])) return $checked[$name];
+       // TRUE or FALSE or NULL (Return nothing / Not exists)
+       if (array_key_exists($name, $checked)) return $checked[$name];
 
        $func = 'plugin_' . $name . '_init';
        if (function_exists($func)) {
-               // TRUE or FALSE or NULL (return nothing)
-               $checked[$name] = call_user_func($func);
+               $result = call_user_func($func);
+               $checked[$name] = ($result === NULL) ? NULL : (bool)$result;
        } else {
-               $checked[$name] = NULL; // Not exist
+               $checked[$name] = NULL;
        }
 
        return $checked[$name];