Skip to content

Commit

Permalink
removed usage of Nette\Utils\LimitedScope (except Templating)
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Aug 5, 2013
1 parent 2b74e46 commit 8c0ad5d
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Nette/Application/PresenterFactory.php
Expand Up @@ -95,7 +95,7 @@ public function getPresenterClass(& $name)
// internal autoloading
$file = $this->formatPresenterFile($name);
if (is_file($file) && is_readable($file)) {
Nette\Utils\LimitedScope::load($file, TRUE);
call_user_func(function() use ($file) { require $file; });
}

if (!class_exists($class)) {
Expand Down
2 changes: 1 addition & 1 deletion Nette/DI/Config/Adapters/PhpAdapter.php
Expand Up @@ -29,7 +29,7 @@ class PhpAdapter extends Nette\Object implements Nette\DI\Config\IAdapter
*/
public function load($file)
{
return Nette\Utils\LimitedScope::load($file);
return require $file;
}


Expand Down
4 changes: 2 additions & 2 deletions Nette/Loaders/NetteLoader.php
Expand Up @@ -116,11 +116,11 @@ class_alias($this->renamed[$type], $type);
trigger_error("Class $type has been renamed to {$this->renamed[$type]}.", E_USER_WARNING);

} elseif (isset($this->list[$type])) {
Nette\Utils\LimitedScope::load(NETTE_DIR . $this->list[$type] . '.php', TRUE);
require NETTE_DIR . $this->list[$type] . '.php';
self::$count++;

} elseif (substr($type, 0, 6) === 'Nette\\' && is_file($file = NETTE_DIR . strtr(substr($type, 5), '\\', '/') . '.php')) {
Nette\Utils\LimitedScope::load($file, TRUE);
require $file;
self::$count++;
}
}
Expand Down
9 changes: 4 additions & 5 deletions Nette/Loaders/RobotLoader.php
Expand Up @@ -113,12 +113,11 @@ public function tryLoad($type)
}

if (isset($this->classes[$type]['file'])) {
if (empty($this->classes[$type]['filter'])) {
Nette\Utils\LimitedScope::load($this->classes[$type]['file'], TRUE);
} else {
$item = $this->getPhpCache()->load($this->classes[$type]['file']);
Nette\Utils\LimitedScope::load($item['file'], TRUE);
$info = $this->classes[$type];
if (!empty($info['filter'])) {
$info = $this->getPhpCache()->load($info['file']);
}
call_user_func(function() use ($info) { require $info['file']; });
self::$count++;
} else {
$this->missing[$type] = TRUE;
Expand Down
2 changes: 1 addition & 1 deletion Nette/common/Configurator.php
Expand Up @@ -164,7 +164,7 @@ public function createContainer()
$cache->save($cacheKey, $code, array($cache::FILES => $dependencies));
$cached = $cache->load($cacheKey);
}
Nette\Utils\LimitedScope::load($cached['file'], TRUE);
require $cached['file'];

$container = new $this->parameters['container']['class'];
$container->initialize();
Expand Down
1 change: 0 additions & 1 deletion Nette/loader.php
Expand Up @@ -30,7 +30,6 @@

require_once __DIR__ . '/common/exceptions.php';
require_once __DIR__ . '/common/Object.php';
require_once __DIR__ . '/Utils/LimitedScope.php';
require_once __DIR__ . '/Loaders/AutoLoader.php';
require_once __DIR__ . '/Loaders/NetteLoader.php';

Expand Down

5 comments on commit 8c0ad5d

@Majkl578
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has a bad side-effect in PHP 5.4+ - $this is now accessible inside the called file, which doesn't seem to be correct. I guess correct replacement for 5.4+ would be as follows:

call_user_func(Closure::bind(function() use ($file) { require $file; }, NULL));

@fprochazka
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dg Is there any benefit? Are you planning to remove LimitedScope?

@dg
Copy link
Member Author

@dg dg commented on 8c0ad5d Aug 5, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Majkl578 Files with class definitions should have no side effects, so current solution is not ideal, but good enough.

@hosiplan Yes, classes like LimitedScope makes framework separation much harder.

@rikiless
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from this commit my app stopped working (blank screen) on production. no errors logged (php 5.3.6).

@milo
Copy link
Member

@milo milo commented on 8c0ad5d Aug 27, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rikiless Check issue #1211

Please sign in to comment.