diff --git a/elevate-cpanel b/elevate-cpanel index ff9bd6e6..9256ffc6 100755 --- a/elevate-cpanel +++ b/elevate-cpanel @@ -5505,6 +5505,11 @@ EOS my $profile_manager = Cpanel::MysqlUtils::RemoteMySQL::ProfileManager->new(); + File::Slurper::write_text( + MYSQL_PROFILE_FILE, + $profile_manager->get_active_profile('dont_die'), + ); + try { $profile_manager->validate_profile('localhost'); $self->_activate_localhost_profile($profile_manager); @@ -5526,9 +5531,6 @@ EOS sub _create_new_localhost_profile ( $self, $profile_manager ) { - my $active_profile = $profile_manager->get_active_profile('dont_die'); - File::Slurper::write_text( MYSQL_PROFILE_FILE, $active_profile ); - my $password = Cpanel::PasswdStrength::Generate::generate_password( 16, no_othersymbols => 1 ); try { diff --git a/lib/Elevate/Components/DatabaseUpgrade.pm b/lib/Elevate/Components/DatabaseUpgrade.pm index ff014b9c..30de81f4 100644 --- a/lib/Elevate/Components/DatabaseUpgrade.pm +++ b/lib/Elevate/Components/DatabaseUpgrade.pm @@ -82,6 +82,13 @@ sub _ensure_localhost_mysql_profile_is_active ( $self, $should_create_localhost_ my $profile_manager = Cpanel::MysqlUtils::RemoteMySQL::ProfileManager->new(); + # Immediately record the currently active profile, as othrewise you can + # miss it in the try/catch below. + File::Slurper::write_text( + MYSQL_PROFILE_FILE, + $profile_manager->get_active_profile('dont_die'), + ); + # Validate that the current “localhost” profile exists, and contains valid settings. try { $profile_manager->validate_profile('localhost'); @@ -105,9 +112,6 @@ sub _ensure_localhost_mysql_profile_is_active ( $self, $should_create_localhost_ sub _create_new_localhost_profile ( $self, $profile_manager ) { - my $active_profile = $profile_manager->get_active_profile('dont_die'); - File::Slurper::write_text( MYSQL_PROFILE_FILE, $active_profile ); - my $password = Cpanel::PasswdStrength::Generate::generate_password( 16, no_othersymbols => 1 ); try {