From 2e15e112f731034db32fbd6895f0f432e41cc77f Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Sun, 4 Oct 2015 18:50:16 +0200 Subject: [PATCH] Define deprecated constants before evaluating the config.php in Picos root dir This prevents E_NOTICEs when using e.g. ROOT_DIR in a old config.php, so upgrading users are usually not bothered with this BC break --- plugins/00-PicoDeprecated.php | 52 +++++++++++++++++------------------ 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/plugins/00-PicoDeprecated.php b/plugins/00-PicoDeprecated.php index 7edf739..d39b229 100644 --- a/plugins/00-PicoDeprecated.php +++ b/plugins/00-PicoDeprecated.php @@ -93,32 +93,6 @@ class PicoDeprecated extends AbstractPicoPlugin */ public function onConfigLoaded(&$config) { - 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; - } - } - - // enable PicoParsePagesContent and PicoExcerpt - // we can't enable them during onPluginsLoaded because we can't know - // if the user disabled us (PicoDeprecated) manually in the config - $plugins = $this->getPlugins(); - if (isset($plugins['PicoParsePagesContent'])) { - // parse all pages content if this plugin hasn't - // be explicitly enabled/disabled yet - if (!$plugins['PicoParsePagesContent']->isStatusChanged()) { - $plugins['PicoParsePagesContent']->setEnabled(true, true, true); - } - } - if (isset($plugins['PicoExcerpt'])) { - // enable excerpt plugin if it hasn't be explicitly enabled/disabled yet - if (!$plugins['PicoExcerpt']->isStatusChanged()) { - $plugins['PicoExcerpt']->setEnabled(true, true, true); - } - } - // CONTENT_DIR constant is deprecated since v0.9, // ROOT_DIR, LIB_DIR, PLUGINS_DIR, THEMES_DIR and CONTENT_EXT constants since v1.0, // CONFIG_DIR constant existed just for a short time between v0.9 and v1.0, @@ -146,6 +120,32 @@ class PicoDeprecated extends AbstractPicoPlugin define('CONTENT_EXT', $config['content_ext']); } + 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; + } + } + + // enable PicoParsePagesContent and PicoExcerpt + // we can't enable them during onPluginsLoaded because we can't know + // if the user disabled us (PicoDeprecated) manually in the config + $plugins = $this->getPlugins(); + if (isset($plugins['PicoParsePagesContent'])) { + // parse all pages content if this plugin hasn't + // be explicitly enabled/disabled yet + if (!$plugins['PicoParsePagesContent']->isStatusChanged()) { + $plugins['PicoParsePagesContent']->setEnabled(true, true, true); + } + } + if (isset($plugins['PicoExcerpt'])) { + // enable excerpt plugin if it hasn't be explicitly enabled/disabled yet + if (!$plugins['PicoExcerpt']->isStatusChanged()) { + $plugins['PicoExcerpt']->setEnabled(true, true, true); + } + } + $this->triggerEvent('config_loaded', array(&$config)); }