Problem/Motivation
API page: https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Form%21Fo...
For the following methods:
- setStorage
- getStorage
- get
- set
- has
Change doc comments from
"Sets a value to an arbitrary property."
to a more descriptive comments, and say that it sets the form state storage.
Add @see references between all of the following methods:
- setStorage
- getStorage
- get
- set
- has
Steps to reproduce
Proposed resolution
Remaining tasks
Update patch
Respond to #34
review
commit
User interface changes
API changes
Data model changes
Release notes snippet
Comment | File | Size | Author |
---|---|---|---|
#50 | 2714753-50.patch | 3.15 KB | ankit_rathore |
| |||
#48 | interdff_31-47.txt | 1.72 KB | ankit_rathore |
#48 | 2714753-47.patch | 4.69 KB | ankit_rathore |
| |||
#45 | interdff_31-45.txt | 2.05 KB | ankit_rathore |
#45 | 2714753-45.patch | 5.09 KB | ankit_rathore |
|
Comments
Comment #2
hershey.k CreditAttribution: hershey.k as a volunteer commentedDoes the applied description add enough clarity?
Comment #4
hershey.k CreditAttribution: hershey.k as a volunteer commentedThe test result failure seems to be unrelated to the patch provided. The patch needs to be re-tested.
Comment #5
jhodgdonThanks! This is a good start, but it still needs some work:
This line goes over 80 characters. The first line of a function doc block needs to be a one-line description of less than 80 chars.
@see goes at the end of a doc block, not in the middle. See https://www.drupal.org/node/1354#order
But in any case, we should not be doing an @see to FormState::getStorage, but rather to FormStateInterface::getStorage().
Also it needs the full namespace.
Also we need an @see on getStorage to this method. And all related methods should also be linked in this way.
Comment #6
snehi CreditAttribution: snehi as a volunteer and at Publicis Sapient for Publicis Sapient commentedDone as said by Jhodgdon.
Comment #7
jhodgdonGood, but not complete... We should have @see references between all of the following methods, I think:
- setStorage
- getStorage
- get
- set
- has
They all work with the storage. We should also update the get() and has() methods in a similar way to what set() has in this patch (to say in the first line that they work with the storage).
But I also think we need to make sure that the terminology is consistent between getStorage(), setStorage(), get(), set(), and has(). Currently, in this patch, set() says "Sets value to an arbitrary property and saves it to the form state storage." What I think it should probably say is more like "Sets a value for a property in the form state storage." ("a value to an arbitrary property" doesn't really make sense to me). And then all the other 4 methods should use that same terminology.
Come to think of it, I am not sure the @param $property description on get(), set(), and has() actually makes much sense either. They are on an interface, but they reference $storage, which is not defined on the interface so doesn't really exist. This should also be fixed, so that it talks about the "form state storage" rather than $storage.
Comment #8
ashishdalviComment #9
ashishdalviComment #11
mradcliffeAdding tag for sprints on Friday. The patch needs work to address the comments above.
Comment #12
Finn Lewis CreditAttribution: Finn Lewis commentedI'm taking a look at this at Drupalcon Dublin
Comment #13
Finn Lewis CreditAttribution: Finn Lewis commentedComment #14
Finn Lewis CreditAttribution: Finn Lewis at Agile Collective commentedHi @jhodgdon,
reviewing your comments on #7, I've uploaded a patch that cross references setStorage, getStorage, get, set, has with @see comments for each . Is this what you meant?
On the following comment:
This should also be fixed, so that it talks about the "form state storage" rather than $storage
I've discussed with one of the sprint mentors, and wanted to check this. setStorage does refer to the $storage array, and getStorage returns this array, so could you clarify why we shouldn't refer to $storage?
Many thanks,
Finn
Comment #15
Finn Lewis CreditAttribution: Finn Lewis at Agile Collective commentedComment #19
dark-o CreditAttribution: dark-o as a volunteer commentedI am now looking at this issue
Comment #20
dark-o CreditAttribution: dark-o as a volunteer commentedPatch that Finn provided works OK, comments are rectified as requested. Setting this issue to "review" to see if it will pass tests.
Comment #21
dark-o CreditAttribution: dark-o as a volunteer commentedUpdated the description of the issue to reflect all the changes as advised in the comment #7
Removed "Needs issue summary update" tag
Comment #22
dark-o CreditAttribution: dark-o as a volunteer commentedHiding patches #6 and #2 as patch #14 includes the code of the former two patches
Comment #23
dark-o CreditAttribution: dark-o as a volunteer commentedUnassigning from me as I have been explained by my mentor that we should use comments rather that assigning issue to us. I am still working on this issue
Comment #24
dark-o CreditAttribution: dark-o as a volunteer commentedTest have now passed for both php 5 and 7 on 8.6.x branch
Comment #25
dark-o CreditAttribution: dark-o as a volunteer commentedsetting to "Reviewed & tested by the community"
Comment #26
eojthebraveHey @dark-o thanks for working on this.
+++ b/core/lib/Drupal/Core/Form/FormStateInterface.php
@@ -173,11 +178,16 @@ public function setStorage(array $storage);
+ * Gets a value for a property in the form state storage.
I think "Gets the value" reads better than "Gets a value" (same for "Sets the value") but that might also just be overly nit-picky so fine by me if you don't agree. Just thought I would point it out.
I think we should also update the docblock for
\Drupal\Core\Form\FormState::$storage
as well. It currently reads:But, this isn't really accurate anymore. As the rest of the changes in this issue show we now have get/set/has methods that are part of the API and work exclusively with this variable.
Comment #27
neerajsinghComment #28
neerajsinghsuggestion on
looks good to me, hence re-rolled the patch from #14.
Comment #29
neerajsinghComment #30
neerajsinghMy bad, I just updated for 'Gets' and missed out the 'Sets', will update the patch and re-roll the same.
Comment #31
neerajsinghComment #32
mradcliffeIf anyone wants to review this issue we should make sure that the @neerajsingh's patch in #31 addresses @eojthebrave's comments and update the issue summary to indicate the proposed resolution of reviewed patch as well as any info. that a core committer might need to know while evaluating the issue.
Comment #33
benjifisherComment #34
eojthebraveI think we still need to get the text for
updated. This text for example, is no longer true: "This is not a special key, and no specific support is provided for it in the Form API."
And then there's a bunch of maybe useful, maybe not, details about making keys unique. I would argue this could probably be removed since I believe just using these methods, and $storage, is the recommended best-practice now. But, I don't know that for sure. :/
I think updating the text to something like:
Storage for application specific information and communication between the submit, validation, and form builder functions, especially in a multi-step-style form. This data should be accessed using the related getter/setter methods.
And then @see those.
I'm around at the Sprint in Nashville if anyone is working on this today.
Comment #44
quietone CreditAttribution: quietone at PreviousNext commentedReviewed at a documentation triage meeting.
The changes in the patch are still valid but it needs a reroll. The issue summary is out of date,. Adding tags. This is suitable for a novice, leaving that tag.
Comment #45
ankit_rathore CreditAttribution: ankit_rathore at OpenSense Labs for DrupalFit commentedRe-rolled patch #31 against 10.1.x-dev
Please review it.
Comment #46
joachim CreditAttribution: joachim commentedThe docs changes look good, but this patch has los of unrelated changes - lots of code changes and this docs change:
These need to be removed.
Comment #47
ankit_rathore CreditAttribution: ankit_rathore at OpenSense Labs for DrupalFit commentedignore this comment
Comment #48
ankit_rathore CreditAttribution: ankit_rathore at OpenSense Labs for DrupalFit commentedI have considered the above suggestions and incorporated the changes in this patch.
Comment #49
joachim CreditAttribution: joachim commentedThere are still all these code changes.
Comment #50
ankit_rathore CreditAttribution: ankit_rathore at OpenSense Labs for DrupalFit commentedThose were changes suggested by the code snipper uploading another patch by removing those changes.
Comment #51
joachim CreditAttribution: joachim at Factorial GmbH commentedThanks!
LGTM.
Comment #52
catchCommitted/pushed to 10.1.x, thanks!