Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH Update DataObject::delete() docblock #11131

Draft
wants to merge 1 commit into
base: 5.1
Choose a base branch
from

Conversation

emteknetnz
Copy link
Member

@emteknetnz emteknetnz commented Feb 8, 2024

Issue silverstripe/silverstripe-linkfield#213

I believe this is accurate, though please double check with a quick manual test before merging

Copy link
Member

@GuySartorelli GuySartorelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels more like the fact it's not doing this is a bug that should probably be fixed instead.

@emteknetnz
Copy link
Member Author

Possibly is, though I'm not sure. Versioned::doArchive() will do stuff in a nice orderly fashion such as managing changesets and unpublishing live version first, creating a nice history of deleted versions, etc

delete() is kind of crude and won't do any of that. If we changed delete() to also remove from the live stage then we now have 2x ways to remove things from the live stage - delete() and doArchive(). In my mind it's much better to only have a single way to do this, in this case it would be doArchive()

Also worth nothing that Versioned::deleteFromStage() has this:

    public function deleteFromStage($stage)
    {
       // ...
        static::withVersionedMode(function () use ($stage, $owner) {
            Versioned::set_stage($stage);
            $clone = clone $owner;
            $clone->delete();
        });

i.e. it's assuming that it's only going to delete() from a single stage, so if we changed delete() to delete from both stages then this method now has undesidered side effects. There may be well plenty more like this in the codebase.

So I think we should stick with this PR and just update the docblock

@GuySartorelli
Copy link
Member

I would agree, except that both this PHPDoc and the official docs have been telling people they can just call delete() and it'll correctly archive the record.

At the very very least we need to update those docs and call out (probably in the changelog) that "hey you've been archiving records wrong because we told you to, sorry!"

This is probably a decision that needs to go through refinement at least though, if not an architecture discussion.

@emteknetnz
Copy link
Member Author

emteknetnz commented Feb 12, 2024

I've spun off a new issue - I'll remove this PR from the original issue and attach it to the new one

Note the other PR on the original issue is still required as it also updates the owner

@GuySartorelli
Copy link
Member

Setting to draft pending discussion on the new issue

@GuySartorelli GuySartorelli marked this pull request as draft February 12, 2024 01:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants