mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-28 12:30:42 +02:00
Merge branch 'develop-olympus' into develop
* develop-olympus: [ticket/10057] Fixes for a bunch of small problems. [ticket/10035] ACP template edit feature allows to read any files on webserver. [ticket/10057] Handle the case of missing interbase extension better. [ticket/10057] Fixed wrong usage of sql_error again, in firebird. [ticket/10057] Fixed usage of sql_error again. [ticket/10057] Condition file/line display on DEBUG_EXTRA or IN_INSTALL. [ticket/10057] Fixed wrong usage of sql_error in postgres dbal. [ticket/10057] Skip ibase_service_attach if firebird connection failed. [ticket/10057] Check for interbase function existence. [ticket/10057] Split statements in firebird dbal for readability. [ticket/10057] Include error collector class file in postgres dbal. [ticket/10057] Moved error collector class into its own file. [ticket/10057] Use a class for error collection. [ticket/10057] More informative error messages in postgres dbal. [ticket/10057] No negative array indexing. [ticket/10057] Report postgres db connection errors.
This commit is contained in:
@@ -18,6 +18,11 @@ if (!defined('IN_PHPBB'))
|
||||
|
||||
include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx);
|
||||
|
||||
if (!class_exists('phpbb_error_collector'))
|
||||
{
|
||||
include($phpbb_root_path . 'includes/error_collector.' . $phpEx);
|
||||
}
|
||||
|
||||
/**
|
||||
* PostgreSQL Database Abstraction Layer
|
||||
* Minimum Requirement is Version 7.3+
|
||||
@@ -26,6 +31,7 @@ include_once($phpbb_root_path . 'includes/db/dbal.' . $phpEx);
|
||||
class dbal_postgres extends dbal
|
||||
{
|
||||
var $last_query_text = '';
|
||||
var $connect_error = '';
|
||||
|
||||
/**
|
||||
* Connect to server
|
||||
@@ -81,13 +87,29 @@ class dbal_postgres extends dbal
|
||||
|
||||
if ($this->persistency)
|
||||
{
|
||||
if (!function_exists('pg_pconnect'))
|
||||
{
|
||||
$this->connect_error = 'pg_pconnect function does not exist, is pgsql extension installed?';
|
||||
return $this->sql_error('');
|
||||
}
|
||||
$collector = new phpbb_error_collector;
|
||||
$collector->install();
|
||||
$this->db_connect_id = (!$new_link) ? @pg_pconnect($connect_string) : @pg_pconnect($connect_string, PGSQL_CONNECT_FORCE_NEW);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!function_exists('pg_connect'))
|
||||
{
|
||||
$this->connect_error = 'pg_connect function does not exist, is pgsql extension installed?';
|
||||
return $this->sql_error('');
|
||||
}
|
||||
$collector = new phpbb_error_collector;
|
||||
$collector->install();
|
||||
$this->db_connect_id = (!$new_link) ? @pg_connect($connect_string) : @pg_connect($connect_string, PGSQL_CONNECT_FORCE_NEW);
|
||||
}
|
||||
|
||||
$collector->uninstall();
|
||||
|
||||
if ($this->db_connect_id)
|
||||
{
|
||||
if (version_compare($this->sql_server_info(true), '8.2', '>='))
|
||||
@@ -102,6 +124,7 @@ class dbal_postgres extends dbal
|
||||
return $this->db_connect_id;
|
||||
}
|
||||
|
||||
$this->connect_error = $collector->format_errors();
|
||||
return $this->sql_error('');
|
||||
}
|
||||
|
||||
@@ -387,8 +410,19 @@ class dbal_postgres extends dbal
|
||||
*/
|
||||
function _sql_error()
|
||||
{
|
||||
// pg_last_error only works when there is an established connection.
|
||||
// Connection errors have to be tracked by us manually.
|
||||
if ($this->db_connect_id)
|
||||
{
|
||||
$message = @pg_last_error($this->db_connect_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
$message = $this->connect_error;
|
||||
}
|
||||
|
||||
return array(
|
||||
'message' => (!$this->db_connect_id) ? @pg_last_error() : @pg_last_error($this->db_connect_id),
|
||||
'message' => $message,
|
||||
'code' => ''
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user