Skip to content

Commit

Permalink
Remove check for really old pre 1.x installer logic
Browse files Browse the repository at this point in the history
  • Loading branch information
mantis committed Oct 15, 2013
1 parent ad7009c commit 9da643a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 44 deletions.
3 changes: 1 addition & 2 deletions lang/strings_english.txt
Expand Up @@ -647,8 +647,7 @@ $s_warning_change_setting = '<strong>Warning:</strong> "%1$s" is not set to its
$s_warning_security_hazard = 'is a potential security hazard as it can expose sensitive information.';
$s_warning_integrity_hazard = 'will cause Mantis to continue when errors occurs and may lead to system/data integrity issues.';
$s_warning_debug_email = '<strong>Warning:</strong> "debug_email" is not OFF, all notification e-mails will be sent to "%1$s".';
$s_error_database_version_out_of_date_1 = '<strong>Error:</strong> The database structure appears to be out of date (config(databaseversion) is 0 and old upgrade tables exist). Version 1.x of MantisBT introduced a new upgrade process. You appear to be upgrading from a 0.XX Release. Please upgrade to 1.0.8 or 1.1.X, then upgrade to 1.2.';
$s_error_database_no_schema_version = '<strong>Error:</strong> The database structure appears to be out of date (config(databaseversion) is 0 and old upgrade tables do not exist). Please check that your database is running - we can not retrieve the database schema version. Config Table did not return a valid database schema version - please ask for support on the mantis-help mailing list if required.';
$s_error_database_no_schema_version = '<strong>Error:</strong> The database structure appears to be out of date (config(databaseversion) is 0) or corrupt. Please check that your database is running - we can not retrieve the database schema version. Config Table did not return a valid database schema version - please ask for support on the mantis-help mailing list if required.';
$s_error_database_version_out_of_date_2 = '<strong>Warning:</strong> The database structure may be out of date. Please upgrade <a href="admin/install.php">here</a> before logging in.';
$s_error_code_version_out_of_date = '<strong>Warning:</strong> The database structure is more up-to-date than the code installed. Please upgrade the code.';

Expand Down
58 changes: 16 additions & 42 deletions login_page.php
Expand Up @@ -238,52 +238,26 @@ function debug_setting_message ( $p_type, $p_setting, $p_value ) {
$t_warnings[] = sprintf( lang_get( 'warning_debug_email' ), $t_debug_email );
}

# Check if the admin directory is available and is readable.
$t_admin_dir = dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'admin' . DIRECTORY_SEPARATOR;
if ( is_dir( $t_admin_dir ) ) {
$t_warnings[] = lang_get( 'warning_admin_directory_present' );
# since admin directory and db_upgrade lists are available check for missing db upgrades
# if db version is 0, we do not have a valid database.
$t_db_version = config_get( 'database_version' , 0 );
if ( $t_db_version == 0 ) {
$t_warnings[] = lang_get( 'error_database_no_schema_version' );
}
if ( is_dir( $t_admin_dir ) && is_readable( $t_admin_dir ) && is_executable( $t_admin_dir ) && @file_exists( "$t_admin_dir/." ) ) {
# since admin directory and db_upgrade lists are available check for missing db upgrades
# Check for db upgrade for versions < 1.0.0 using old upgrader
$t_db_version = config_get( 'database_version' , 0 );
# if db version is 0, we haven't moved to new installer.
if ( $t_db_version == 0 ) {
$t_upgrade_count = 0;
if ( db_table_exists( db_get_table( 'upgrade' ) ) ) {
$query = "SELECT COUNT(*) from " . db_get_table( 'upgrade' ) . ";";
$result = db_query_bound( $query );
if ( db_num_rows( $result ) > 0 ) {
$t_upgrade_count = (int)db_result( $result );
}
}

if ( $t_upgrade_count > 0 ) { # table exists, check for number of updates

# new config table database version is 0.
# old upgrade tables exist.
# assume user is upgrading from <1.0 and therefore needs to update to 1.x before upgrading to 1.2
$t_warnings[] = lang_get( 'error_database_version_out_of_date_1' );
} else {
# old upgrade tables do not exist, yet config database_version is 0
$t_warnings[] = lang_get( 'error_database_no_schema_version' );
}
}

# Check for db upgrade for versions > 1.0.0 using new installer and schema
# Note: install_helper_functions_api.php required for db_null_date() function definition
require_api( 'install_helper_functions_api.php' );
require_once( 'admin' . DIRECTORY_SEPARATOR . 'schema.php' );
$t_upgrades_reqd = count( $upgrade ) - 1;
# Check for db upgrade for versions > 1.0.0 using new installer and schema
# Note: install_helper_functions_api.php required for db_null_date() function definition
require_api( 'install_helper_functions_api.php' );
require_once( 'admin' . DIRECTORY_SEPARATOR . 'schema.php' );
$t_upgrades_reqd = count( $upgrade ) - 1;

if ( ( 0 < $t_db_version ) &&
( $t_db_version != $t_upgrades_reqd ) ) {
if ( ( 0 < $t_db_version ) &&
( $t_db_version != $t_upgrades_reqd ) ) {

if ( $t_db_version < $t_upgrades_reqd ) {
$t_warnings[] = lang_get( 'error_database_version_out_of_date_2' );
} else {
$t_warnings[] = lang_get( 'error_code_version_out_of_date' );
}
if ( $t_db_version < $t_upgrades_reqd ) {
$t_warnings[] = lang_get( 'error_database_version_out_of_date_2' );
} else {
$t_warnings[] = lang_get( 'error_code_version_out_of_date' );
}
}
if( count( $t_warnings ) > 0 ) {
Expand Down

0 comments on commit 9da643a

Please sign in to comment.