Skip to content

Commit

Permalink
Prevent plugin pages access when upgrade pending
Browse files Browse the repository at this point in the history
If a plugin's code has been upgraded, but the schema is still on the old
version, the plugin is effectively disabled (i.e. its entry points are
not displayed). However, it was still possible to access individual
pages directly, which could lead to errors.

This commit adds an extra check in plugin.php which triggers an error
when the plugin needs to be upgraded.

Fixes #16706
  • Loading branch information
dregad committed Feb 4, 2014
1 parent 0db530a commit 896f775
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions core/constant_inc.php
Expand Up @@ -378,6 +378,7 @@
define( 'ERROR_PLUGIN_PAGE_NOT_FOUND', 2502 );
define( 'ERROR_PLUGIN_UPGRADE_FAILED', 2503 );
define( 'ERROR_PLUGIN_INSTALL_FAILED', 2504 );
define( 'ERROR_PLUGIN_UPGRADE_NEEDED', 2505 );
define( 'ERROR_PLUGIN_GENERIC', 2599 );

# ERROR_COLUMNS_*
Expand Down
1 change: 1 addition & 0 deletions lang/strings_english.txt
Expand Up @@ -1668,6 +1668,7 @@ $MANTIS_ERROR[ERROR_PLUGIN_ALREADY_INSTALLED] = 'Plugin is already installed.';
$MANTIS_ERROR[ERROR_PLUGIN_PAGE_NOT_FOUND] = 'Plugin page not found.';
$MANTIS_ERROR[ERROR_PLUGIN_INSTALL_FAILED] = 'Plugin installation failed: %1$s.';
$MANTIS_ERROR[ERROR_PLUGIN_UPGRADE_FAILED] = 'Upgrading the plugin schema failed in block #%1$s.';
$MANTIS_ERROR[ERROR_PLUGIN_UPGRADE_NEEDED] = 'The "%1$s" plugin needs to be upgraded before you can access this page.';
$MANTIS_ERROR[ERROR_PLUGIN_GENERIC] = 'There was an unknown error "%1$s" during execution of the "%2$s" plugin.';
$MANTIS_ERROR[ERROR_COLUMNS_DUPLICATE] = 'Field "%1$s" contains duplicate column "%2$s".';
$MANTIS_ERROR[ERROR_COLUMNS_INVALID] = 'Field "%1$s" contains invalid field "%2$s".';
Expand Down
5 changes: 5 additions & 0 deletions plugin.php
Expand Up @@ -57,6 +57,11 @@
trigger_error( ERROR_PLUGIN_PAGE_NOT_FOUND, ERROR );
}

if( plugin_needs_upgrade( $g_plugin_cache[$t_basename] ) ) {
error_parameters( $t_basename );
trigger_error( ERROR_PLUGIN_UPGRADE_NEEDED, ERROR );
}

plugin_push_current( $t_basename );
include( $t_page );

0 comments on commit 896f775

Please sign in to comment.