PicoDeprecated: Making $config globally accessible again

This was dropped without a replacement with Pico 0.9. I checked all changes since Pico 0.8 manually, as far as I can tell there should be no more surprises regarding BC... Thanks @Lomanic for rubbing our nose in the fact that we should check this! I also added the missing changes of Pico 0.9 to changelog.txt
This commit is contained in:
Daniel Rudolf 2015-10-31 01:03:24 +01:00
parent 9a702415fb
commit 8da62f4aad
2 changed files with 29 additions and 14 deletions

View file

@ -16,7 +16,7 @@
and `AbstractPicoPlugin`); if you're plugin dev, you really should
take a look at the UPGRADE section of the docs!
* [New] Introducing the `PicoDeprecated` plugin to maintain full backward
compatibility with Pico 0.9 and older
compatibility with Pico 0.9 and Pico 0.8
* [New] Support YAML-style meta header comments (`---`)
* [New] Various new placeholders to use in content files (e.g. `%site_title%`)
* [New] Provide access to all meta headers in content files (`%meta.*%`)
@ -68,11 +68,15 @@
2015.04.28 - version 0.9
* [New] Default theme is now mobile-friendly
* [New] Description meta now available in content areas
* [New] Add description to composer.json
* [Changed] content folder is now content-sample
* [Changed] config.php moved to config.php.template
* [Changed] Updated documentation & wiki
* [Changed] Removed Composer, Twig files in /vendor, you must run composer install now
* [Changed] Localized date format; strftime() instead of date()
* [Changed] Added ignore for tmp file extensions in the get_files() method
* [Changed] michelf/php-markdown is replaced with erusev/parsedown-extra
* [Changed] $config is no global variable anymore
* [Fixed] Pico now only removes the 1st comment block in .md files
* [Fixed] Issue wherein the alphabetical sorting of pages did not happen

View file

@ -88,27 +88,38 @@ class PicoDeprecated extends AbstractPicoPlugin
/**
* Triggers the deprecated event config_loaded($config)
*
* @see PicoDeprecated::defineConstants()
* @see PicoDeprecated::loadRootDirConfig()
* @see PicoDeprecated::enablePlugins()
* @see DummyPlugin::onConfigLoaded()
* This method also defines deprecated constants, reads the `config.php`
* in Picos root dir, enables the plugins {@link PicoParsePagesContent}
* and {@link PicoExcerpt} and makes `$config` globally accessible (the
* latter was removed with Pico 0.9 and was added again as deprecated
* feature with Pico 1.0)
*
* @see PicoDeprecated::defineConstants()
* @see PicoDeprecated::loadRootDirConfig()
* @see PicoDeprecated::enablePlugins()
* @see DummyPlugin::onConfigLoaded()
* @param mixed[] &$realConfig array of config variables
* @return void
*/
public function onConfigLoaded(&$config)
public function onConfigLoaded(&$realConfig)
{
$this->defineConstants();
$this->loadRootDirConfig($config);
$this->enablePlugins();
global $config;
$this->triggerEvent('config_loaded', array(&$config));
$this->defineConstants();
$this->loadRootDirConfig($realConfig);
$this->enablePlugins();
$config = &$realConfig;
$this->triggerEvent('config_loaded', array(&$realConfig));
}
/**
* Defines deprecated constants
*
* `CONTENT_DIR` is deprecated since v0.9, `ROOT_DIR`, `LIB_DIR`,
* `PLUGINS_DIR`, `THEMES_DIR` and `CONTENT_EXT` since v1.0, `CONFIG_DIR`
* existed just for a short time between v0.9 and v1.0 and `CACHE_DIR`
* was dropped with v1.0 without a replacement.
* `ROOT_DIR`, `LIB_DIR`, `PLUGINS_DIR`, `THEMES_DIR` and `CONTENT_EXT`
* are deprecated since v1.0, `CONTENT_DIR` existed just in v0.9,
* `CONFIG_DIR` just for a short time between v0.9 and v1.0 and
* `CACHE_DIR` was dropped with v1.0 without a replacement.
*
* @see PicoDeprecated::onConfigLoaded()
* @return void