diff --git a/App/Config/app.php b/App/Config/app.php index 7e078d804ed..0c90abc90d1 100644 --- a/App/Config/app.php +++ b/App/Config/app.php @@ -110,3 +110,25 @@ $loader = new ClassLoader($namespace, dirname(APP)); $loader->register(); unset($loader, $namespace); + +/** + * Define the FULL_BASE_URL used for link generation. + * In most cases the code below will generate the correct hostname. + * However, you can manually define the hostname to resolve any issues. + */ +$s = null; +if (env('HTTPS')) { + $s = 's'; +} + +$httpHost = env('HTTP_HOST'); +if (isset($httpHost)) { + define('FULL_BASE_URL', 'http' . $s . '://' . $httpHost); +} +unset($httpHost, $s); + +/** + * Configure the mbstring extension to use the correct encoding. + */ +$encoding = Configure::read('App.encoding'); +mb_internal_encoding($encoding); diff --git a/lib/Cake/Console/Templates/skel/Config/app.php b/lib/Cake/Console/Templates/skel/Config/app.php index cc05bbf0186..0c90abc90d1 100644 --- a/lib/Cake/Console/Templates/skel/Config/app.php +++ b/lib/Cake/Console/Templates/skel/Config/app.php @@ -80,9 +80,10 @@ * - cipherSeed - A random numeric string (digits only) used to seed * the xor cipher functions in Security. */ - Configure::write('Security.salt', 'DYhG93b0qyJfIxfs2guVoUubWwvniR2G0FgaC9mi'); - - Configure::write('Security.cipherSeed', '76859309657453542496749683645'); + Configure::write('Security', [ + 'salt' => 'DYhG93b0qyJfIxfs2guVoUubWwvniR2G0FgaC9mi', + 'cipherSeed' => '76859309657453542496749683645', + ]); /** * Apply timestamps with the last modified time to static assets (js, css, images). @@ -109,3 +110,25 @@ $loader = new ClassLoader($namespace, dirname(APP)); $loader->register(); unset($loader, $namespace); + +/** + * Define the FULL_BASE_URL used for link generation. + * In most cases the code below will generate the correct hostname. + * However, you can manually define the hostname to resolve any issues. + */ +$s = null; +if (env('HTTPS')) { + $s = 's'; +} + +$httpHost = env('HTTP_HOST'); +if (isset($httpHost)) { + define('FULL_BASE_URL', 'http' . $s . '://' . $httpHost); +} +unset($httpHost, $s); + +/** + * Configure the mbstring extension to use the correct encoding. + */ +$encoding = Configure::read('App.encoding'); +mb_internal_encoding($encoding); diff --git a/lib/Cake/Routing/Router.php b/lib/Cake/Routing/Router.php index 805e2b10479..d7174046007 100644 --- a/lib/Cake/Routing/Router.php +++ b/lib/Cake/Routing/Router.php @@ -450,7 +450,7 @@ public static function parse($url) { static::_loadRoutes(); } - if ($url && strpos($url, '/') !== 0) { + if (strlen($url) && strpos($url, '/') !== 0) { $url = '/' . $url; } if (strpos($url, '?') !== false) { diff --git a/lib/Cake/Test/TestCase/Routing/RouterTest.php b/lib/Cake/Test/TestCase/Routing/RouterTest.php index 335ed42ad23..eaa224d4f89 100644 --- a/lib/Cake/Test/TestCase/Routing/RouterTest.php +++ b/lib/Cake/Test/TestCase/Routing/RouterTest.php @@ -399,12 +399,12 @@ public function testUrlCatchAllRoute() { $result = Router::url(array('controller' => 'categories', 'action' => 'index', '0')); $this->assertEquals('/0', $result); - $expected = array( + $expected = [ 'plugin' => null, 'controller' => 'categories', 'action' => 'index', - 'pass' => array('0'), - ); + 'pass' => ['0'], + ]; $result = Router::parse('/0'); $this->assertEquals($expected, $result); diff --git a/lib/Cake/Test/TestCase/View/Helper/FormHelperTest.php b/lib/Cake/Test/TestCase/View/Helper/FormHelperTest.php index 8a301cba8cc..91597ec3601 100644 --- a/lib/Cake/Test/TestCase/View/Helper/FormHelperTest.php +++ b/lib/Cake/Test/TestCase/View/Helper/FormHelperTest.php @@ -2750,7 +2750,7 @@ public function testInputMagicSelectForTypeNumber() { 'label' => array('for' => 'ValidateUserBalance'), 'Balance', '/label', - 'select' => array('name' => 'data[ValidateUser][balance]', 'id' => 'ValidateUserBalance'), + 'select' => array('name' => 'ValidateUser[balance]', 'id' => 'ValidateUserBalance'), array('option' => array('value' => '0')), 'nothing', '/option', @@ -7177,7 +7177,7 @@ public function testFormInputRequiredDetection() { 'Iamrequiredalways', '/label', 'input' => array( - 'type' => 'text', 'name' => 'data[Contact][iamrequiredalways]', + 'type' => 'text', 'name' => 'Contact[iamrequiredalways]', 'id' => 'ContactIamrequiredalways' ), '/div' diff --git a/lib/Cake/bootstrap.php b/lib/Cake/bootstrap.php index 3b371c5b8cf..2a64b5e4a23 100644 --- a/lib/Cake/bootstrap.php +++ b/lib/Cake/bootstrap.php @@ -26,30 +26,7 @@ $loader->register(); use Cake\Core\App; +use Cake\Core\Configure; App::init(); App::build(); - -/** - * Full url prefix - */ -if (!defined('FULL_BASE_URL')) { - $s = null; - if (env('HTTPS')) { - $s = 's'; - } - - $httpHost = env('HTTP_HOST'); - - if (isset($httpHost)) { - define('FULL_BASE_URL', 'http' . $s . '://' . $httpHost); - } - unset($httpHost, $s); -} - -spl_autoload_register(array('App', 'load')); - -$encoding = Configure::read('App.encoding'); -if (!empty($encoding)) { - mb_internal_encoding($encoding); -}