Problem/Motivation

The constant SAVED_DELETED, defined in core/includes/common.inc is not used anywhere in core since Drupal 7. It is not used in Drupal 8 or Drupal 9 or Drupal 10.

Absent a use case for this constant, it should be removed from core.

Steps to reproduce

N/A

Proposed resolution

Deprecate to be removed

Remaining tasks

Review

User interface changes

N/A

Introduced terminology

N/A

API changes

N/A

Data model changes

N/A

Release notes snippet

N/A

CommentFileSizeAuthor
#2 3282744-2-remove-SAVED_DELETED.patch391 bytestr

Issue fork drupal-3282744

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

TR created an issue. See original summary.

tr’s picture

Status: Active » Needs review
StatusFileSize
new391 bytes
ghost of drupal past’s picture

Something this odd needs a little bit of git archeology -- how did that constant came to be, what did it really do?

Well, dear readers, aside from efe0a73b29 when define was changed to const the only commit this line saw is 89ae34de471 from 2005. Not sure why it was prefixed by SAVED_ but it was returned when a vocabulary got deleted. Needless to say, it seems safe to remove it.

However, there are backwards compatibility concerns. Can we even remove constants any more? https://www.drupal.org/about/core/policies/core-change-policies/bc-policy is mum on this.

andypost’s picture

andypost’s picture

tr’s picture

This constant was introduced in Drupal 4.6.0 as a patch for the forum module in #19621: Sensible status messages for forum admin (five digit issue number!). There was no apparent discussion about the new constant.

In Drupal 5 and Drupal 6 and Drupal 7, this constant was only used by the taxonomy module. Forum no longer used it.

In D7 SAVED_DELETED was used only for the core taxonomy module, and only when deleting a taxonomy term or vocabulary in function taxonomy_term_delete($tid) or function taxonomy_vocabulary_delete($vid) - SAVED_DELETED was returned to indicate that fields attached to the deleted term/vocabulary had also been deleted.

There is literally no mention of SAVED_DELETED in the entire D8/D9/D10 codebase except for the "const" declaration.

SAVED_DELETED is one of three "SAVED" constants (SAVED_NEW, SAVED_UPDATED, and SAVED_DELETED) defined in common.inc. These are meant to be used as return codes for EntityInterface::save(), EntityStorageInterface::save(), EntityFormInterface::save(), etc.

But note that all these save() methods are explicitly documented to return just SAVED_NEW or SAVED_UPDATED - there is NO documentation that these will ever or can ever return SAVED_DELETED. Likewise there is no core method/function that actually returns SAVED_DELETED or documents SAVED_DELETED as a possible return value. It is just not used at all in D8/D9/D10.

I also searched the gitlab archives of all Drupal contributed modules at https://git.drupalcode.org/search?group_id=2&page=5&repository_ref=9.5.x... and the only uses I found were Drupal 7 modules - this does not appear in any D8, D9, or D10 contributions.

tr’s picture

Regarding BC,

If this constant was being used in any core or contributed modules at all in D8/D9/D10, then I think it would be reasonable to ask about whether this should be done now or whether it has to be postponed to D11.

But this constant hasn't been used by contrib or core since D7. I don't see any need to delay removal at this point, as this is part of the core API and core NEVER returns this value and never documents that it can be returned.

For D10 we are taking steps to remove procedural code etc. in include files like common.inc, so I think removal of an unused constant SAVED_DELETED fits with the changes that are to be expected to occur in D10.

ghost of drupal past’s picture

Status: Needs review » Reviewed & tested by the community

Well then let's try. A decision needs to be made -- and that decision belongs to the core maintainers anyways.

ghost of drupal past’s picture

Status: Reviewed & tested by the community » Needs review
geek-merlin’s picture

Status: Needs review » Needs work

From https://www.drupal.org/node/2831620, it looks like the way to deprecate a constant is to drop it and add a CR.
I can't think of a way to report constant usage.

So NW for the CR, otherwise RTBC imho.

danielveza’s picture

Status: Needs work » Needs review

Checked the Drupal 10.1 codebase, there are still no references to SAVED_DELETED besides the const declaration itself.

Created a draft CR. https://www.drupal.org/node/3328750

geek-merlin’s picture

Status: Needs review » Needs work

Not exactly. We have to deprecate it (by a CR) and to remove it in D11.

Version: 10.0.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

tr’s picture

Title: SAVED_DELETED is not used in D10, D9, or D8 and should be removed » SAVED_DELETED is not used in D11, D10, D9, or D8 and should be removed
Status: Needs work » Needs review

Not exactly. We have to deprecate it (by a CR) and to remove it in D11.

I don't understand why this was moved back to NW.

The draft CR deprecating the constant was created on 21 Dec 2022 by @danielveza, as requested.
He then moved the issue to NR.

So what needs to be done here to get this constant removed? It is not used by core or contrib in D11, D10, D9, or D8.

smustgrave’s picture

Status: Needs review » Needs work

Believe number #12 still stands. We would have to officially deprecate it in 11.2 and remove in 12 to be safe.

tr’s picture

What does that mean? The CR exists, are you saying it just needs to be published? Then this issue should not be NW because it is ready for a maintainer to publish. If the CR is not sufficient then why? If the CR needs to be changed, what's wrong with it?

My question is still, what needs to be done?

smustgrave’s picture

It actually has to be deprecated in code. Contrib or custom modules may be using orb

tr’s picture

#12 says deprecate by CR. That's why the status was NW.
There is no mention of deprecating in code.
That's why I'm asking.

smustgrave’s picture

Issue summary: View changes

Think something like that.

smustgrave’s picture

Status: Needs work » Needs review
Issue tags: +Needs Review Queue Initiative

Unfortunately I can't mark it now.

smustgrave changed the visibility of the branch 3282744-saveddeleted-is-not to hidden.

nicxvan’s picture

Status: Needs review » Reviewed & tested by the community

Yep that is how to deprecate constants now. I don't think this was defined when the issue was first created which is why using a CR was recommended.

This is good cleanup!

I updated the CR to be more concise.

The history isn't needed in the CR, it's on the issue.

I think I can mark it rtbc since I only changed the CR.

catch’s picture

@TR documentation on how to deprecate constants is here: https://www.drupal.org/about/core/policies/core-change-policies/how-to-d...

MR looks good to me.

tr’s picture

"@TR documentation on how to deprecate constants is here"
Yeah but that was only created in May 2024.
Back in May 2022 when this issue was opened there was NO mechanism for deprecating constants.

What I'm hearing is that there is no good reason why this was put into NW two years ago, but now the solution has to be different because core changed. It shouldn't be this hard to get little things fixed.

catch’s picture

@TR, no when #12 was written, while there was no way to deprecate constants, we would remove constants that were unused by contrib in minor releases (probably), or if not, in a major release - in both cases with a change record since that was the only way to communicate the change.

It looks like @danielveza created the change record the same day, but forgot to come back and update this issue. Then also no-one else noticed or updated this issue in the intervening two years.

Had the issue been re-RTBCed, it could have been committed to either a major or minor release at that point.

During that time, we added better support for deprecating constants (not trivial because it can't be done at runtime, so it had to be added to phpstan), so that we don't break contrib modules relying on them, like the ones that Ghost of Drupal Past found in #9, and this can happen in any minor release now, no need to grep contrib etc.

I've now spent five minutes writing this up which I could have spent committing this issue if #25 hadn't been inaccurate.

  • catch committed f5d1ca72 on 11.x
    Issue #3282744 by tr, smustgrave, ghost of drupal past, geek-merlin,...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 11.x, thanks!

tr’s picture

so that we don't break contrib modules relying on them, like the ones that Ghost of Drupal Past found in #9, and this can happen in any minor release now, no need to grep contrib etc.

@ghost was citing the russian site, which was never up-to-date. But I did my search on gitlib, which *is* up-to-date, and I did that search both before I opened the issue and also gave the link in #6. No active, published contrib was/is using this constant.

Yes, deprecating is a much better way, but that method didn't exist two years ago so I pro-actively searched contrib and presented my results out of an abundance of caution.

I've now spent five minutes writing this up which I could have spent committing this issue if #25 hadn't been inaccurate.

And if the desired fix back then was to change the CR "introduced in" version from 10.1 to 11.0, then that could have been done in 10 seconds two years ago, rather than throwing it into "needs work" with an inaccurate reason why. And then NO-ONE would have had to spend 5 or 10 or 30 minutes more dealing with this.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

nicxvan’s picture