From ff7f182c8cf1fe030f85d98d20c204b6fa3b05b6 Mon Sep 17 00:00:00 2001 From: Nick Liu Date: Thu, 1 Nov 2018 09:59:17 -0500 Subject: [PATCH] Fixed e_plugin::buildAddonPrefLists() stateful bug Prevents e_plugin::buildAddonPrefLists() from wiping out the variable that is tracking the currently loaded plugin by moving the currently loaded plugin to the end of the iterated array Fixes: #3531 Fixes: e107inc/e107-test#9 --- e107_handlers/plugin_class.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/e107_handlers/plugin_class.php b/e107_handlers/plugin_class.php index 1d9f9a614..b9ac2e1f8 100644 --- a/e107_handlers/plugin_class.php +++ b/e107_handlers/plugin_class.php @@ -998,8 +998,19 @@ class e_plugin ->set('shortcode_legacy_list', array()) ->set('shortcode_list', array()); + $paths = $this->getDetected(); - foreach($this->getDetected() as $path) + /** + * Prevent this method from wiping out the variable that is tracking + * the currently loaded plugin by moving the currently loaded plugin to + * the end of the iterated array. + * @see https://github.com/e107inc/e107/issues/3531 + * @see https://github.com/e107inc/e107-test/issues/9 + */ + $paths = array_diff($paths, [$this->_plugdir]); + $paths[] = $this->_plugdir; + + foreach($paths as $path) { $this->load($path);