From 9ffd549e99bebf3a94e826679bbe36076e07fc50 Mon Sep 17 00:00:00 2001 From: Damien Regad Date: Sun, 20 Sep 2020 15:19:41 +0200 Subject: [PATCH] Define constants for Plugin Priority Previously, these values were hardcoded. Note that the priority for the MantisCore pseudo-plugin is now set to HIGHEST instead of 3 previously. This avoids creating another constant, considering that it makes sense to load this first anyway. As suggested by @atrol in [[1]]. [1]: https://github.com/mantisbt/mantisbt/pull/1700#issuecomment-695351578 --- core/constant_inc.php | 4 ++++ core/plugin_api.php | 4 ++-- core/print_api.php | 8 +++++--- manage_plugin_update.php | 2 +- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/core/constant_inc.php b/core/constant_inc.php index fc10021b9c..93d0d8c50a 100644 --- a/core/constant_inc.php +++ b/core/constant_inc.php @@ -233,6 +233,10 @@ define( 'CONFIRMATION_TYPE_WARNING', 1 ); define( 'CONFIRMATION_TYPE_FAILURE', 2 ); +# Plugin management +define( 'PLUGIN_PRIORITY_LOW', 1 ); +define( 'PLUGIN_PRIORITY_HIGH', 5 ); + # error messages define( 'ERROR_PHP', -1 ); define( 'ERROR_GENERIC', 0 ); diff --git a/core/plugin_api.php b/core/plugin_api.php index eda53f62ff..15db260fd1 100644 --- a/core/plugin_api.php +++ b/core/plugin_api.php @@ -95,8 +95,8 @@ function plugin_pop_current() { function plugin_get_force_installed() { $t_forced_plugins = config_get_global( 'plugins_force_installed' ); - # MantisCore pseudo-plugin is force-installed by definition, with priority 3 - $t_forced_plugins['MantisCore'] = 3; + # MantisCore pseudo-plugin is force-installed by definition + $t_forced_plugins['MantisCore'] = PLUGIN_PRIORITY_HIGH; return $t_forced_plugins; } diff --git a/core/print_api.php b/core/print_api.php index 99c5992d3b..252d5ee59d 100644 --- a/core/print_api.php +++ b/core/print_api.php @@ -1262,12 +1262,14 @@ function print_custom_field_projects_list( $p_field_id ) { * @return void */ function print_plugin_priority_list( $p_priority ) { - if( $p_priority < 1 || $p_priority > 5 ) { + if( $p_priority < PLUGIN_PRIORITY_LOW || $p_priority > PLUGIN_PRIORITY_HIGH ) { echo ''; } - for( $i = 5;$i >= 1;$i-- ) { - echo ''; + for( $i = PLUGIN_PRIORITY_HIGH; $i >= PLUGIN_PRIORITY_LOW; $i-- ) { + echo ''; } } diff --git a/manage_plugin_update.php b/manage_plugin_update.php index 139d54e3de..e4d0fcef53 100644 --- a/manage_plugin_update.php +++ b/manage_plugin_update.php @@ -64,7 +64,7 @@ } $f_priority = gpc_get_int( 'priority_'.$t_basename, 3 ); - if( $f_priority < 1 || $f_priority > 5 ) { + if( $f_priority < PLUGIN_PRIORITY_LOW || $f_priority > PLUGIN_PRIORITY_HIGH ) { error_parameters( 'priority_' . $t_basename ); trigger_error( ERROR_INVALID_FIELD_VALUE, ERROR ); }