Issue Bug Closed

#67183Exception in \TYPO3\CMS\Frontend\Aspect\FileMetadataOverlayAspect::languageAndWorkspaceOverlay

André Spindler 05/28/15, 18:52 updated 09/10/15, 09:15

Description

Error is “Passed variable is not an array or object, using empty array instead” in line “$data->exchangeArray($overlayedMetaData);”

I got this exception today in a workspace preview – it is the cause of an type error. check in the line above must be done against FALSE, not NULL.
TYPO3: 6.2.12
PHP: 5.3.10-1ubuntu3.18

Code:

$overlaidMetaData = $data->getArrayCopy();
$this->getTsfe()->sys_page->versionOL('sys_file_metadata', $overlaidMetaData);
$overlaidMetaData = $this->getTsfe()->sys_page->getRecordOverlay(
    'sys_file_metadata',
    $overlaidMetaData,
    $this->getTsfe()->sys_language_content,
    $this->getTsfe()->sys_language_contentOL
);
if ($overlaidMetaData !== NULL) {
    $data->exchangeArray($overlaidMetaData);
}

If there is no overlay, versionOL() sets the given data array ($overlaidMetaData) to FALSE (instead of unset() it).
So FALSE is passed to getRecordOverlay() as second parameter. But if it is not an array (as has no index “uid”), getRecordOverlay() does just nothing (ok, hooks are processed) and returns just this FALSE.
So we run into the exception when FALSE is checked against NULL – and it indeed not NULL and we replace the data of the array object with FALSE…

So it is just a small fix to replace NULL in the check with FALSE.

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.