mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 11:06:15 +00:00
Closes #5557 model.php and App::__settings try to import inexistent class Behavior
Removed loading of ModelBehavior in App::__settings(); this it not needed since the behavior is loaded in the model. Added additional optimizations. git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7733 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
93a54735d6
commit
2f85fefa29
1 changed files with 38 additions and 49 deletions
|
@ -511,9 +511,8 @@ class Configure extends Object {
|
||||||
*/
|
*/
|
||||||
function __writeConfig($content, $name, $write = true) {
|
function __writeConfig($content, $name, $write = true) {
|
||||||
$file = CACHE . 'persistent' . DS . $name . '.php';
|
$file = CACHE . 'persistent' . DS . $name . '.php';
|
||||||
$_this =& Configure::getInstance();
|
|
||||||
|
|
||||||
if ($_this->read() > 0) {
|
if ($this->read() > 0) {
|
||||||
$expires = "+10 seconds";
|
$expires = "+10 seconds";
|
||||||
} else {
|
} else {
|
||||||
$expires = "+999 days";
|
$expires = "+999 days";
|
||||||
|
@ -666,10 +665,8 @@ class Configure extends Object {
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function __destruct() {
|
function __destruct() {
|
||||||
$_this =& Configure::getInstance();
|
if ($this->__cache) {
|
||||||
|
Cache::write('object_map', array_filter($this->__objects), '_cake_core_');
|
||||||
if ($_this->__cache) {
|
|
||||||
Cache::write('object_map', array_filter($_this->__objects), '_cake_core_');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -875,41 +872,39 @@ class App extends Object {
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function __find($file, $recursive = true) {
|
function __find($file, $recursive = true) {
|
||||||
$_this =& App::getInstance();
|
if (empty($this->search)) {
|
||||||
|
|
||||||
if (empty($_this->search)) {
|
|
||||||
return null;
|
return null;
|
||||||
} elseif (is_string($_this->search)) {
|
} elseif (is_string($this->search)) {
|
||||||
$_this->search = array($_this->search);
|
$this->search = array($this->search);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($_this->__paths)) {
|
if (empty($this->__paths)) {
|
||||||
$_this->__paths = Cache::read('dir_map', '_cake_core_');
|
$this->__paths = Cache::read('dir_map', '_cake_core_');
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($_this->search as $path) {
|
foreach ($this->search as $path) {
|
||||||
$path = rtrim($path, DS);
|
$path = rtrim($path, DS);
|
||||||
|
|
||||||
if ($path === rtrim(APP, DS)) {
|
if ($path === rtrim(APP, DS)) {
|
||||||
$recursive = false;
|
$recursive = false;
|
||||||
}
|
}
|
||||||
if ($recursive === false) {
|
if ($recursive === false) {
|
||||||
if ($_this->__load($path . DS . $file)) {
|
if ($this->__load($path . DS . $file)) {
|
||||||
return $path . DS;
|
return $path . DS;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!isset($_this->__paths[$path])) {
|
if (!isset($this->__paths[$path])) {
|
||||||
if (!class_exists('Folder')) {
|
if (!class_exists('Folder')) {
|
||||||
require LIBS . 'folder.php';
|
require LIBS . 'folder.php';
|
||||||
}
|
}
|
||||||
$Folder =& new Folder();
|
$Folder =& new Folder();
|
||||||
$directories = $Folder->tree($path, false, 'dir');
|
$directories = $Folder->tree($path, false, 'dir');
|
||||||
$_this->__paths[$path] = $directories;
|
$this->__paths[$path] = $directories;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($_this->__paths[$path] as $directory) {
|
foreach ($this->__paths[$path] as $directory) {
|
||||||
if ($_this->__load($directory . DS . $file)) {
|
if ($this->__load($directory . DS . $file)) {
|
||||||
return $directory . DS;
|
return $directory . DS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -927,16 +922,13 @@ class App extends Object {
|
||||||
if (empty($file)) {
|
if (empty($file)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$_this =& App::getInstance();
|
if (!$this->return && isset($this->__loaded[$file])) {
|
||||||
|
|
||||||
if (!$_this->return && isset($_this->__loaded[$file])) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file_exists($file)) {
|
if (file_exists($file)) {
|
||||||
if (!$_this->return) {
|
if (!$this->return) {
|
||||||
require($file);
|
require($file);
|
||||||
$_this->__loaded[$file] = true;
|
$this->__loaded[$file] = true;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -952,13 +944,11 @@ class App extends Object {
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function __map($file, $name, $type, $plugin) {
|
function __map($file, $name, $type, $plugin) {
|
||||||
$_this =& App::getInstance();
|
|
||||||
|
|
||||||
if ($plugin) {
|
if ($plugin) {
|
||||||
$plugin = Inflector::camelize($plugin);
|
$plugin = Inflector::camelize($plugin);
|
||||||
$_this->__map['Plugin'][$plugin][$type][$name] = $file;
|
$this->__map['Plugin'][$plugin][$type][$name] = $file;
|
||||||
} else {
|
} else {
|
||||||
$_this->__map[$type][$name] = $file;
|
$this->__map[$type][$name] = $file;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -971,19 +961,17 @@ class App extends Object {
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function __mapped($name, $type, $plugin) {
|
function __mapped($name, $type, $plugin) {
|
||||||
$_this =& App::getInstance();
|
|
||||||
|
|
||||||
if ($plugin) {
|
if ($plugin) {
|
||||||
$plugin = Inflector::camelize($plugin);
|
$plugin = Inflector::camelize($plugin);
|
||||||
|
|
||||||
if (isset($_this->__map['Plugin'][$plugin][$type]) && isset($_this->__map['Plugin'][$plugin][$type][$name])) {
|
if (isset($this->__map['Plugin'][$plugin][$type]) && isset($this->__map['Plugin'][$plugin][$type][$name])) {
|
||||||
return $_this->__map['Plugin'][$plugin][$type][$name];
|
return $this->__map['Plugin'][$plugin][$type][$name];
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_this->__map[$type]) && isset($_this->__map[$type][$name])) {
|
if (isset($this->__map[$type]) && isset($this->__map[$type][$name])) {
|
||||||
return $_this->__map[$type][$name];
|
return $this->__map[$type][$name];
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1026,15 +1014,18 @@ class App extends Object {
|
||||||
if (!class_exists('Model')) {
|
if (!class_exists('Model')) {
|
||||||
App::import('Core', 'Model', false, Configure::corePaths('model'));
|
App::import('Core', 'Model', false, Configure::corePaths('model'));
|
||||||
}
|
}
|
||||||
|
if (!class_exists('AppModel')) {
|
||||||
App::import($type, 'AppModel', false, Configure::read('modelPaths'));
|
App::import($type, 'AppModel', false, Configure::read('modelPaths'));
|
||||||
|
}
|
||||||
if ($plugin) {
|
if ($plugin) {
|
||||||
|
if (!class_exists($name . 'AppModel')) {
|
||||||
App::import($type, $plugin . '.' . $name . 'AppModel', false, array(), $plugin . DS . $plugin . '_app_model.php');
|
App::import($type, $plugin . '.' . $name . 'AppModel', false, array(), $plugin . DS . $plugin . '_app_model.php');
|
||||||
|
}
|
||||||
$path = $plugin . DS . 'models' . DS;
|
$path = $plugin . DS . 'models' . DS;
|
||||||
}
|
}
|
||||||
return array('class' => null, 'suffix' => null, 'path' => $path);
|
return array('class' => null, 'suffix' => null, 'path' => $path);
|
||||||
break;
|
break;
|
||||||
case 'behavior':
|
case 'behavior':
|
||||||
App::import('Core', 'Behavior', false);
|
|
||||||
if ($plugin) {
|
if ($plugin) {
|
||||||
$path = $plugin . DS . 'models' . DS . 'behaviors' . DS;
|
$path = $plugin . DS . 'models' . DS . 'behaviors' . DS;
|
||||||
}
|
}
|
||||||
|
@ -1061,7 +1052,9 @@ class App extends Object {
|
||||||
return array('class' => $type, 'suffix' => null, 'path' => $path);
|
return array('class' => $type, 'suffix' => null, 'path' => $path);
|
||||||
break;
|
break;
|
||||||
case 'helper':
|
case 'helper':
|
||||||
|
if (!class_exists('AppHelper')) {
|
||||||
App::import($type, 'AppHelper', false);
|
App::import($type, 'AppHelper', false);
|
||||||
|
}
|
||||||
if ($plugin) {
|
if ($plugin) {
|
||||||
$path = $plugin . DS . 'views' . DS . 'helpers' . DS;
|
$path = $plugin . DS . 'views' . DS . 'helpers' . DS;
|
||||||
}
|
}
|
||||||
|
@ -1129,13 +1122,11 @@ class App extends Object {
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function __remove($name, $type, $plugin) {
|
function __remove($name, $type, $plugin) {
|
||||||
$_this =& App::getInstance();
|
|
||||||
|
|
||||||
if ($plugin) {
|
if ($plugin) {
|
||||||
$plugin = Inflector::camelize($plugin);
|
$plugin = Inflector::camelize($plugin);
|
||||||
unset($_this->__map['Plugin'][$plugin][$type][$name]);
|
unset($this->__map['Plugin'][$plugin][$type][$name]);
|
||||||
} else {
|
} else {
|
||||||
unset($_this->__map[$type][$name]);
|
unset($this->__map[$type][$name]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -1146,13 +1137,11 @@ class App extends Object {
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function __destruct() {
|
function __destruct() {
|
||||||
$_this =& App::getInstance();
|
if ($this->__cache) {
|
||||||
|
|
||||||
if ($_this->__cache) {
|
|
||||||
$core = Configure::corePaths('cake');
|
$core = Configure::corePaths('cake');
|
||||||
unset($_this->__paths[rtrim($core[0], DS)]);
|
unset($this->__paths[rtrim($core[0], DS)]);
|
||||||
Cache::write('dir_map', array_filter($_this->__paths), '_cake_core_');
|
Cache::write('dir_map', array_filter($this->__paths), '_cake_core_');
|
||||||
Cache::write('file_map', array_filter($_this->__map), '_cake_core_');
|
Cache::write('file_map', array_filter($this->__map), '_cake_core_');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue