mirror of
https://github.com/PostgreSQL-For-Wordpress/postgresql-for-wordpress.git
synced 2025-07-30 17:57:13 +02:00
Fix connection failure handling
If the connection fails, bail early. Otherwise the processing of the queued SQL statements will cause an infinite loop by continually pushing the same statement into the queue due to lack of connection. Also add a local variable for the connection for clarity and performance. Signed-off-by: Kevin Locke <kevin@kevinlocke.name>
This commit is contained in:
@ -91,15 +91,15 @@
|
||||
$pg_connstr = $GLOBALS['pg4wp_connstr'].' dbname='.$dbname;
|
||||
|
||||
// Note: pg_connect returns existing connection for same connstr
|
||||
$GLOBALS['pg4wp_conn'] = pg_connect($pg_connstr);
|
||||
|
||||
if( $GLOBALS['pg4wp_conn'])
|
||||
{
|
||||
$ver = pg_version($GLOBALS['pg4wp_conn']);
|
||||
if( isset($ver['server']))
|
||||
$GLOBALS['pg4wp_version'] = $ver['server'];
|
||||
}
|
||||
|
||||
$GLOBALS['pg4wp_conn'] = $conn = pg_connect($pg_connstr);
|
||||
|
||||
if( !$conn)
|
||||
return $conn;
|
||||
|
||||
$ver = pg_version($conn);
|
||||
if( isset($ver['server']))
|
||||
$GLOBALS['pg4wp_version'] = $ver['server'];
|
||||
|
||||
// Now we should be connected, we "forget" about the connection parameters (if this is not a "test" connection)
|
||||
if( !defined('WP_INSTALLING') || !WP_INSTALLING)
|
||||
$GLOBALS['pg4wp_connstr'] = '';
|
||||
@ -109,7 +109,7 @@
|
||||
foreach( $GLOBALS['pg4wp_pre_sql'] as $sql2run)
|
||||
wpsql_query( $sql2run);
|
||||
|
||||
return $GLOBALS['pg4wp_conn'];
|
||||
return $conn;
|
||||
}
|
||||
|
||||
function wpsql_fetch_array($result)
|
||||
|
Reference in New Issue
Block a user