bednee / cooluri

GIT repository for TYPO3 extension CoolUri
7 stars 12 forks source link

Core: Error handler (FE): PHP Warning: array_merge(): Argument #1 is not an array in /typo3conf/ext/cooluri/Classes/Integration/CoolUri.php line 558 #72

Closed jpmschuler closed 7 years ago

jpmschuler commented 7 years ago

The error ame up in typo3 protocol as an error after switch to 7LTS i think using 1.1.3. Still present in 1.1.4:

Core: Error handler (FE): PHP Warning: array_merge(): Argument #1 is not an array 
in /typo3conf/ext/cooluri/Classes/Integration/CoolUri.php line 558

It's about the array_merge-line in the snipped below. As a solution I'd suggest moving the if (!$page) break; before the if ($langId) which shouldn't be a problem at all, as $page should have at least a uid, and the lang overlay should just add/override stuff und thus $page should be empty afterwards if it was set before.

$q  = $db->exec_SELECTquery('*', 'pages', 'uid=' . $id . $enable);
$page = $db->sql_fetch_assoc($q);

$count = self::getTemplateCount($id);

if ($count['num'] > 0 || $page['is_siteroot'] == 1) {
    return $pagepath;
}

if ($langId) {
    $q = $db->exec_SELECTquery('*', 'pages_language_overlay', 'pid=' . $id . ' AND sys_language_uid=' . $langId . $enable);
    $lo = $db->sql_fetch_assoc($q);
    if ($lo) {
        unset($lo['uid']);
        unset($lo['pid']);
        $page = array_merge($page, $lo);
    }
}
if (!$page) break;

Could create a simple pull request, but wondered 2 things:

  1. why should the page object be empty at all - that would mean it's a deleted page, why should this be triggered at all as the function? (function getPageTitleBE and getPageTitle)
  2. does nobody else have this error in their logs? is it perhaps a strange config option on my end?
bednee commented 7 years ago

Looking at the code, the check "if (!$page) break;" should go above the overlay piece, that would make sense. I guess this can happen when the pagepath goes above the root, which would happen if you didn't have a root template or page marked as siteroot.

bednee commented 7 years ago

Fixed (https://github.com/bednee/cooluri/commit/cc813e9e1e3fa37cfbbdb531edbb69835a55f8d5)