Bug #73872
closed
Invalid argument supplied for foreach in PageLayoutView
Added by Dmitry Dulepov over 8 years ago.
Updated over 8 years ago.
Category:
Backend User Interface
Description
Getting a warning:
PHP Warning
Core: Error handler (BE): PHP Warning: Invalid argument supplied for foreach() in /home/***/vendor/typo3/cms/typo3/sysext/backend/Classes/View/PageLayoutView.php line 1802
Code in question is:
foreach ($this->contentElementCache[$lP][$colPos] as $record) {
$key = array_search($record['t3_origuid'], $defLanguageCount);
if ($key !== false) {
unset($defLanguageCount[$key]);
}
}
It looks like it should be checked that it is an array before looping.
This is function newLanguageButton, when "Languages" is selected instead of "Columns" in the Page module.
- Status changed from New to Needs Feedback
- Assignee set to Mathias Schreiber
Can you provide a bit more details on where content elements are located?
I'd like to understand the current setup because this case should not happen on a straight core.
When I debugged that cache was empty for colPos=0. The whole $this->contentElementCache was empty. Content uses fluidcontent/flux from fluidtypo3.org
I've set up a page like this:
Two content positions (colpos 0 and 1).
Two languages (english and german).
I now have a CE in language german
in colpos 1
.
No error here.
Are we 100% sure this is a core problem and not related to flux?
I cannot be 100% sure but if it was my code, I would make a simple check in the code:
if (isset($this->contentElementCache[$lP][$colPos])) {
foreach ($this->contentElementCache[$lP][$colPos] as $record) {
$key = array_search($record['t3_origuid'], $defLanguageCount);
if ($key !== false) {
unset($defLanguageCount[$key]);
}
}
}
It never hurts to be careful. Customers complain. I could solve this with Xclass for us but the function is long and I will have to overwrite it completely. I prefer that the code is safe in the core.
There is one element, which is not translated as usual but created separately in the non-default language. This is the only difference with pages where the warning does not appear. May be, this will help.
- Status changed from Needs Feedback to Closed
Sorry, why is it closed without reason?
Oh, I see it is a duplicate of #73670. Thanks!
Also available in: Atom
PDF