Closed Juanitou closed 6 years ago
Looks like the error is coming from this line specifically: https://github.com/silverstripe/silverstripe-framework/blob/4/src/ORM/ArrayList.php#L694. It could be argued that it’s a framework bug - a call to UnsavedRelationList::filterByCallback()
should probably return an ArrayList
, not attempt to return an UnsavedRelationList
- but I’m more interested in how you’re hitting this error.
If $this->Elements()
is returning an UnsavedRelationList
, I guess that means that either the page doesn’t have an ElementArea
or the page/area are both new records not yet written to the database. Do you know if either of those guesses are correct?
A simple fix would be to amend ElementArea::ElementControllers()
to something like:
$controllers = ArrayList::create();
$elements = $this->Elements();
// Or perhaps if (!$this->isInDB())
if ($elements instanceof UnsavedRelationList) {
return $controllers;
}
$items = $this->Elements()->filterByCallback(function (BaseElement $item) {
// ...
I can't reproduce this error by creating variations of saved pages or elements in the page, but I'm happy to fix it anyway
Fix at #265
Thank you for the quick fix.
If $this->Elements() is returning an UnsavedRelationList, I guess that means that either the page doesn’t have an ElementArea or the page/area are both new records not yet written to the database. Do you know if either of those guesses are correct?
This was not my case. Both page and its elements were saved and published days ago the update.
The following error appears when trying to access the CMS after upgrading this module to 3.0.0-rc1.
Downgrading to 3.0.0-beta3 (or removing elements from the config) prevents the error.
This is a really simple test site.
composer.json: