Skip to content

CMS pages fail to load if the database contains records with faulty/stale records #33

@pjayme

Description

@pjayme

When a site is loaded with a database snapshot that contains bad records, such as when a record has a ParentID or ParentClass record of null then the CMS throws an "internal server error" when any page is visited within the CMS.

In my particular case this was breaking when Silverstripe's SiteTreeLink had records where both the ParentID and ParentClass were null, throwing the following error:

error-log.WARNING: E_DEPRECATED: strtolower(): Passing null to parameter #1 ($string) of type string is deprecated {"code":8192,"message":"strtolower(): Passing null to parameter #1 ($string) of type string is deprecated","file":"/Users/user/Sites/mysite/vendor/silverstripe/config/src/Collections/MemoryConfigCollection.php","line":118} []

To resolve this issue, I removed these stale records from the database then the CMS started behaving as expected.

One suggestion from a module level would be to add a defensive check on this specific line of code where the $relationClassName must first be checked before referencing it in the Config call, perhaps something like:

$excludeClass = null;
if ($relationClassName) {
    $excludeClass = Config::inst()->get($relationClassName, 'exclude_from_fixture_relationships');
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions