mirror of
https://github.com/e107inc/e107.git
synced 2025-07-26 01:11:28 +02:00
Issue #5114 - Prevent override class conflict.
This commit is contained in:
@@ -15,6 +15,7 @@
|
|||||||
if (!defined('e107_INIT')) { exit; }
|
if (!defined('e107_INIT')) { exit; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @package e107
|
* @package e107
|
||||||
@@ -153,6 +154,8 @@ class e107
|
|||||||
|
|
||||||
protected static $_breadcrumb = array();
|
protected static $_breadcrumb = array();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Core handlers array
|
* Core handlers array
|
||||||
* For new/missing handler add
|
* For new/missing handler add
|
||||||
@@ -250,7 +253,7 @@ class e107
|
|||||||
'language' => '{e_HANDLER}language_class.php',
|
'language' => '{e_HANDLER}language_class.php',
|
||||||
'news' => '{e_HANDLER}news_class.php',
|
'news' => '{e_HANDLER}news_class.php',
|
||||||
'notify' => '{e_HANDLER}notify_class.php',
|
'notify' => '{e_HANDLER}notify_class.php',
|
||||||
'override' => '{e_HANDLER}override_class.php',
|
'e107\override' => '{e_HANDLER}override_class.php',
|
||||||
'rater' => '{e_HANDLER}rate_class.php',
|
'rater' => '{e_HANDLER}rate_class.php',
|
||||||
'redirection' => '{e_HANDLER}redirection_class.php',
|
'redirection' => '{e_HANDLER}redirection_class.php',
|
||||||
'secure_image' => '{e_HANDLER}secure_img_handler.php',
|
'secure_image' => '{e_HANDLER}secure_img_handler.php',
|
||||||
@@ -269,6 +272,7 @@ class e107
|
|||||||
'pageHelper' => '{e_PLUGIN}page/includes/pageHelper.php'
|
'pageHelper' => '{e_PLUGIN}page/includes/pageHelper.php'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Overload core handlers array
|
* Overload core handlers array
|
||||||
* Format: 'core_class' => array('overload_class', 'overload_path');
|
* Format: 'core_class' => array('overload_class', 'overload_path');
|
||||||
@@ -1034,6 +1038,11 @@ class e107
|
|||||||
return isset(self::$_known_handlers[$class_name]);
|
return isset(self::$_known_handlers[$class_name]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function isHandlerNamespaced($className)
|
||||||
|
{
|
||||||
|
return isset(self::$_known_handlers['e107\\'.$className]) ? '\\e107\\'.$className : false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get overlod class and path (if any)
|
* Get overlod class and path (if any)
|
||||||
*
|
*
|
||||||
@@ -1148,9 +1157,26 @@ class e107
|
|||||||
// remove the need for external function.
|
// remove the need for external function.
|
||||||
//e107_require_once() is available without class2.php. - see core_functions.php
|
//e107_require_once() is available without class2.php. - see core_functions.php
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(class_exists($class_name, false))
|
if(class_exists($class_name, false))
|
||||||
{
|
{
|
||||||
self::setRegistry($id, new $class_name($vars));
|
if($named = self::isHandlerNamespaced($class_name))
|
||||||
|
{
|
||||||
|
$class_name = $named;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$cls = is_null($vars) ? new $class_name() : new $class_name($vars);
|
||||||
|
}
|
||||||
|
catch (Exception $e)
|
||||||
|
{
|
||||||
|
trigger_error($e->getMessage());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
self::setRegistry($id, $cls);
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::getRegistry($id);
|
return self::getRegistry($id);
|
||||||
@@ -5932,12 +5958,18 @@ class e107
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$levels[0] = e_HANDLER;
|
$levels[0] = e_HANDLER;
|
||||||
$classPath = implode('/', $levels).'.php';
|
$classPath = implode('/', $levels).'.php';
|
||||||
if (is_file($classPath) && is_readable($classPath))
|
if (is_file($classPath) && is_readable($classPath))
|
||||||
{
|
{
|
||||||
include($classPath);
|
include($classPath);
|
||||||
}
|
}
|
||||||
|
elseif($filename = self::getHandlerPath($className))
|
||||||
|
{
|
||||||
|
include($filename);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -14,6 +14,8 @@
|
|||||||
* $Author$
|
* $Author$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
namespace e107;
|
||||||
|
|
||||||
if (!defined('e107_INIT')) { exit; }
|
if (!defined('e107_INIT')) { exit; }
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -40,7 +42,7 @@ class override {
|
|||||||
protected $functions = array();
|
protected $functions = array();
|
||||||
protected $includes = array();
|
protected $includes = array();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Replace an existing function or class method
|
* Replace an existing function or class method
|
||||||
|
@@ -289,13 +289,19 @@ class e107Test extends \Codeception\Test\Unit
|
|||||||
$res = null;
|
$res = null;
|
||||||
$this->assertTrue($res);
|
$this->assertTrue($res);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
public function testGetSingleton()
|
public function testGetSingleton()
|
||||||
{
|
{
|
||||||
$res = null;
|
$e107 = $this->e107;
|
||||||
$this->assertTrue($res);
|
|
||||||
|
$result = $e107::getSingleton('override', e_HANDLER . 'override_class.php');
|
||||||
|
|
||||||
|
$exists = method_exists($result, 'override_check');
|
||||||
|
|
||||||
|
$this->assertTrue($exists, 'Failed to load override class singleton');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
public function testGetObject()
|
public function testGetObject()
|
||||||
{
|
{
|
||||||
$res = null;
|
$res = null;
|
||||||
|
Reference in New Issue
Block a user