1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-13 12:14:06 +02:00

[ticket/11700] Correctly load extensions with nonprefixed namespaces

PHPBB3-11700
This commit is contained in:
Nils Adermann
2013-09-17 16:15:44 +02:00
parent d12f358855
commit c4b53490ad
29 changed files with 111 additions and 72 deletions

View File

@@ -87,7 +87,7 @@ set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handle
// Setup class loader first
$phpbb_class_loader = new \phpbb\class_loader('phpbb\\', "{$phpbb_root_path}phpbb/", $phpEx);
$phpbb_class_loader->register();
$phpbb_class_loader_ext = new \phpbb\class_loader('phpbb_ext_', "{$phpbb_root_path}ext/", $phpEx);
$phpbb_class_loader_ext = new \phpbb\class_loader('\\', "{$phpbb_root_path}ext/", $phpEx);
$phpbb_class_loader_ext->register();
// Set up container

View File

@@ -52,7 +52,7 @@ services:
class_loader.ext:
class: phpbb\class_loader
arguments:
- phpbb\ext\
- \
- %core.root_path%ext/
- %core.php_ext%
calls:

View File

@@ -50,9 +50,9 @@ if (isset($_GET['avatar']))
require($phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx);
// Setup class loader first
$phpbb_class_loader = new \phpbb\class_loader('phpbb_', "{$phpbb_root_path}phpbb/", $phpEx);
$phpbb_class_loader = new \phpbb\class_loader('phpbb\\', "{$phpbb_root_path}phpbb/", $phpEx);
$phpbb_class_loader->register();
$phpbb_class_loader_ext = new \phpbb\class_loader('phpbb_ext_', "{$phpbb_root_path}ext/", $phpEx);
$phpbb_class_loader_ext = new \phpbb\class_loader('\\', "{$phpbb_root_path}ext/", $phpEx);
$phpbb_class_loader_ext->register();
// Set up container

View File

@@ -565,7 +565,7 @@ class acp_modules
{
// Skip entries we do not need if we know the module we are
// looking for
if ($module && strpos($cur_module, $module) === false)
if ($module && strpos(str_replace('\\', '_', $cur_module), $module) === false)
{
continue;
}

View File

@@ -112,7 +112,7 @@ $phpbb_class_loader_new = new \phpbb\class_loader('phpbb\\', "{$phpbb_root_path}
$phpbb_class_loader_new->register();
$phpbb_class_loader = new \phpbb\class_loader('phpbb\\', "{$phpbb_root_path}phpbb/", $phpEx);
$phpbb_class_loader->register();
$phpbb_class_loader_ext = new \phpbb\class_loader('phpbb\\ext\\', "{$phpbb_root_path}ext/", $phpEx);
$phpbb_class_loader_ext = new \phpbb\class_loader('\\', "{$phpbb_root_path}ext/", $phpEx);
$phpbb_class_loader_ext->register();
// Set up container

View File

@@ -277,15 +277,16 @@ class finder
$classes = array();
foreach ($files as $file => $ext_name)
{
if (preg_match('#^includes/#', $file))
$class = substr($file, 0, -strlen('.' . $this->php_ext));
if ($ext_name === '/' && preg_match('#^includes/#', $file))
{
$file = preg_replace('#^includes/#', '', $file);
$classes[] = 'phpbb_' . str_replace('/', '_', substr($file, 0, -strlen('.' . $this->php_ext)));
$class = preg_replace('#^includes/#', '', $class);
$classes[] = 'phpbb_' . str_replace('/', '_', $class);
}
else
{
$file = preg_replace('#^phpbb/#', '', $file);
$classes[] = 'phpbb\\' . str_replace('/', '\\', substr($file, 0, -strlen('.' . $this->php_ext)));
{
$class = preg_replace('#^ext/#', '', $class);
$classes[] = str_replace('/', '\\', $class);
}
}
return $classes;

View File

@@ -133,7 +133,7 @@ class manager
*/
public function get_extension($name)
{
$extension_class_name = 'phpbb_ext_' . str_replace('/', '_', $name) . '_ext';
$extension_class_name = str_replace('/', '\\', $name) . '\\ext';
$migrator = $this->container->get('migrator');