Permalink
Browse files

chore(config): Removes several $CONFIG keys and deprecated APIs

Fixes #8524

BREAKING CHANGE:
Several internal data structures are no longer stored within the plugin-
accessible config space; the removed keys are listed in docs/guides/upgrading.rst.
The long-deprecated remove_blacklist() function has also been removed.
  • Loading branch information...
mrclay committed Jun 23, 2015
1 parent 8b3ea65 commit 2247ed808392a16a2fc9e3375de3888427e9db27
View
@@ -224,14 +224,27 @@ Messages will no longer get the metadata 'msg' for newly created messages. This
Removed Classes
---------------
+ - ``ElggInspector``
- ``FilePluginFile``: replace with ``ElggFile`` (or load with ``get_entity()``)
Removed keys available via ``elgg_get_config()``
------------------------------------------------
+ - ``allowed_ajax_views``
+ - ``dataroot_in_settings``
+ - ``externals``
+ - ``externals_map``
+ - ``i18n_loaded_from_cache``
+ - ``language_paths``
+ - ``pagesetupdone``
+ - ``registered_tag_metadata_names``
+ - ``simplecache_enabled_in_settings``
+ - ``translations``
+ - ``viewpath``
- ``views``
+ - ``view_path``
- ``viewtype``
- - ``viewpath``
+ - ``wordblacklist``
Also note that plugins should not be accessing the global ``$CONFIG`` variable except for in ``settings.php``.
@@ -244,6 +257,7 @@ Removed Functions
- ``get_db_link()``
- ``load_plugins()``
- ``mysql_*()``: Elgg :ref:`no longer uses ext/mysql<migrated-to-pdo>`
+ - ``remove_blacklist()``
- ``set_template_handler()``
Removed Plugin Hooks
View
@@ -8,70 +8,13 @@
* @subpackage Configuration
*/
-/**
- * Paths to scan for autoloading languages.
- *
- * Languages are automatically loaded for the site or
- * user's default language. Plugins can extend or override strings.
- * language_paths is an array of paths to scan for PHP files matching
- * the default language. The order of paths is determined by the plugin load order,
- * with later entries overriding earlier. Language files within these paths are
- * named as the two-letter ISO 639-1 country codes for the language they represent.
- *
- * Language paths are stored as array keys in the format:
- * <code>
- * $CONFIG->language_paths[str $language_path] = true
- * </code>
- *
- * @link http://en.wikipedia.org/wiki/ISO_639-1
- * @see register_language()
- * @global array $CONFIG->language_paths
- */
-$CONFIG->language_paths;
-
-
-/**
- * String translations for the current language.
- *
- * Elgg uses a key-based system for string internationalization, which
- * is accessed with {@link elgg_echo()}.
- *
- * Translations are stored as an array in the following format:
- * <code>
- * $CONFIG->translations[str $language_code][str $string_key] = str 'Translated Language String';
- * </code>
- *
- * @see register_translation()
- * @see elgg_echo()
- * @global array $CONFIG->translations
- */
-$CONFIG->translations;
-
-/**
- * An array of metadata names to be used as tags.
- *
- * Because tags are simply names of meatdata, This is used
- * in search to prevent data exposure by searching on
- * arbitrary metadata.
- *
- * @global array $CONFIG->registered_tag_metadata_names
- */
-$CONFIG->registered_tag_metadata_names;
-
/**
* The full path where Elgg is installed.
*
* @global string $CONFIG->path;
*/
$CONFIG->path;
-/**
- * The full path for core views.
- *
- * @global string $CONFIG->view_path
- */
-$CONFIG->view_path;
-
/**
* The full path where plugins are stored.
*
@@ -235,13 +178,6 @@
*/
$CONFIG->menu_items_custom_items;
-/**
- * A list of valid view types as discovered.
- *
- * @global array $CONFIG->view_types
- */
-$CONFIG->view_types;
-
/**
* A list of plugins and their load order
*
@@ -278,14 +214,6 @@
*/
$CONFIG->servicehandler;
-/**
- * A list of stop works for search. Not currently used.
- *
- * @global array $CONFIG->wordblacklist
- * @todo currently unused.
- */
-$CONFIG->wordblacklist;
-
/**
* A list of menu contexts for menus registered with {@link add_menu()}. Not currently used.
*
@@ -336,4 +264,72 @@
*
* @global string $CONFIG->exception_include
*/
-$CONFIG->exception_include = '';
+$CONFIG->exception_include = '';
+
+/**
+ * Paths to scan for autoloading languages.
+ *
+ * Languages are automatically loaded for the site or
+ * user's default language. Plugins can extend or override strings.
+ * language_paths is an array of paths to scan for PHP files matching
+ * the default language. The order of paths is determined by the plugin load order,
+ * with later entries overriding earlier. Language files within these paths are
+ * named as the two-letter ISO 639-1 country codes for the language they represent.
+ *
+ * Language paths are stored as array keys in the format:
+ * <code>
+ * $_ELGG->language_paths[str $language_path] = true
+ * </code>
+ *
+ * @link http://en.wikipedia.org/wiki/ISO_639-1
+ * @see register_language()
+ * @global array $_ELGG->language_paths
+ * @access private
+ */
+$_ELGG->language_paths;
+
+/**
+ * String translations for the current language.
+ *
+ * Elgg uses a key-based system for string internationalization, which
+ * is accessed with {@link elgg_echo()}.
+ *
+ * Translations are stored as an array in the following format:
+ * <code>
+ * $_ELGG->translations[str $language_code][str $string_key] = str 'Translated Language String';
+ * </code>
+ *
+ * @see register_translation()
+ * @see elgg_echo()
+ * @global array $_ELGG->translations
+ * @access private
+ */
+$_ELGG->translations;
+
+/**
+ * An array of metadata names to be used as tags.
+ *
+ * Because tags are simply names of meatdata, This is used
+ * in search to prevent data exposure by searching on
+ * arbitrary metadata.
+ *
+ * @global array $_ELGG->registered_tag_metadata_names
+ * @access private
+ */
+$_ELGG->registered_tag_metadata_names;
+
+/**
+ * The full path for core views.
+ *
+ * @global string $_ELGG->view_path
+ * @access private
+ */
+$_ELGG->view_path;
+
+/**
+ * A list of valid view types as discovered.
+ *
+ * @global array $_ELGG->view_types
+ * @access private
+ */
+$_ELGG->view_types;
@@ -79,6 +79,18 @@ public function __construct(ServiceProvider $services = null) {
$START_MICROTIME = microtime(true);
}
+ /**
+ * This was introduced in 2.0 in order to remove all internal non-API state from $CONFIG. This will
+ * be a breaking change, but frees us to refactor in 2.x without fear of plugins depending on
+ * $CONFIG.
+ *
+ * @access private
+ */
+ global $_ELGG;
+ if (!isset($_ELGG)) {
+ $_ELGG = new \stdClass();
+ }
+
$this->engine_dir = dirname(dirname(__DIR__));
$this->install_dir = dirname($this->engine_dir);
}
@@ -311,13 +311,13 @@ protected function renderView($view, $viewtype) {
// disable error reporting so we don't cache problems
$this->config->set('debug', null);
- // @todo elgg_view() checks if the page set is done (isset($CONFIG->pagesetupdone)) and
+ // @todo elgg_view() checks if the page set is done (isset($GLOBALS['_ELGG']->pagesetupdone)) and
// triggers an event if it's not. Calling elgg_view() here breaks submenus
// (at least) because the page setup hook is called before any
// contexts can be correctly set (since this is called before page_handler()).
// To avoid this, lie about $CONFIG->pagehandlerdone to force
// the trigger correctly when the first view is actually being output.
- $this->config->set('pagesetupdone', true);
+ $GLOBALS['_ELGG']->pagesetupdone = true;
return elgg_view($view);
}
@@ -64,7 +64,7 @@ public function register($type, $name, $url, $location, $priority = 500) {
// no negative priorities right now.
$priority = max((int)$priority, 0);
- $item = elgg_extract($name, $this->CONFIG->externals_map[$type]);
+ $item = elgg_extract($name, $GLOBALS['_ELGG']->externals_map[$type]);
if ($item) {
// updating a registered item
@@ -73,21 +73,21 @@ public function register($type, $name, $url, $location, $priority = 500) {
$item->location = $location;
// if loaded before registered, that means it hasn't been added to the list yet
- if ($this->CONFIG->externals[$type]->contains($item)) {
- $priority = $this->CONFIG->externals[$type]->move($item, $priority);
+ if ($GLOBALS['_ELGG']->externals[$type]->contains($item)) {
+ $priority = $GLOBALS['_ELGG']->externals[$type]->move($item, $priority);
} else {
- $priority = $this->CONFIG->externals[$type]->add($item, $priority);
+ $priority = $GLOBALS['_ELGG']->externals[$type]->add($item, $priority);
}
} else {
$item = new \stdClass();
$item->loaded = false;
$item->url = $url;
$item->location = $location;
- $priority = $this->CONFIG->externals[$type]->add($item, $priority);
+ $priority = $GLOBALS['_ELGG']->externals[$type]->add($item, $priority);
}
-
- $this->CONFIG->externals_map[$type][$name] = $item;
+
+ $GLOBALS['_ELGG']->externals_map[$type][$name] = $item;
return $priority !== false;
}
@@ -105,11 +105,11 @@ public function unregister($type, $name) {
$this->bootstrap($type);
$name = trim(strtolower($name));
- $item = elgg_extract($name, $this->CONFIG->externals_map[$type]);
+ $item = elgg_extract($name, $GLOBALS['_ELGG']->externals_map[$type]);
if ($item) {
- unset($this->CONFIG->externals_map[$type][$name]);
- return $this->CONFIG->externals[$type]->remove($item);
+ unset($GLOBALS['_ELGG']->externals_map[$type][$name]);
+ return $GLOBALS['_ELGG']->externals[$type]->remove($item);
}
return false;
@@ -130,7 +130,7 @@ public function load($type, $name) {
$name = trim(strtolower($name));
- $item = elgg_extract($name, $this->CONFIG->externals_map[$type]);
+ $item = elgg_extract($name, $GLOBALS['_ELGG']->externals_map[$type]);
if ($item) {
// update a registered item
@@ -140,9 +140,9 @@ public function load($type, $name) {
$item->loaded = true;
$item->url = '';
$item->location = '';
-
- $this->CONFIG->externals[$type]->add($item);
- $this->CONFIG->externals_map[$type][$name] = $item;
+
+ $GLOBALS['_ELGG']->externals[$type]->add($item);
+ $GLOBALS['_ELGG']->externals_map[$type][$name] = $item;
}
}
@@ -158,11 +158,11 @@ public function getLoadedFiles($type, $location) {
if (
- isset($this->CONFIG->externals)
- && isset($this->CONFIG->externals[$type])
- && $this->CONFIG->externals[$type] instanceof \ElggPriorityList
+ isset($GLOBALS['_ELGG']->externals)
+ && isset($GLOBALS['_ELGG']->externals[$type])
+ && $GLOBALS['_ELGG']->externals[$type] instanceof \ElggPriorityList
) {
- $items = $this->CONFIG->externals[$type]->getElements();
+ $items = $GLOBALS['_ELGG']->externals[$type]->getElements();
$items = array_filter($items, function($v) use ($location) {
return $v->loaded == true && $v->location == $location;
@@ -178,27 +178,27 @@ public function getLoadedFiles($type, $location) {
}
/**
- * Bootstraps the externals data structure in $CONFIG.
+ * Bootstraps the externals data structure in $_ELGG.
*
* @param string $type The type of external, js or css.
* @return null
*/
protected function bootstrap($type) {
- if (!isset($this->CONFIG->externals)) {
- $this->CONFIG->externals = array();
+ if (!isset($GLOBALS['_ELGG']->externals)) {
+ $GLOBALS['_ELGG']->externals = array();
}
- if (!isset($this->CONFIG->externals[$type]) || !$this->CONFIG->externals[$type] instanceof \ElggPriorityList) {
- $this->CONFIG->externals[$type] = new \ElggPriorityList();
+ if (!isset($GLOBALS['_ELGG']->externals[$type]) || !$GLOBALS['_ELGG']->externals[$type] instanceof \ElggPriorityList) {
+ $GLOBALS['_ELGG']->externals[$type] = new \ElggPriorityList();
}
- if (!isset($this->CONFIG->externals_map)) {
- $this->CONFIG->externals_map = array();
+ if (!isset($GLOBALS['_ELGG']->externals_map)) {
+ $GLOBALS['_ELGG']->externals_map = array();
}
- if (!isset($this->CONFIG->externals_map[$type])) {
- $this->CONFIG->externals_map[$type] = array();
+ if (!isset($GLOBALS['_ELGG']->externals_map[$type])) {
+ $GLOBALS['_ELGG']->externals_map[$type] = array();
}
}
}
Oops, something went wrong.

0 comments on commit 2247ed8

Please sign in to comment.