浏览代码

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
Daniel Rudolf 9 年之前
父节点
当前提交
2e15e112f7
共有 1 个文件被更改,包括 26 次插入26 次删除
  1. 26 26
      plugins/00-PicoDeprecated.php

+ 26 - 26
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));
     }