rdbms: Replace reportConnectionError() with direct throws
authorTimo Tijhof <krinklemail@gmail.com>
Thu, 19 Apr 2018 23:21:51 +0000 (00:21 +0100)
committerKrinkle <krinklemail@gmail.com>
Thu, 26 Apr 2018 04:25:17 +0000 (04:25 +0000)
commitc7fc4ef9bf3dc044e8da3497fdab226bc177dd88
tree0dc93072b4a8f0bd95e4099e564a02a6900a114b
parentda5da8bbd69ce7d3c46b7de72a5a4da1a1a9c6ef
rdbms: Replace reportConnectionError() with direct throws

When reading through DatabaseMysqlBase::open(), it was not
obvious that execution would not continue after the conditional
`!$this->conn` block, given it ends in a method call, without
return or throw. I considered adding a return statement after it
for clarity, but it seems in this case it might make more sense
to throw directly given $error here has already gone through a
fallback to getLastError() a few lines up.

Replace the other three calls to reportConnectionError() as well,
which previously passed a useful string that was overwritten
with lastError(). Instead, log both. And make their call to
queryLogger->error() match the previous ones to have an 'error' as well.

This leaves reportConnectionError() as being unused, except for
a call from LoadBalancer. That call was problematic because
it was inside a conditional for IDatabase, but the method isn't
part of that interface. Replace it with a direct throw as well.

Deprecate the method as its now unused in core, and also remove its
'# New method' comment which hasn't made sense since r75341 (16cded8b32).

Change-Id: I0f2ef00ba44bf7090a3ce54edeb8c7e8e543e46a
includes/libs/rdbms/database/Database.php
includes/libs/rdbms/database/DatabaseMysqlBase.php
includes/libs/rdbms/loadbalancer/LoadBalancer.php