Changeset:
c1da0208e846
https://sourceforge.net/p/mrbs/hg-code/ci/c1da0208e84677108d330b19bd2990c1354745ba
Author:
Campbell Morrison <[email protected]>
Date:
Thu Sep 29 14:20:44 2016 +0100
Log message:
Switched to exceptions in db connection code
diffstat:
web/dbsys.inc | 1 -
web/lib/MRBS/DB.php | 20 ++++++--------------
2 files changed, 6 insertions(+), 15 deletions(-)
diffs (58 lines):
diff -r 331249866f8e -r c1da0208e846 web/dbsys.inc
--- a/web/dbsys.inc Thu Sep 29 12:55:39 2016 +0100
+++ b/web/dbsys.inc Thu Sep 29 14:20:44 2016 +0100
@@ -174,7 +174,6 @@
print_footer(TRUE);
}
-
// Sanity check: check that we can access the MRBS tables. If we can't, it's
// either because they don't exist or we don't have permission.
if (!sql_table_exists($tbl_entry))
diff -r 331249866f8e -r c1da0208e846 web/lib/MRBS/DB.php
--- a/web/lib/MRBS/DB.php Thu Sep 29 12:55:39 2016 +0100
+++ b/web/lib/MRBS/DB.php Thu Sep 29 14:20:44 2016 +0100
@@ -37,12 +37,6 @@
}
// Establish a database connection.
-
- // On connection error, the message will be output without a proper HTML
- // header. There is no way I can see around this; if track_errors isn't on
- // there seems to be no way to supress the automatic error message output
and
- // still be able to access the error text.
-
try
{
$this->dbh = new
PDO(static::DB_DBO_DRIVER.":host=$db_host;port=$db_port;dbname=$db_name",
@@ -54,16 +48,14 @@
}
catch (PDOException $e)
{
- trigger_error($e->getMessage(), E_USER_WARNING);
+ $message = $e->getMessage();
if ($e->getCode() == 2054)
{
- $message = "It looks like you have an old style MySQL password stored,
which cannot be " .
- "used with PDO (though it is possible that mysqli may have
accepted it). Try " .
- "deleting the MySQL user and recreating it with the same
password.";
- trigger_error($message, E_USER_WARNING);
+ $message .= ".\n[MRBS note] It looks like you may have an old style
MySQL password stored, which cannot be " .
+ "used with PDO (though it is possible that mysqli may have
accepted it). Try " .
+ "deleting the MySQL user and recreating it with the same
password.";
}
- echo "\n<p>\n" . get_vocab("failed_connect_db") . "\n</p>\n";
- exit;
+ throw new DBException($message, 0, $e);
}
}
@@ -76,7 +68,7 @@
{
global $db_persist, $db_host, $db_login, $db_password,
$db_database, $db_port, $dbsys;
-
+
self::$default_db_obj = DBFactory::create($dbsys, $db_host, $db_login,
$db_password,
$db_database, $db_persist,
$db_port);
}
------------------------------------------------------------------------------
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits