silverstripe / silverstripe-versioned-admin

Provides admin UIs for versioned DataObjects in Silverstripe CMS.
BSD 3-Clause "New" or "Revised" License
9 stars 28 forks source link

Obsolete records break the Archives Admin #350

Closed elliot-sawyer closed 1 month ago

elliot-sawyer commented 2 months ago

Module version(s) affected

2.2.0

Description

If any obsolete class records are present in the Archives Admin, it fails with the following error: Uncaught BadMethodCallException: Object->__call(): the method 'getLastEdited' does not exist on 'SilverStripe\ORM\DataObject'

This is because non-existent classes default to DataObject, which does not have an actual LastEdited database column. Commenting out this line sort of* resolves the issue: it allows the Gridfield to load, but any pages with a broken/obsolete record will throw a 500 error

How to reproduce

Not 100% sure how to reproduce, but:

Possible Solution

Adding this method to DataObject.php via an Extension makes the issue go away:

    public function getLastEdited()
    {
        return $this->owner->dbObject('LastEdited') ?? '';
    }

Additional Context

No response

Validations

GuySartorelli commented 2 months ago

I can't reproduce this - following those instructions, the page shows up fine in archive admin, and its page type is displayed as "Page" - i.e. it falls back to Page, not to DataObject.

elliot-sawyer commented 2 months ago

The records in question used to be Mailchimp newsletter pages, but the module was removed at some point. Perhaps it was unpublished after the module was removed.

elliot-sawyer commented 2 months ago

Not hugely urgent since the posted workaround works for us, I thought I'd post it here to share with anyone else who hits the issue :+1:

GuySartorelli commented 2 months ago

Tried archiving after deleting the custom page class and dev/build but got the same result.

If someone can find a way to reproduce this that'd be great - if not, it will likely be closed at some stage in the future.

GuySartorelli commented 1 month ago

Closing as there are no new reproduction steps. If someone can reproduce, feel free to @ me with more details and I'll look at it again.