[BUGFIX] Failure in AbstractRepository::findByUid on deleted record
authorOliver Hader <oliver@typo3.org>
Thu, 1 Nov 2012 15:16:30 +0000 (16:16 +0100)
committerOliver Hader <oliver.hader@typo3.org>
Fri, 2 Nov 2012 20:24:35 +0000 (21:24 +0100)
Resource\AbstractRepository::findByUid fails if the record to
be fetched has been deleted or simply does not exist. The
condition whether something was fetched from database is wrong.

count(FALSE) is TRUE, thus it needs to be ensure that there is
a non-empty array.

Change-Id: I9fbdb2ed79ceef9ed0782eeed3db15af73636731
Releases: 6.0
Fixes: #42593
Reviewed-on: http://review.typo3.org/16102
Reviewed-by: Helmut Hummel
Tested-by: Helmut Hummel
Reviewed-by: Oliver Hader
Tested-by: Oliver Hader
typo3/sysext/core/Classes/Resource/AbstractRepository.php

index e034955..47d2b96 100644 (file)
@@ -189,7 +189,7 @@ abstract class AbstractRepository implements \TYPO3\CMS\Extbase\Persistence\Repo
                        throw new \InvalidArgumentException('uid has to be integer.', 1316779798);
                }
                $row = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('*', $this->table, 'uid=' . intval($uid) . ' AND deleted=0');
-               if (count($row) === 0) {
+               if (empty($row) || !is_array($row)) {
                        throw new \RuntimeException('Could not find row with uid "' . $uid . '" in table $this->table.', 1314354065);
                }
                return $this->createDomainObject($row);