Closed (fixed)
Project:
Drupal core
Version:
10.1.x-dev
Component:
system.module
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
21 May 2020 at 14:27 UTC
Updated:
3 Mar 2023 at 16:49 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
markdorisonComment #3
codersukanta commentedSuccessfully applied patch #1. it looks good to me.
This seems to be a good idea.
For me it's RTBC +1.
Comment #4
walangitan commentedThere's a typo in 3138595-1.patch on the deprecation notice in PhpStorageInterface.php on comment #2. Patch to follow.
Comment #5
walangitan commentedComment #6
ankitsingh0188Hi,
Patch applied successfully #5
Looks good to me. Good to move it to RTBC.
Comment #7
xjmThanks for working on this. More consistent spelling in APIs will mean fewer accidental bugs.
The old implementations should also
@trigger_error()the deprecation, and have a legacy test of the expected deprecation.This should have an @see to a change record. It's also listing the wrong thing -- it should say
PhpStorageInterface. Edit: But actually, see the next point.Adding a new method to an interface is a BC break, because it changes the interface contract. We can add new methods to an interface if there's a 1:1 relationship with an abstract base class that implements the methods; then, the base class can provide the new method implementation. Reference: https://www.drupal.org/core/d8-bc-policy#interfaces
Unfortunately, we don't seem to have that here.
So, I think we need to probably drop the new method from the interface. We might be able to create an additional interface as a BC layer that gets merged into the current interface in D10. Edit: The deprecation messages / documentation would need to explain all that; otherwise we might not complete it correctly in D10.
Comment #8
kunalgautam commentedComment #9
kunalgautam commentedUpdated patch.
Comment #10
kunalgautam commentedThere are some "writeable" text and "is_writeable" function in the vendor folder.
Comment #11
kunalgautam commentedComment #12
atul4drupal commentedRegarding #9:
Thanks for taking this forward, however the patch at #9 does not addresses the concerns pointed at #7.
Resetting for needs work.
Comment #13
ramya balasubramanian commentedComment #14
ramya balasubramanian commentedI am unassigning this ticket as I have another ticket on my plate.
Comment #15
Kumar Kundan commentedComment #16
Kumar Kundan commentedComment #17
Kumar Kundan commentedComment #18
Kumar Kundan commentedComment #19
atul4drupal commentedThanks Kumar Kundan, #17 is a good start to address the BC concern, just few improvements over what is in #17:
1) Its better to implement the 'PhpStorageInterface' interface in the abstract class itself and have the abstract class only been implemented in the class actually defining the functions body.
2) deprecation message needs improvement for @trigger_error:
some thing like -
%thing% is deprecated in %in-version% and will be VERB ADVERB %removal-version%. %extra-info%. See %cr-link%
(make this consistent where ever used)
3) +++ b/core/lib/Drupal/Component/PhpStorage/PhpStorageInterface.php
+ * @deprecated in drupal:9.1.0 and is removed from drupal:10.0.0.
change with : + @deprecated in Drupal:9.0.0 and will be removed "from / before" Drupal:10.0.0.
(make this consistent where ever used)
4) +++ b/core/lib/Drupal/Component/PhpStorage/PhpStorageInterface.php
"public function writeable();" is removed from the interface
and added the new function + public function writable();
writable function I see is placed in abstract class which is good however the original writeable() function must remain in the interface else it will break the BC.
The interface must not change at all.
Looks like a long patch to review... will share more findings if found :)
Comment #20
Kumar Kundan commentedComment #21
Kumar Kundan commentedComment #22
Kumar Kundan commentedComment #23
Kumar Kundan commentedComment #24
ankitsingh0188Regarding #21 patch looks good, just a small suggestion/change.
Interface
PhpStorageInterfacealready implemented by abstract class PhpStorageBase. If you are extending the abstract class PhpStorageBase, then there's no need to implement the PhpStorageInterface again.+++ b/core/lib/Drupal/Component/PhpStorage/FileStorage.phpclass FileStorage extends PhpStorageBase implements PhpStorageInterface must be class FileStorage extends PhpStorageBase
+++ b/core/lib/Drupal/Component/PhpStorage/FileReadOnlyStorage.phpclass FileReadOnlyStorage extends PhpStorageBase implements PhpStorageInterface must be class FileReadOnlyStorage extends PhpStorageBase
Comment #25
Kumar Kundan commentedComment #26
Kumar Kundan commentedComment #27
Kumar Kundan commentedComment #28
atul4drupal commentedThanks Kumar Kundan for working on this, #26 looks almost ready just a small change:
Comment #29
mrinalini9 commentedComment #30
mrinalini9 commentedDone changes as mentioned in #28, please review.
Comment #31
atul4drupal commentedRegarding #30
Thanks for the patch but seems you removed spaces against all the lines within the class, it only is to be removed (only 2 spaces) from the line containing function signature.
Comment #32
ankitsingh0188I am working on it.
Comment #33
ankitsingh0188Comment #34
ankitsingh0188Comment #35
daffie commentedAll the points of @xjm from comment #7 are still open.
There are still coding standard messages for the latest patch (see: https://www.drupal.org/pift-ci-job/1729166).
I think we should be using #2972224: Add .cspell.json to automate spellchecking in Drupal core, now that it has landed.
Comment #36
himanshu_sindhwani commentedComment #37
himanshu_sindhwani commentedCorrecting the coding standard errors from drupal CI.
Interdiff:
Comment #38
ankitsingh0188@himanshu_sindhwani
When you post an updated patch, please also attach an interdiff file. There are instructions here: Creating an interdiff. Personally, I recommend using the interdiff utility. I think there is less room for making mistakes.
Comment #39
Kumar Kundan commentedHi @daffie,
As per #7 comment, we covered all the possible points.
For
#7.1:- We used @trigger_error() for showing the deprecation message.
#7.2:- We used @see for referencing this issue.
#7.3:- We created a new abstract class & used for Backward compatibility.
Pls, let us know if we missed any point/cases.
Thanks
Comment #40
alexpottI'm not sure about adding this class. I guess we're adding this because we don't want to change the interface to add writable(). But then we have to support this unnecessary base class til at least Drupal 11 and have to coordinate removing it. If we're going to do this we might as when add a new interface that adds the new method. In Drupal 10 we move the writable method to PhpStorageInterface and deprecate the bridging interface. That way everything stays on interfaces and we don't end up with unnecessary class hierarchy. I think the docs for the bridging interface should tell people to not typehint on it.
Another thing that is quite amusing is that the ->writeable() method is not used in any runtime. So is it even necessary? The last runtime usage was in #2497243: Replace Symfony container with a Drupal one, stored in cache and there are no searchable contrib usages... http://grep.xnddx.ru/search?text=-%3Ewriteable%28%29&filename=
Comment #41
Kumar Kundan commentedThanks to @alexpott, for reviewing this issue.
There are two points of view.
1. Either we follow the BC &
abstract class PhpStorageBase implements PhpStorageInterface {convert the abstarct class to interface.2. Or we directlly make changes in
PhpStorageInterfaceinterface.Note:- I believe the 2nd point will be better.
@xjm & @alexpott please suggest the approach.
Comment #42
alexpott@Kumar Kundan note that #40 points out that another option is to deprecate the writeable() method and not replace it we have no use-case in core and nothing in contrib. For me that's the preferred way forward.
Comment #43
jungleI would postpone this on #2898947: Change "writeable" to "writable" in documentation, some changes are out of scope here or in the scope of that one.
Comment #44
jungleComment #45
jungleMarked #3155135: Change "writeable" to "writable" ( Replace method names ) as duplicate, please credit @rajandro and @matts213 if applicable.
And the blocker is in.
Comment #46
junglePer #42 if I understood it well. Deprecated
writeable()directly, no replacement. But changing the method name in tests is fine, So changed.Comment #47
jungleFYI, this is in the scope of #3155400: Change $requirements["$file file writeable"] to $requirements["$file file writable"], not here.
Comment #48
jungleSelf-review, this should be the link of CR
Comment #49
jungleCR added, Updating URL.
Comment #50
jungleAnother self-review, over 80 chars.
Comment #51
jungleAddressing #50
Comment #57
smustgrave commentedThis issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request as a guide.
@expectedDeprecation appears to no longer be used in Drupal core so tags for test to replace though.
Change record would have to be updated for deprecated in 10.1 and removed in 11
Thanks
Comment #58
markdorisonUpdated references to deprecation version and updated the change record.
Does this need to be removed or replaced with something else?
Comment #59
smustgrave commentedProbably their own tests
Use the expectDeprecation() method instead. See https://www.drupal.org/node/3176667
Comment #60
_utsavsharma commentedUpdated the @expectedDeprecation with expectDeprecation().
Comment #61
ankitsingh0188Comment #62
nayana_mvr commentedVerified the patch #60 on Drupal version 10.1.x. The patch applied cleanly and I have added the after patch screenshots of both files for reference.
Comment #63
smustgrave commentedThat wasn't the correct fix. See change record
Comment #64
jungleComment #65
jungleComment #66
smustgrave commentedThanks @jungle!
Comment #67
xjmThese deprecation messages would appear to refer to a global procedural
writeable()function. However, they are actually aboutDrupal\Component\PhpStorage\PhpStorageInterface::writeable().Comment #68
xjmThe change record also doesn't explain what the code should do instead if for some reason some code happens to use this method.
Comment #69
xjmPlus, the current scope (of entirely deprecating the method without any replacement) seems much broader than just changing the spelling to not have the silent "e", so we should update it with how we came to this solution of just entirely removing the whole interface method.
Comment #70
jungleAddressing @xjm's review. Added the new method ::writable() as the replacement of ::writeable().
Comment #71
jungleBoth IS and CR were updated.
Comment #72
smustgrave commentedIS and CR look better now.
Comment #73
jungleThanks, @smustgrave
Note: writable() added to the interface is a BC break. Not sure if it's allowed.
Comment #74
catchThe extra method is OK under the 1-1 exception for interface changes https://www.drupal.org/about/core/policies/core-change-policies/bc-policy
Committed 09a5ff9 and pushed to 10.1.x. Thanks!
Comment #76
catchComment #77
jungle#74 thanks!
BTW, just published the CR.
Comment #79
xjmI think there was a misunderstanding here. In #68 and #69 I wasn't saying that the new approach (of deprecating the methods with no replacement) was wrong; I was just indicating that the IS and CR needed to be updated accordingly.
#40 and #42 make a case for deprecating the method with no replacement because as of those comments it was not used in core or contrib. That's fine, so long as we update the issue title, issue summary, and change record to justify this and to explain to someone who might have for whatever reason used this in custom code whatever it is they should do instead.
Discussed with @catch and we agreed on a revert. Thanks!
Comment #80
xjmComment #81
catchJust doing the title for now.
Comment #82
jungleSorry for the misunderstanding.
Corrected the title, it's
::writeable(), not::isWriteableIS updated, CR updated.
Comment #83
smustgrave commentedI missed that too. Think it should be good now though.
Comment #85
longwaveCommitted to 10.1.x, thanks!