mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
"Fixes #3743, Loading mechanism tries to load files twice from same location.
Fixes #3751, Behavior of Configure::listObjects() changed." git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6209 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
17610a5287
commit
c98d1457ac
4 changed files with 46 additions and 10 deletions
|
@ -125,9 +125,9 @@ class ClassRegistry {
|
||||||
$options = array('id' => $id, 'table' => $table, 'ds' => $ds, 'alias' => $alias, 'name' => $class);
|
$options = array('id' => $id, 'table' => $table, 'ds' => $ds, 'alias' => $alias, 'name' => $class);
|
||||||
}
|
}
|
||||||
if (App::import($type, $plugin . $class)) {
|
if (App::import($type, $plugin . $class)) {
|
||||||
${$class} = new $class($options);
|
${$class} =& new $class($options);
|
||||||
} elseif ($type === 'Model') {
|
} elseif ($type === 'Model') {
|
||||||
${$class} = new AppModel($options);
|
${$class} =& new AppModel($options);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset(${$class})) {
|
if (!isset(${$class})) {
|
||||||
|
@ -136,7 +136,7 @@ class ClassRegistry {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($type !== 'Model') {
|
if ($type !== 'Model') {
|
||||||
$_this->addObject($this->alias, ${$class});
|
$_this->addObject($alias, ${$class});
|
||||||
} else {
|
} else {
|
||||||
$_this->map($alias, $class);
|
$_this->map($alias, $class);
|
||||||
}
|
}
|
||||||
|
|
|
@ -730,6 +730,13 @@ class App extends Object {
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $__paths = array();
|
var $__paths = array();
|
||||||
|
/**
|
||||||
|
* Holds loaded files
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
var $__loaded = array();
|
||||||
/**
|
/**
|
||||||
* Will find Classes based on the $name, or can accept specific file to search for
|
* Will find Classes based on the $name, or can accept specific file to search for
|
||||||
*
|
*
|
||||||
|
@ -927,10 +934,15 @@ class App extends Object {
|
||||||
function __load($file) {
|
function __load($file) {
|
||||||
$_this =& App::getInstance();
|
$_this =& App::getInstance();
|
||||||
|
|
||||||
|
if (!$_this->return && in_array($file, $_this->__loaded)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (file_exists($file)) {
|
if (file_exists($file)) {
|
||||||
if (!$_this->return) {
|
if (!$_this->return) {
|
||||||
require($file);
|
require($file);
|
||||||
}
|
}
|
||||||
|
$_this->__loaded[] = $file;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -56,7 +56,12 @@ class ClassRegistryTest extends UnitTestCase {
|
||||||
|
|
||||||
$Tag->name = 'SomeNewName';
|
$Tag->name = 'SomeNewName';
|
||||||
|
|
||||||
|
if (PHP5) {
|
||||||
$TagCopy = ClassRegistry::getObject('RegisterArticleTag');
|
$TagCopy = ClassRegistry::getObject('RegisterArticleTag');
|
||||||
|
} else {
|
||||||
|
$TagCopy =& ClassRegistry::getObject('RegisterArticleTag');
|
||||||
|
}
|
||||||
|
|
||||||
$this->assertTrue(is_a($TagCopy, 'RegisterArticleTag'));
|
$this->assertTrue(is_a($TagCopy, 'RegisterArticleTag'));
|
||||||
$this->assertIdentical($Tag, $TagCopy);
|
$this->assertIdentical($Tag, $TagCopy);
|
||||||
|
|
||||||
|
|
|
@ -44,15 +44,27 @@ class AppImportTest extends UnitTestCase {
|
||||||
|
|
||||||
if (!class_exists('AppController')) {
|
if (!class_exists('AppController')) {
|
||||||
$classes = array_flip(get_declared_classes());
|
$classes = array_flip(get_declared_classes());
|
||||||
|
|
||||||
|
if (PHP5) {
|
||||||
$this->assertFalse(isset($classes['PagesController']));
|
$this->assertFalse(isset($classes['PagesController']));
|
||||||
$this->assertFalse(isset($classes['AppController']));
|
$this->assertFalse(isset($classes['AppController']));
|
||||||
|
} else {
|
||||||
|
$this->assertFalse(isset($classes['pagescontroller']));
|
||||||
|
$this->assertFalse(isset($classes['appcontroller']));
|
||||||
|
}
|
||||||
|
|
||||||
$file = App::import('Controller', 'Pages');
|
$file = App::import('Controller', 'Pages');
|
||||||
$this->assertTrue($file);
|
$this->assertTrue($file);
|
||||||
|
|
||||||
$classes = array_flip(get_declared_classes());
|
$classes = array_flip(get_declared_classes());
|
||||||
|
|
||||||
|
if (PHP5) {
|
||||||
$this->assertTrue(isset($classes['PagesController']));
|
$this->assertTrue(isset($classes['PagesController']));
|
||||||
$this->assertTrue(isset($classes['AppController']));
|
$this->assertTrue(isset($classes['AppController']));
|
||||||
|
} else {
|
||||||
|
$this->assertTrue(isset($classes['pagescontroller']));
|
||||||
|
$this->assertTrue(isset($classes['appcontroller']));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,15 +127,22 @@ class AppImportTest extends UnitTestCase {
|
||||||
$this->assertFalse(isset($classes['i18n']));
|
$this->assertFalse(isset($classes['i18n']));
|
||||||
$this->assertFalse(isset($classes['Socket']));
|
$this->assertFalse(isset($classes['Socket']));
|
||||||
|
|
||||||
|
|
||||||
$load = App::import($toLoad);
|
$load = App::import($toLoad);
|
||||||
$this->assertTrue($load);
|
$this->assertTrue($load);
|
||||||
|
|
||||||
$classes = array_flip(get_declared_classes());
|
$classes = array_flip(get_declared_classes());
|
||||||
|
|
||||||
|
if (PHP5) {
|
||||||
$this->assertTrue(isset($classes['I18n']));
|
$this->assertTrue(isset($classes['I18n']));
|
||||||
|
} else {
|
||||||
|
$this->assertTrue(isset($classes['i18n']));
|
||||||
|
}
|
||||||
|
|
||||||
$load = App::import(array('I18n', 'SomeNotFoundClass', 'Socket'));
|
$load = App::import(array('I18n', 'SomeNotFoundClass', 'Socket'));
|
||||||
$this->assertFalse($load);
|
$this->assertFalse($load);
|
||||||
|
|
||||||
|
$load = App::import($toLoad);
|
||||||
|
$this->assertTrue($load);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* This test only works if you have plugins/my_plugin set up.
|
* This test only works if you have plugins/my_plugin set up.
|
||||||
|
|
Loading…
Add table
Reference in a new issue