make sure robust db is connected after converting robust ini

This commit is contained in:
Olivier van Helden
2025-02-02 15:18:13 -04:00
parent e9ce39c309
commit 4b5d1dea28
3 changed files with 21 additions and 7 deletions
+7 -3
View File
@@ -41,6 +41,9 @@ class OpenSim_Grid {
$is_local_grid = true;
// Default, get login_uri from config, query grid for live grid_info
$grid_uri = OpenSim::get_option( 'Hypergrid.HomeURI' );
if( empty( $grid_uri ) ) {
return false;
}
} else {
$is_local_grid = false;
// External grid lookup, not yet implemented
@@ -168,7 +171,6 @@ class OpenSim_Grid {
$grid_stats = self::get_grid_stats( $args );
if( ! $grid_stats || OpenSim::is_error( $grid_stats ) ) {
error_log( __METHOD__ . ' grid stats empty or error' );
return false;
}
@@ -197,6 +199,10 @@ class OpenSim_Grid {
public static function get_grid_stats( $args = null ) {
$grid_info = self::get_grid_info();
if( empty( $grid_info ) ) {
return false;
}
$grid_uri = $grid_info['login'];
$args = array_merge(array(
@@ -212,7 +218,6 @@ class OpenSim_Grid {
if ( ! $robust_db || OpenSim::is_error($robust_db) ) {
$stats['error'] = _('Database not connected.');
} else {
error_log('querying robust db');
$lastmonth = time() - 30 * 86400;
$gridonline = $grid_info['online'] ? _('Yes') : _('No');
@@ -265,7 +270,6 @@ class OpenSim_Grid {
// Replace keys with values of self::$labels
$labels = self::$labels;
$labels = array_intersect_key( self::$labels, $stats );
error_log( 'labels: ' . print_r( $labels, true ) . ' stats: ' . print_r( $stats, true ) );
$stats = array_combine( $labels, $stats );
}
+3 -3
View File
@@ -52,14 +52,14 @@ class OpenSim {
require_once( OSHELPERS_DIR . 'classes/class-exception.php' );
require_once( OSHELPERS_DIR . 'includes/databases.php' );
require_once( OSHELPERS_DIR . 'includes/functions.php' );
$this->connect_db();
$this->db_connect();
require_once( OSHELPERS_DIR . 'classes/class-locale.php' );
require_once( OSHELPERS_DIR . 'classes/class-ini.php' );
require_once( OSHELPERS_DIR . 'classes/class-grid.php' );
}
public function connect_db() {
public function db_connect() {
$DatabaseService = self::get_option( 'DatabaseService', false );
$connectionstring = self::get_option( 'DatabaseService.ConnectionString', false);
@@ -77,7 +77,7 @@ class OpenSim {
self::$robust_db = $db;
}
} else {
error_log('No connection string found');
return false;
}
}
+11 -1
View File
@@ -236,7 +236,17 @@ class OpenSim_Install extends OpenSim_Page {
throw new OpenSim_Error( _('Some required values are missing from the configuration file.') );
}
// Connect to Robust to check credential and get up-to-date grid info
global $OpenSim;
try {
$OpenSim->db_connect();
if( ! OpenSim::$robust_db ) {
throw new OpenSim_Error( _('Could not connect to the database.') );
}
} catch (Throwable $e) {
OpenSim::notify_error( $e );
return false;
}
// OpenSim::notify( _('Configuration file loaded successfully.'), 'success' );
// TODO: copy the temp file to the final location on success.
return true;