From 8994317b5f4e05775074a1c943d27fba5af079e9 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Sat, 3 Feb 2018 15:00:52 -0600 Subject: [PATCH] Update: specifically handle known database errors for public account This may be useful for diagnosing a mis-configured public account. Generally, public account access (aka: anonymous) does not use a password. --- common/standard/classes/standard_index.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/common/standard/classes/standard_index.php b/common/standard/classes/standard_index.php index e002fc3..58b8c93 100644 --- a/common/standard/classes/standard_index.php +++ b/common/standard/classes/standard_index.php @@ -532,6 +532,14 @@ class c_standard_index extends c_base_return { // open a database connection $result = $this->database->do_connect(); if (c_base_return::s_has_error($result)) { + if ($user_name == $this->settings['database_user_public']) { + $error_message = $result->get_error(0)->get_message(); + if ($error_message == 'pg_connect(): Unable to connect to PostgreSQL server: fe_sendauth: no password supplied') { + $error = c_base_error::s_log('Unable to connect to database with public account (message = ' . $error_message . ').', ['arguments' => [':{database_account}' => $account_name, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::POSTGRESQL_NO_ACCOUNT); + return c_base_return_error::s_false($error); + } + unset($error_message); + } return c_base_return_error::s_false($result->get_error()); } unset($result); @@ -553,7 +561,7 @@ class c_standard_index extends c_base_return { $account_name = ''; } - $error = c_base_error::s_log(NULL, ['arguments' => [':{account_name}' => $account_name, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::POSTGRESQL_NO_ACCOUNT); + $error = c_base_error::s_log(NULL, ['arguments' => [':{database_account}' => $account_name, ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::POSTGRESQL_NO_ACCOUNT); unset($account_name); return c_base_return_error::s_false($error); -- 1.8.3.1