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
| Comment | File | Size | Author |
|---|
Issue fork drupal-3282744
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:
- 3282744-deprecate
changes, plain diff MR !10878
- 3282744-saveddeleted-is-not
compare
Comments
Comment #2
tr commentedComment #3
ghost of drupal pastSomething 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
definewas changed toconstthe 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.
Comment #4
andypostComment #5
andypostComment #6
tr commentedThis 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)orfunction 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.
Comment #7
tr commentedRegarding 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.
Comment #8
ghost of drupal pastWell then let's try. A decision needs to be made -- and that decision belongs to the core maintainers anyways.
Comment #9
ghost of drupal pastSorry, that was hasty.
http://grep.xnddx.ru/node/32504394#line-700
http://grep.xnddx.ru/node/32660644#line-211
http://grep.xnddx.ru/node/32665004#line-649
it's being used :(
Comment #10
geek-merlinFrom 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.
Comment #11
danielvezaChecked 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
Comment #12
geek-merlinNot exactly. We have to deprecate it (by a CR) and to remove it in D11.
Comment #14
tr commentedI 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.
Comment #15
smustgrave commentedBelieve number #12 still stands. We would have to officially deprecate it in 11.2 and remove in 12 to be safe.
Comment #16
tr commentedWhat 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?
Comment #17
smustgrave commentedIt actually has to be deprecated in code. Contrib or custom modules may be using orb
Comment #18
tr commented#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.
Comment #20
smustgrave commentedThink something like that.
Comment #21
smustgrave commentedUnfortunately I can't mark it now.
Comment #23
nicxvan commentedYep 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.
Comment #24
catch@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.
Comment #25
tr commented"@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.
Comment #26
catch@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.
Comment #28
catchCommitted/pushed to 11.x, thanks!
Comment #30
tr commented@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.
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.
Comment #32
nicxvan commented