FluidTYPO3 / vhs

TYPO3 extension VHS: Fluid ViewHelpers
https://fluidtypo3.org
Other
189 stars 228 forks source link

PHP Warning: Undefined array key "tt_content:xxxx" #1816

Closed sk-foresite closed 1 year ago

sk-foresite commented 1 year ago

When using the v:content.render ViewHelper I get the following warning:

PHP Warning: Undefined array key "tt_content:3078" in /home/<REDACTED>/www/<REDACTED>/public/typo3conf/ext/vhs/Classes/ViewHelpers/Content/AbstractContentViewHelper.php line 239

Using: TYPO3 11.5.19 PHP 8.1 Using branch development (commit 7752545e2f4e1d651a22bd0b523557eac95ebfff at the time of posting).

It seems to be similiar to issue #1779.

I managed to fix the issues locally by checking that the array key exists:

if (false === empty($parent)) {
    if(array_key_exists($parent, $GLOBALS['TSFE']->recordRegister)) {
        ++$GLOBALS['TSFE']->recordRegister[$parent];
    }
}
$html = $GLOBALS['TSFE']->cObj->cObjGetSingle('RECORDS', $conf);

$GLOBALS['TSFE']->currentRecord = $parent;
if (false === empty($parent)) {
    if(array_key_exists($parent, $GLOBALS['TSFE']->recordRegister)) {
        --$GLOBALS['TSFE']->recordRegister[$parent];
    }
}
lucmuller commented 1 year ago

I have the same behaviour using :

DanYouCan commented 1 year ago

With TYPO3 V11.5.22 / PHP8.1.13 / VHS 6.1.3 got same php error:

Core: Error handler (FE): PHP Warning: Undefined array key "tt_content:xyz" in /public/typo3conf/ext/vhs/Classes/ViewHelpers/Content/AbstractContentViewHelper.php line 239

When I use @sk-foresite's workaround, this error disappears.

hbrz commented 1 year ago

I've got the same error with TYPO3 11.5.21 / PHP 8.1.3 / VHS 6.1.3 I use VHS in my own extension.

For me, it helped to add my plugin to non-cachable actions:

// non-cacheable actions
    array(
        'ControllerName' => 'list, show, create, update',

    )

Otherwise, the "renderRecord()" get called twice and throws this error.

helsner commented 1 year ago

I got this issue as well. the PR seems good to me as far as fixing the PHP exception that blocks the whole page..

NamelessCoder commented 1 year ago

Solved in dev-development.