Fix uncaught mysqli_sql_exception in PHP 8.1+ during install backup

Agent-Logs-Url: https://github.com/GameServerPanel/GSP/sessions/e16b79db-af25-4a5f-828d-355ab71d8962

Co-authored-by: iaretechnician <2749183+iaretechnician@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-05-02 00:38:38 +00:00 committed by GitHub
parent 0427f577c6
commit 2fc3a1f8a7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -62,6 +62,11 @@ class OGPDatabaseMySQL extends OGPDatabase
if ( $db_host === NULL )
return -1;
// PHP 8.1+ changed the default mysqli error reporting mode to throw exceptions.
// Disable that so all calling code can continue to rely on return-value error
// checking rather than exception handling.
mysqli_report(MYSQLI_REPORT_OFF);
// Use explicit port when provided; otherwise fall back to MySQL default (3306).
$port = ($db_port !== NULL && $db_port !== '') ? (int)$db_port : NULL;
$this->link = mysqli_connect( $db_host, $db_user, $db_pass, $db_name, $port );
@ -81,7 +86,12 @@ class OGPDatabaseMySQL extends OGPDatabase
if ( !$this->link ) return FALSE;
++$this->queries_;
$result = mysqli_query($this->link,$query);
try {
$result = mysqli_query($this->link,$query);
} catch ( \Throwable $e ) {
error_log("OGPDatabaseMySQL::listQuery exception: " . $e->getMessage());
return FALSE;
}
if ( mysqli_errno($this->link) > 0 )
print mysqli_error($this->link);
@ -1169,7 +1179,12 @@ class OGPDatabaseMySQL extends OGPDatabase
$query = str_replace( "OGP_DB_PREFIX", $this->table_prefix, $query );
++$this->queries_;
mysqli_query($this->link,$query);
try {
mysqli_query($this->link,$query);
} catch ( \Throwable $e ) {
error_log("OGPDatabaseMySQL::query exception: " . $e->getMessage());
return FALSE;
}
if( mysqli_errno($this->link) != 0 )
{