Skip to content

Commit

Permalink
Perform obsolete check against db config also
Browse files Browse the repository at this point in the history
Previously the check for usage of obsolete configuration variables was
only performed against global variables (defined in config_inc.php).
With this change, a more thorough verification is done, including
values with an override in mantis_config_table.

Detailed information about where the config option is set (database
and/or config_inc.php), for which user(s) and for which project(s), is
printed with the warning message.

To implement this functionality, it was required to alter the order in
which the checks are executed by check/index.php: the DB checks must be
performed before the Configuration checks, otherwise there is no DB
connectivity to verify values in the config table.

Fixes #13435
  • Loading branch information
dregad committed Nov 20, 2011
1 parent d1cd06c commit 2ef79a9
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 9 deletions.
10 changes: 5 additions & 5 deletions admin/check/index.php
Expand Up @@ -82,6 +82,11 @@
define( 'CHECK_PHP_INC_ALLOW', true );
include( 'check_php_inc.php' );

if( !$g_failed_test ) {
define( 'CHECK_DATABASE_INC_ALLOW', true );
include( 'check_database_inc.php' );
}

if( !$g_failed_test ) {
define( 'CHECK_CONFIG_INC_ALLOW', true );
include( 'check_config_inc.php' );
Expand All @@ -97,11 +102,6 @@
include( 'check_integrity_inc.php' );
}

if( !$g_failed_test ) {
define( 'CHECK_DATABASE_INC_ALLOW', true );
include( 'check_database_inc.php' );
}

if( !$g_failed_test ) {
define( 'CHECK_CRYPTO_INC_ALLOW', true );
include( 'check_crypto_inc.php' );
Expand Down
30 changes: 26 additions & 4 deletions core/config_api.php
Expand Up @@ -533,24 +533,46 @@ function config_flush_cache( $p_option = '', $p_user = ALL_USERS, $p_project = A
# Checks if an obsolete configuration variable is still in use. If so, an error
# will be generated and the script will exit. This is called from admin_check.php.
function config_obsolete( $p_var, $p_replace = '' ) {
global $g_cache_config;

# @@@ we could trigger a WARNING here, once we have errors that can
# have extra data plugged into them (we need to give the old and
# new config option names in the warning text)

if( config_is_set( $p_var ) ) {
$t_description = 'The configuration option <em>' . $p_var . '</em> is now obsolete';
$t_info = '';

// Check if set in the database
if( is_array( $g_cache_config ) && array_key_exists( $p_var, $g_cache_config ) ) {
$t_info .= 'it is currently defined in ';
if( isset( $GLOBALS['g_' . $p_var] ) ) {
$t_info .= 'config_inc.php, as well as in ';
}
$t_info .= 'the database configuration for: <ul>';

foreach( $g_cache_config[$p_var] as $t_user_id => $t_user ) {
$t_info .= '<li>'
. (($t_user_id == 0)? lang_get('all_users') : user_get_name( $t_user_id ))
. ': ';
foreach ( $t_user as $t_project_id => $t_project ) {
$t_info .= project_get_name( $t_project_id ) . ', ';
}
$t_info = rtrim( $t_info, ', ') . '</li>';
}
$t_info .= '</ul>';
}

// Replacement defined
if( is_array( $p_replace ) ) {
$t_info = 'please see the following options: <ul>';
$t_info .= 'please see the following options: <ul>';
foreach( $p_replace as $t_option ) {
$t_info .= '<li>' . $t_option . '</li>';
}
$t_info .= '</ul>';
}
else if( !is_blank( $p_replace ) ) {
$t_info = 'please use ' . $p_replace . ' instead.';
} else {
$t_info = '';
$t_info .= 'please use ' . $p_replace . ' instead.';
}

check_print_test_warn_row( $t_description, false, $t_info );
Expand Down

0 comments on commit 2ef79a9

Please sign in to comment.