Skip to content

Commit

Permalink
[BUGFIX] Pass original DBALException along with SqlErrorException
Browse files Browse the repository at this point in the history
When a
TYPO3\CMS\Extbase\Persistence\Generic\Storage\Exception\SqlErrorException
is thrown, pass the previous exception as 3rd parameter to the
constructor, to get the real reason for the exception.

Resolves: #87852
Releases: master, 9.5, 8.7
Change-Id: I20d711c0038b51a1d0c12d9a975d8c0da1f510f4
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/59960
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
  • Loading branch information
christianfutterlieb authored and andreaskienast committed Aug 5, 2019
1 parent 8d49a7d commit 62a78be
Showing 1 changed file with 12 additions and 12 deletions.
Expand Up @@ -148,7 +148,7 @@ public function addRow($tableName, array $fieldValues, $isRelation = false)

$connection->insert($tableName, $fieldValues, $types);
} catch (DBALException $e) {
throw new SqlErrorException($e->getPrevious()->getMessage(), 1470230766);
throw new SqlErrorException($e->getPrevious()->getMessage(), 1470230766, $e);
}

$uid = 0;
Expand Down Expand Up @@ -194,7 +194,7 @@ public function updateRow($tableName, array $fieldValues, $isRelation = false)

$connection->update($tableName, $fieldValues, ['uid' => $uid], $types);
} catch (DBALException $e) {
throw new SqlErrorException($e->getPrevious()->getMessage(), 1470230767);
throw new SqlErrorException($e->getPrevious()->getMessage(), 1470230767, $e);
}

if (!$isRelation) {
Expand Down Expand Up @@ -240,7 +240,7 @@ public function updateRelationTableRow($tableName, array $fieldValues)
try {
$this->connectionPool->getConnectionForTable($tableName)->update($tableName, $fieldValues, $where);
} catch (DBALException $e) {
throw new SqlErrorException($e->getPrevious()->getMessage(), 1470230768);
throw new SqlErrorException($e->getPrevious()->getMessage(), 1470230768, $e);
}

// always returns true
Expand All @@ -261,7 +261,7 @@ public function removeRow($tableName, array $where, $isRelation = false)
try {
$this->connectionPool->getConnectionForTable($tableName)->delete($tableName, $where);
} catch (DBALException $e) {
throw new SqlErrorException($e->getPrevious()->getMessage(), 1470230769);
throw new SqlErrorException($e->getPrevious()->getMessage(), 1470230769, $e);
}

if (!$isRelation && isset($where['uid'])) {
Expand Down Expand Up @@ -300,7 +300,7 @@ public function getMaxValueFromTable($tableName, array $where, $columnName)

$result = $queryBuilder->execute()->fetchColumn(0);
} catch (DBALException $e) {
throw new SqlErrorException($e->getPrevious()->getMessage(), 1470230770);
throw new SqlErrorException($e->getPrevious()->getMessage(), 1470230770, $e);
}
return $result;
}
Expand Down Expand Up @@ -330,7 +330,7 @@ public function getRowByIdentifier($tableName, array $where)

$row = $queryBuilder->execute()->fetch();
} catch (DBALException $e) {
throw new SqlErrorException($e->getPrevious()->getMessage(), 1470230771);
throw new SqlErrorException($e->getPrevious()->getMessage(), 1470230771, $e);
}
return $row ?: false;
}
Expand Down Expand Up @@ -372,7 +372,7 @@ public function getObjectDataByQuery(QueryInterface $query)
try {
$rows = $queryBuilder->execute()->fetchAll();
} catch (DBALException $e) {
throw new SqlErrorException($e->getPrevious()->getMessage(), 1472074485);
throw new SqlErrorException($e->getPrevious()->getMessage(), 1472074485, $e);
}
}

Expand Down Expand Up @@ -403,14 +403,14 @@ protected function getObjectDataByRawQuery(Qom\Statement $statement)
try {
$result = $realStatement->execute();
} catch (DBALException $e) {
throw new SqlErrorException($e->getPrevious()->getMessage(), 1472064721);
throw new SqlErrorException($e->getPrevious()->getMessage(), 1472064721, $e);
}
$rows = $result->fetchAll();
} elseif ($realStatement instanceof \Doctrine\DBAL\Statement) {
try {
$realStatement->execute($parameters);
} catch (DBALException $e) {
throw new SqlErrorException($e->getPrevious()->getMessage(), 1481281404);
throw new SqlErrorException($e->getPrevious()->getMessage(), 1481281404, $e);
}
$rows = $realStatement->fetchAll();
} else {
Expand All @@ -421,7 +421,7 @@ protected function getObjectDataByRawQuery(Qom\Statement $statement)
$connection = $this->connectionPool->getConnectionByName(ConnectionPool::DEFAULT_CONNECTION_NAME);
$statement = $connection->executeQuery($realStatement, $parameters);
} catch (DBALException $e) {
throw new SqlErrorException($e->getPrevious()->getMessage(), 1472064775);
throw new SqlErrorException($e->getPrevious()->getMessage(), 1472064775, $e);
}

$rows = $statement->fetchAll();
Expand Down Expand Up @@ -470,7 +470,7 @@ public function getObjectCountByQuery(QueryInterface $query)
try {
$count = $queryBuilder->execute()->fetchColumn(0);
} catch (DBALException $e) {
throw new SqlErrorException($e->getPrevious()->getMessage(), 1472074379);
throw new SqlErrorException($e->getPrevious()->getMessage(), 1472074379, $e);
}
if ($query->getOffset()) {
$count -= $query->getOffset();
Expand Down Expand Up @@ -526,7 +526,7 @@ public function getUidOfAlreadyPersistedValueObject(AbstractValueObject $object)
}
return false;
} catch (DBALException $e) {
throw new SqlErrorException($e->getPrevious()->getMessage(), 1470231748);
throw new SqlErrorException($e->getPrevious()->getMessage(), 1470231748, $e);
}
}

Expand Down

0 comments on commit 62a78be

Please sign in to comment.