Remove return $config in config/config.php

I always thought that doing this is pretty unusual... But now it simply breaks BC - please refer to @Lomanic's [comment](https://github.com/picocms/Pico/pull/260#issuecomment-152610857). Using a return statement has no advantages, but increases the probability that something goes wrong (e.g. a clueless user removes the return statement). It was introduced with 23b90e2, but we never released it ([v0.9.1](4cb2b24fae/lib/pico.php (L188-L189))). Removing the return statement shouldn't cause any problems even for users which installed Pico in the meantime. As a result we don't break BC and moreover remove a prior BC break 😃
This commit is contained in:
Daniel Rudolf 2015-10-31 00:32:08 +01:00
parent afb55b9cb6
commit 9a702415fb
3 changed files with 11 additions and 11 deletions

View file

@ -16,8 +16,6 @@
* @version 0.9
*/
$config = array();
/*
* BASIC
*/
@ -58,6 +56,3 @@ $config = array();
* CUSTOM
*/
// $config['custom_setting'] = 'Hello'; // Can be accessed by {{ config.custom_setting }} in a theme
// DO NOT REMOVE THIS LINE
return $config;

View file

@ -427,6 +427,7 @@ class Pico
*/
protected function loadConfig()
{
$config = null;
$defaultConfig = array(
'site_title' => 'Pico',
'base_url' => '',
@ -442,7 +443,9 @@ class Pico
);
$configFile = $this->getConfigDir() . 'config.php';
$config = file_exists($configFile) ? require($configFile) : null;
if (file_exists($configFile)) {
require $configFile;
}
$this->config = is_array($this->config) ? $this->config : array();
$this->config += is_array($config) ? $config + $defaultConfig : $defaultConfig;

View file

@ -144,16 +144,18 @@ class PicoDeprecated extends AbstractPicoPlugin
*
* @see PicoDeprecated::onConfigLoaded()
* @see Pico::loadConfig()
* @param mixed[] &$config array of config variables
* @param mixed[] &$realConfig array of config variables
* @return void
*/
protected function loadRootDirConfig(&$config)
protected function loadRootDirConfig(&$realConfig)
{
if (file_exists($this->getRootDir() . 'config.php')) {
// config.php in Pico::$rootDir is deprecated; use Pico::$configDir instead
$newConfig = require($this->getRootDir() . 'config.php');
if (is_array($newConfig)) {
$config = $newConfig + $config;
$config = null;
require($this->getRootDir() . 'config.php');
if (is_array($config)) {
$realConfig = $config + $realConfig;
}
}
}