Skip to content

Commit

Permalink
fix(views): locations specified in /engine/views.php are modifiable
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mrclay committed Jan 19, 2016
1 parent f733b5e commit 3cc5b5b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
2 changes: 2 additions & 0 deletions engine/classes/Elgg/Application.php
Expand Up @@ -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();
Expand All @@ -266,6 +267,7 @@ public function bootCore() {
}
}

// find views for the custom plugin (not Elgg core)
_elgg_services()->views->registerPluginViews(Directory\Local::root()->getPath());
}

Expand Down
24 changes: 10 additions & 14 deletions engine/lib/views.php
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 3cc5b5b

Please sign in to comment.