Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
There's still some docs use hook_field_schema()
but there's no such hook
Comment | File | Size | Author |
---|---|---|---|
#54 | interdiff_52-54.txt | 2.62 KB | himanshu_sindhwani |
#54 | 2673688-54.patch | 2.92 KB | himanshu_sindhwani |
#52 | 2673688-52.patch | 2.92 KB | himanshu_sindhwani |
#46 | interdiff-38-44.txt | 2.64 KB | atul4drupal |
#44 | remove-hook-field-schema-2673688-43.patch | 2.83 KB | atul4drupal |
Comments
Comment #3
markdorisonPatch no longer applies cleanly. Re-rolled against 8.2.x.
Comment #4
markdorisonComment #5
heykarthikwithuPatch applies cleanly and looks good.
Comment #6
andypostrtbc++ for 8.2.x
8.1.x - 5 pleaces
Comment #7
catchShouldn't this link to the fully qualified interface name + method?
Comment #16
kkalashnikov CreditAttribution: kkalashnikov at Srijan | A Material+ Company commentedComment #17
kkalashnikov CreditAttribution: kkalashnikov at Srijan | A Material+ Company commentedUpdated patch tested on D9.
Comment #18
andypostLooks this place still needs better explanation about stored data
Comment #19
kkalashnikov CreditAttribution: kkalashnikov at Srijan | A Material+ Company for Drupal India Association commentedThanks for the quick response @andypost. Here is the updated patch.
Comment #20
andypoststill not sure about it...
It looks this place should mention
propertyDefinitions()
method of the field pluginComment #21
atul4drupal CreditAttribution: atul4drupal at Srijan | A Material+ Company commentedRegarding #20
````
+++ b/core/modules/field/field.api.php
@@ -18,7 +18,7 @@
* In the Field API, each field has a type, which determines what kind of data
* (integer, string, date, etc.) the field can hold, which settings it provides,
* and so on. The data type(s) accepted by a field are defined in
- * hook_field_schema().
+ * hook_schema().
````
I am of the opinion that this place should mention "schema() method", propertyDefinitions() method appears a method for adding/specifying additional attributes for the field item.
In this block the schema method is been referenced with respect to data type(s) which is defined in schema().
Referenced:
core/lib/Drupal/Core/Field/Plugin/Field/FieldType/BooleanItem.php
core/modules/file/src/Plugin/Field/FieldType/FileItem.php
core/lib/Drupal/Core/Field/Plugin/Field/FieldType/UriItem.php
Comment #22
andypostThanks, that's why another couple of eyes helps!
Comment #23
atul4drupal CreditAttribution: atul4drupal at Srijan | A Material+ Company commentedThanks andypost for moving this to RTBC.
I think the wording must change:
- hook_schema()
+ schema() method
Kindly suggest and accordingly we may mark this for needs work?
Thanks.
Comment #24
atul4drupal CreditAttribution: atul4drupal at Srijan | A Material+ Company commentedupdate patch at #19
b/core/modules/field/field.api.php
replace: hook_field_schema()
with: schema() method
Thanks.
Comment #25
saurabh-2k17 CreditAttribution: saurabh-2k17 at Srijan | A Material+ Company for Drupal India Association commentedHi @atul4drupal as per your suggestion i have updated the patch.
Comment #26
saurabh-2k17 CreditAttribution: saurabh-2k17 at Srijan | A Material+ Company for Drupal India Association commentedComment #27
kkalashnikov CreditAttribution: kkalashnikov at Srijan | A Material+ Company commentedComment #28
atul4drupal CreditAttribution: atul4drupal at Srijan | A Material+ Company commentedHi Saurabh_sgh thanks for working on this. The changes look good.
It will however be more helpful if you ensure adding interdiff file.
Comment #29
atul4drupal CreditAttribution: atul4drupal at Srijan | A Material+ Company for Drupal India Association commentedapologies for the mess, I mistakenly have this set to needs work
Comment #30
saurabh-2k17 CreditAttribution: saurabh-2k17 at Srijan | A Material+ Company for Drupal India Association commentedHi @atul4drupal I have added the interdiff.
Comment #31
Bunty Badgujar CreditAttribution: Bunty Badgujar commentedpatch #25 looks good to me also includes suggestion #24. Moving back to RTBC.
Comment #32
xjmThanks for fixing this; good find.
I thinnk we need to specify the interface with the fully qualified namespace for the method in the docs here. Should be just another set of small changes. Thanks!
Comment #33
saurabh-2k17 CreditAttribution: saurabh-2k17 at Srijan | A Material+ Company for Drupal India Association commentedHi @xjm,
I hope this is the final change. I have updated the patch as per your suggestion.
Thanks
Comment #34
priyanka.sahni CreditAttribution: priyanka.sahni at Srijan | A Material+ Company for Drupal India Association commentedComment #35
priyanka.sahni CreditAttribution: priyanka.sahni at Srijan | A Material+ Company for Drupal India Association commentedComment #36
Bunty Badgujar CreditAttribution: Bunty Badgujar commentedMovie again to RTBC as suggestions from #32 added in #33.
Comment #37
xjmThanks @Saurabh_sgh. Two more small things:
There are trailing spaces on these lines that need to be removed.
The first line here is now over 80 characters. It needs to be rewrapped.
Tagging novice since those are small cleanups. Thank you for working on this!
Comment #38
walangitan CreditAttribution: walangitan at Chromatic commentedRemoved trailing spaces and rewrapped the line.
Comment #39
daffie CreditAttribution: daffie commentedThe 2 points of @xjm are addressed.
Back to RTBC.
Comment #40
atul4drupal CreditAttribution: atul4drupal at Srijan | A Material+ Company for Drupal India Association commentedRegarding #7, #32 & #33:
Thanks for working on this & taking this forward, this looks very close.
Still not sure of the statement with respect to "FieldItemInterface".
The statement in :
b/core/modules/field/src/Entity/FieldStorageConfig.php
Here this statement gives an impression as if the method is implemented in "FieldItemInterface" interface itself, wherein it only holds signature of the method.
Likewise at other places:
b/core/modules/field/field.api.php
b/core/lib/Drupal/Core/Field/FieldConfigBase.php
These statements with respect to "FieldItemInterface::schema()", I believe still need some fine improvement so that it implies the interface implementing 'snippetItem' classes schema method, which actually holds the field schema definition and not the interface.
Comment #41
Bunty Badgujar CreditAttribution: Bunty Badgujar commented@atul4drupal,
Interface's comment should describe the abstract purpose of this method/interface. In \Drupal\Core\Field\FieldItemInterface::schema() it describe like
* Returns the schema for the field.
And the concrete comment will talk about the implementation specifics of the method/class in the context of the interface's purpose. which is clearly mentioned in comment "This set of indexes is merged with the "default" indexes specified by the field type in \Drupal\Core\Field\FieldItemInterface::schema() method"
Comment #42
atul4drupal CreditAttribution: atul4drupal at Srijan | A Material+ Company for Drupal India Association commentedRegarding #41,
#41.1 - This I believe is not about what the comment for schema() method in FieldItemInterface reads.
#41.2 - I am only concerned with the sense that current used statement derives. It definitely need fine improvement so that it implies the 'class implementing the interface method', currently it gives sense as if all implementations of schema methods will return same data.
Also if we have to call the schema() method we will call it from the class implementing the interface and not the one mentioned in the interface(if by any means we may do that), this is why I believe the statement needs fine tuning to get the right sense out of it.
for example something in the lines of : indexes specified by field type in the <'class' OR 'snippetItem class'> implementing \Drupal\Core\Field\FieldItemInterface::schema() method
Comment #43
himanshu_sindhwani CreditAttribution: himanshu_sindhwani at Srijan | A Material+ Company for Drupal India Association commentedComment #44
atul4drupal CreditAttribution: atul4drupal at Srijan | A Material+ Company for Drupal India Association commentedupdated patch for review.
Taking cue from https://www.drupal.org/docs/creating-custom-modules/creating-custom-field-types-widgets-and-formatters/overview-creating-a for using "SnippetsItem" keyword to represent the field-type class.
Comment #45
atul4drupal CreditAttribution: atul4drupal at Srijan | A Material+ Company for Drupal India Association commentedReagrding #43 Its my bad .. seems I didn't have the page refreshed before posting the patch.
Comment #46
atul4drupal CreditAttribution: atul4drupal at Srijan | A Material+ Company for Drupal India Association commentedAdding interdiff for #38 & #44
Comment #47
himanshu_sindhwani CreditAttribution: himanshu_sindhwani at Srijan | A Material+ Company for Drupal India Association commentedHi @atul4drupal,
There is no such class SnippetsItem present in the core. So, I don't think it is useful to mention.
Comment #48
atul4drupal CreditAttribution: atul4drupal at Srijan | A Material+ Company for Drupal India Association commentedRegarding #47: Thanks for the review and feedback, seems I haven't clarified myself at #44 comment. SnippetsItem is a generic keyword used to represent "field type" class, and this has been termed so in referenced page at #44, and in current context it makes sense to use generic word to represent the classes implementing schema() method from the \Drupal\Core\Field\FieldItemInterface interface.
For this reason you will not find a class named "SnippetsItem" nor in core neither elsewhere. Suggestion are welcome to improve the statement to derive correct meaning out of it.
Comment #49
atul4drupal CreditAttribution: atul4drupal at Srijan | A Material+ Company for Drupal India Association commentedAnd yes we can think if only using "class" will suffice or shall we make it more obvious by using "SnippetsItem" keyword, this I will leave it to the community at large to decide and accordingly can take call based on feedback from others.
Though personally I am of the opinion to using SnippetsItem keyword (even I had this thought of what will be more appropriate here)
Comment #50
himanshu_sindhwani CreditAttribution: himanshu_sindhwani at Srijan | A Material+ Company for Drupal India Association commentedYes you are correct its a generic word, for me it will make more sense to just write
instead of
which uses a SnippetsItem as in #44.
Similarly at other occurrences.
This key word is never used anywhere to generalize the class. Therefore we should keep it same as we have done earlier.
Comment #51
atul4drupal CreditAttribution: atul4drupal at Srijan | A Material+ Company for Drupal India Association commented#50 Thanks for clarifying your stand.
I am open to have it done either way actually as mentioned in #42, but would suggest waiting for more feedback on this and progress accordingly.
Comment #52
himanshu_sindhwani CreditAttribution: himanshu_sindhwani at Srijan | A Material+ Company for Drupal India Association commentedSubmitting a patch covering points from #50.
Comment #53
atul4drupal CreditAttribution: atul4drupal at Srijan | A Material+ Company for Drupal India Association commented#52 thanks for the patch, I appreciate your effort.
Just a few updates:
1)
b/core/lib/Drupal/Core/Field/FieldConfigBase.php
+ * defined by the "field schema" for the field type, as exposed in a class
+ * class implementing \Drupal\Core\Field\FieldItemInterface::schema() method.
here we have class word mentioned twice... also its better if we use "as exposed in the class" instead of in a class.
2) b/core/modules/field/field.api.php
+ * and so on. The data type(s) accepted by a field are defined in a class
here also change "in a class" with "in the class"
3) core/modules/field/src/Entity/FieldStorageConfig.php
+ * field type in a class implementing
change "in a class" with "in the class"
+ *defined by the field type in a class implementing
change "in a class" with "in the class"
Once done I believe we should be good.
Comment #54
himanshu_sindhwani CreditAttribution: himanshu_sindhwani at Srijan | A Material+ Company for Drupal India Association commentedThanks for your valuable feedback, I have worked on all the points mentioned and here the patch.
Comment #55
atul4drupal CreditAttribution: atul4drupal at Srijan | A Material+ Company for Drupal India Association commented#54 looks clean.
Comment #56
alexpottCommitted and pushed 8d67348e9a to 9.1.x and 0285b30825 to 9.0.x and 9522bf29e0 to 8.9.x. Thanks!
Backported to 8.9.x since hook_field_schema() was removed from Drupal 8 :)
I don't think the comma here is correct so I removed it on commit.