瀏覽代碼

Fix scope isolated config includes

Daniel Rudolf 9 年之前
父節點
當前提交
cd74b681f5
共有 2 個文件被更改,包括 4 次插入3 次删除
  1. 1 1
      lib/Pico.php
  2. 3 2
      plugins/00-PicoDeprecated.php

+ 1 - 1
lib/Pico.php

@@ -517,7 +517,7 @@ class Pico
         $config = null;
         if (file_exists($this->getConfigDir() . 'config.php')) {
             // scope isolated require()
-            $includeClosure = function ($configFile) {
+            $includeClosure = function ($configFile) use (&$config) {
                 require($configFile);
             };
             if (PHP_VERSION_ID >= 50400) {

+ 3 - 2
plugins/00-PicoDeprecated.php

@@ -165,8 +165,10 @@ class PicoDeprecated extends AbstractPicoPlugin
     protected function loadRootDirConfig(array &$realConfig)
     {
         if (file_exists($this->getRootDir() . 'config.php')) {
+            $config = null;
+
             // scope isolated require()
-            $includeClosure = function ($configFile) {
+            $includeClosure = function ($configFile) use (&$config) {
                 require($configFile);
             };
             if (PHP_VERSION_ID >= 50400) {
@@ -175,7 +177,6 @@ class PicoDeprecated extends AbstractPicoPlugin
 
             // config.php in Pico::$rootDir is deprecated
             // use config.php in Pico::$configDir instead
-            $config = null;
             $includeClosure($this->getRootDir() . 'config.php');
 
             if (is_array($config)) {