Issue Bug Closed

#98189SQL-Error with empty row in versionOL()

Alexander Schnitzler 08/23/22, 12:00 updated 07/09/24, 12:46

Description

Hi,

after years, I tried workspaces again and I encountered the following issue:

SELECT FROM `pages` WHERE (`t3ver_oid` = ?) AND (`t3ver_wsid` = ?) AND (`pages`.`deleted` = 0) LIMIT 1' with params [0, 2]

The query is invalid due to the missing queried rows. This happens if
@\TYPO3\CMS\Core\Domain\Repository\PageRepository::versionOL()@

is called with empty $row and the following conditions doesn’t guard the following logic enough:

if ($this->versioningWorkspaceId > 0 && is_array($row))

In my case it happens due to the following code in AbstractMenuContentObject.php:

if ($row['l10n_parent'] > 0 && !isset($row['_PAGES_OVERLAY'])) {
    $row = $this->sys_page->getPage($row['l10n_parent'], true);
}
$tsfe->sys_page->versionOL('pages', $row, true);

getPage() returns the empty array which is then passed along to versionOL().

I currently fixed it by extending the guard clause to also check for a non empty array:

if ($this->versioningWorkspaceId > 0 && is_array($row) && $row !== [])

Not sure though if this is a suitable long term solution.

Reviews 3