mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Merge pull request #1466 from ADmad/bugfix/#3874
Ensure Configure::boostrap() doesn't overwrite existing configs under 'A...
This commit is contained in:
commit
48df85d80d
3 changed files with 36 additions and 11 deletions
|
@ -67,13 +67,7 @@ class Configure {
|
||||||
*/
|
*/
|
||||||
public static function bootstrap($boot = true) {
|
public static function bootstrap($boot = true) {
|
||||||
if ($boot) {
|
if ($boot) {
|
||||||
self::write('App', array(
|
self::_appDefaults();
|
||||||
'base' => false,
|
|
||||||
'baseUrl' => false,
|
|
||||||
'dir' => APP_DIR,
|
|
||||||
'webroot' => WEBROOT_DIR,
|
|
||||||
'www_root' => WWW_ROOT
|
|
||||||
));
|
|
||||||
|
|
||||||
if (!include APP . 'Config' . DS . 'core.php') {
|
if (!include APP . 'Config' . DS . 'core.php') {
|
||||||
trigger_error(__d('cake_dev', "Can't find application core file. Please create %score.php, and make sure it is readable by PHP.", APP . 'Config' . DS), E_USER_ERROR);
|
trigger_error(__d('cake_dev', "Can't find application core file. Please create %score.php, and make sure it is readable by PHP.", APP . 'Config' . DS), E_USER_ERROR);
|
||||||
|
@ -109,6 +103,20 @@ class Configure {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set app's default configs
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected static function _appDefaults() {
|
||||||
|
self::write('App', (array)self::read('App') + array(
|
||||||
|
'base' => false,
|
||||||
|
'baseUrl' => false,
|
||||||
|
'dir' => APP_DIR,
|
||||||
|
'webroot' => WEBROOT_DIR,
|
||||||
|
'www_root' => WWW_ROOT
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to store a dynamic variable in Configure.
|
* Used to store a dynamic variable in Configure.
|
||||||
*
|
*
|
||||||
|
|
|
@ -69,6 +69,23 @@ class ConfigureTest extends CakeTestCase {
|
||||||
Configure::drop('test');
|
Configure::drop('test');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test to ensure bootrapping doesn't overwrite prior configs set under 'App' key
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testBootstrap() {
|
||||||
|
$expected = array(
|
||||||
|
'foo' => 'bar'
|
||||||
|
);
|
||||||
|
Configure::write('App', $expected);
|
||||||
|
|
||||||
|
Configure::bootstrap(true);
|
||||||
|
$result = Configure::read('App');
|
||||||
|
|
||||||
|
$this->assertEquals($expected['foo'], $result['foo']);
|
||||||
|
$this->assertFalse($result['base']);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* testRead method
|
* testRead method
|
||||||
*
|
*
|
||||||
|
|
|
@ -150,10 +150,6 @@ App::uses('Cache', 'Cache');
|
||||||
App::uses('Object', 'Core');
|
App::uses('Object', 'Core');
|
||||||
App::uses('Multibyte', 'I18n');
|
App::uses('Multibyte', 'I18n');
|
||||||
|
|
||||||
App::$bootstrapping = true;
|
|
||||||
|
|
||||||
Configure::bootstrap(isset($boot) ? $boot : true);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Full URL prefix
|
* Full URL prefix
|
||||||
*/
|
*/
|
||||||
|
@ -172,6 +168,10 @@ if (!defined('FULL_BASE_URL')) {
|
||||||
unset($httpHost, $s);
|
unset($httpHost, $s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
App::$bootstrapping = true;
|
||||||
|
|
||||||
|
Configure::bootstrap(isset($boot) ? $boot : true);
|
||||||
|
|
||||||
if (function_exists('mb_internal_encoding')) {
|
if (function_exists('mb_internal_encoding')) {
|
||||||
$encoding = Configure::read('App.encoding');
|
$encoding = Configure::read('App.encoding');
|
||||||
if (!empty($encoding)) {
|
if (!empty($encoding)) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue