From 3cc5b5b3a7d71341b36fb5a1b42a6678f2d8060e Mon Sep 17 00:00:00 2001 From: Steve Clay Date: Tue, 19 Jan 2016 17:17:15 -0500 Subject: [PATCH] fix(views): locations specified in /engine/views.php are modifiable When simplecache is on, all view locations are loaded from cache, so no dir scanning/configuration should be done. In elgg_views_boot, we'd forgotten to scan engine/views.php based on this condition. This moves the scanning to the top and into the system cache conditional block. This also gets rid of duplicated code that causes a double scan of the core view files. Fixes #9308 --- engine/classes/Elgg/Application.php | 2 ++ engine/lib/views.php | 24 ++++++++++-------------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/engine/classes/Elgg/Application.php b/engine/classes/Elgg/Application.php index 97d11e36667..9f121d3a8bd 100644 --- a/engine/classes/Elgg/Application.php +++ b/engine/classes/Elgg/Application.php @@ -258,6 +258,7 @@ public function bootCore() { // Elgg is installed as a composer dep, so try to treat the root directory // as a custom plugin that is always loaded last and can't be disabled... if (!elgg_get_config('system_cache_loaded')) { + // configure view locations for the custom plugin (not Elgg core) $viewsFile = Directory\Local::root()->getFile('views.php'); if ($viewsFile->exists()) { $viewsSpec = $viewsFile->includeFile(); @@ -266,6 +267,7 @@ public function bootCore() { } } + // find views for the custom plugin (not Elgg core) _elgg_services()->views->registerPluginViews(Directory\Local::root()->getPath()); } diff --git a/engine/lib/views.php b/engine/lib/views.php index b9bee3ea90d..08380224534 100644 --- a/engine/lib/views.php +++ b/engine/lib/views.php @@ -1508,14 +1508,20 @@ function _elgg_views_send_header_x_frame_options() { * @elgg_event_handler boot system */ function elgg_views_boot() { - if (!elgg_get_config('system_cache_loaded')) { - _elgg_services()->views->registerPluginViews(realpath(__DIR__ . '/../../')); - } - global $CONFIG; if (!elgg_get_config('system_cache_loaded')) { + // Core view files in /views _elgg_services()->views->registerPluginViews(realpath(__DIR__ . '/../../')); + + // Core view definitions in /engine/views.php + $file = dirname(__DIR__) . '/views.php'; + if (is_file($file)) { + $spec = (include $file); + if (is_array($spec)) { + _elgg_services()->views->mergeViewsSpec($spec); + } + } } // on every page @@ -1578,16 +1584,6 @@ function elgg_views_boot() { } } - // Declared views. Unlike plugins, Elgg's root views/ is never scanned, so Elgg cannot override - // these view traditional view files. - $file = dirname(__DIR__) . '/views.php'; - if (is_file($file)) { - $spec = (include $file); - if (is_array($spec)) { - _elgg_services()->views->mergeViewsSpec($spec); - } - } - // set default icon sizes - can be overridden in settings.php or with plugin if (!isset($CONFIG->icon_sizes)) { $icon_sizes = array(