Merge pull request #3519 from Icinga/fix/mysql-ssl-connection-error-brings-up-no-explanation-3249

Pdo\Abstract: Properly handle incomplete error messages
This commit is contained in:
Eric Lippmann 2018-07-16 09:56:26 +02:00 committed by GitHub
commit 11f1a287ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -133,10 +133,16 @@ abstract class Zend_Db_Adapter_Pdo_Abstract extends Zend_Db_Adapter_Abstract
$this->_connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) {
$message = $e->getMessage();
if ($e->getPrevious() !== null && preg_match('~^SQLSTATE\[HY000\] \[\d{1,4}\]\s$~', $message)) {
// See https://bugs.php.net/bug.php?id=76604
$message .= $e->getPrevious()->getMessage();
}
/**
* @see Zend_Db_Adapter_Exception
*/
throw new Zend_Db_Adapter_Exception($e->getMessage(), $e->getCode(), $e);
throw new Zend_Db_Adapter_Exception($message, $e->getCode(), $e);
}
}