Skip to content

Warning on /admin/archive/DNADesign-Elemental-Models-BaseElement (Blocks tab) #314

@elliot-sawyer

Description

@elliot-sawyer

Latest CMS Recipe 4.13.0:

[Warning] foreach() argument must be of type array|object, null given
GET /admin/archive/DNADesign-Elemental-Models-BaseElement

Line 3922 in /var/www/html/vendor/silverstripe/framework/src/ORM/DataObject.php

Somehow I have BaseElement.summary_fields set to null, which is weird given there's a private static $summary_fields value set on that class that isn't null. While I am unsure what causes it, it may be related to an obsolete ClassName that remains in the database. Via debugging, I found one solution is to adjust the DataObject::summaryFields() method to force an array:

Changing
$rawFields = $this->config()->get('summary_fields');
to this:
$rawFields = $this->config()->get('summary_fields') ?? [];

Another option, if PHP support is a concern, is to check if the array is falsey:

        $rawFields = $this->config()->get('summary_fields');

        // Merge associative / numeric keys
        $fields = [];
        if(!$rawFields) {
            return $fields;
        }

I reached out to @GuySartorelli on Slack and he said this is unlikely to be accepted without an identifiable cause, so I'm going to post the issue here in case anyone else comes across it.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions