Fix scope isolated config includes

This commit is contained in:
Daniel Rudolf 2016-03-06 20:47:25 +01:00
parent 75d5081bfb
commit cd74b681f5
2 changed files with 4 additions and 3 deletions

View File

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

View File

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