mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Add plugin. prefix for plugin files.
This prevents app/plugin bleedthrough. This is particularly problematic in controllers, as plugin controllers were partially accessible from non-plugin routes. Fixes #2658
This commit is contained in:
parent
ed1d34accc
commit
72d0105e20
1 changed files with 16 additions and 17 deletions
|
@ -533,12 +533,12 @@ class App {
|
|||
return false;
|
||||
}
|
||||
|
||||
if ($file = self::_mapped($className)) {
|
||||
return include $file;
|
||||
}
|
||||
|
||||
$parts = explode('.', self::$_classMap[$className], 2);
|
||||
list($plugin, $package) = count($parts) > 1 ? $parts : array(null, current($parts));
|
||||
|
||||
if ($file = self::_mapped($className, $plugin)) {
|
||||
return include $file;
|
||||
}
|
||||
$paths = self::path($package, $plugin);
|
||||
|
||||
if (empty($plugin)) {
|
||||
|
@ -554,7 +554,7 @@ class App {
|
|||
foreach ($paths as $path) {
|
||||
$file = $path . $className . '.php';
|
||||
if (file_exists($file)) {
|
||||
self::_map($file, $className);
|
||||
self::_map($file, $className, $plugin);
|
||||
return include $file;
|
||||
}
|
||||
}
|
||||
|
@ -778,10 +778,15 @@ class App {
|
|||
* @return void
|
||||
*/
|
||||
protected static function _map($file, $name, $plugin = null) {
|
||||
$key = $name;
|
||||
if ($plugin) {
|
||||
self::$_map['Plugin'][$plugin][$name] = $file;
|
||||
} else {
|
||||
self::$_map[$name] = $file;
|
||||
$key = 'plugin.' . $name;
|
||||
}
|
||||
if ($plugin && empty(self::$_map[$name])) {
|
||||
self::$_map[$key] = $file;
|
||||
}
|
||||
if (!$plugin && empty(self::$_map['plugin.' . $name])) {
|
||||
self::$_map[$key] = $file;
|
||||
}
|
||||
if (!self::$bootstrapping) {
|
||||
self::$_cacheChange = true;
|
||||
|
@ -796,17 +801,11 @@ class App {
|
|||
* @return mixed file path if found, false otherwise
|
||||
*/
|
||||
protected static function _mapped($name, $plugin = null) {
|
||||
$key = $name;
|
||||
if ($plugin) {
|
||||
if (isset(self::$_map['Plugin'][$plugin][$name])) {
|
||||
return self::$_map['Plugin'][$plugin][$name];
|
||||
}
|
||||
return false;
|
||||
$key = 'plugin.' . $name;
|
||||
}
|
||||
|
||||
if (isset(self::$_map[$name])) {
|
||||
return self::$_map[$name];
|
||||
}
|
||||
return false;
|
||||
return isset(self::$_map[$key]) ? self::$_map[$name] : false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue