b13/container

Undefined array key warnings when editing translated tt_content record

Physikbuddha opened this issue · 4 comments

In v12, opening a content element in the backend in a language different than the default language, two PHP warnings are issued:

PHP Warning: Undefined array key "tx_container_parent" in /var/www/html/vendor/b13/container/Classes/Tca/ItemProcFunc.php line 51
PHP Warning: Undefined array key "tx_container_parent" in /var/www/html/vendor/b13/container/Classes/Tca/ItemProcFunc.php line 83

This is caused by BackendUtility::getProcessedValue() calling BackendUtility::getLabelsFromItemsList() with a fake $row parameter in line 1658, only containing uid and pid.

The stacktrace is as follows:

2024-01-22 14_18_24

And the fix would be to add an isset check, before accessing the array key on Line 51 in the file Tca/ItemProcFunc.php:
if (isset($row['tx_container_parent']) && $row['tx_container_parent'] > 0) {
and Line 83:
if (isset($row['tx_container_parent']) && $row['tx_container_parent'] > 0) {

Maybe this is only a symptom fix instead of a source fix, considering that the ItemProcFunc should maybe not be called at all for the language overlay item, that is called inside of the detail view of translations.

Maybe we have always to check if an array key exists under PHP8.
My most unwantted PHP change + my most forgotten ;-)

if (!empty($key) && ...)

should be fixed in 2.3.3 with 2ef3fd1