Fix \Combodo\iTop\Test\UnitTest\Core\CMDBSourceTest::testIsOpenedDbConnectionUsingTls

This commit is contained in:
Pierre Goiffon
2021-09-30 10:49:11 +02:00
parent 4d6a8a76aa
commit 9c6d8253f4
3 changed files with 15 additions and 14 deletions

View File

@@ -849,20 +849,19 @@ class CMDBSource
*/
public static function QueryToScalar($sSql, $iCol = 0, $oMysqli = null)
{
$oMysqliForQuery = $oMysqli ?: DbConnectionWrapper::GetDbConnection(true);
$oKPI = new ExecutionKPI();
try
{
/** @noinspection NullPointerExceptionInspection this shouldn't be called with un-init DB */
$oResult = DbConnectionWrapper::GetDbConnection(true)->query($sSql);
try {
/** @noinspection NullPointerExceptionInspection this shouldn't happen : either cnx is passed or the DB was init */
$oResult = $oMysqliForQuery->query($sSql);
}
catch(mysqli_sql_exception $e)
{
catch (mysqli_sql_exception $e) {
$oKPI->ComputeStats('Query exec (mySQL)', $sSql);
throw new MySQLException('Failed to issue SQL query', array('query' => $sSql, $e));
}
$oKPI->ComputeStats('Query exec (mySQL)', $sSql);
if ($oResult === false)
{
if ($oResult === false) {
throw new MySQLException('Failed to issue SQL query', array('query' => $sSql));
}