Support from Acquia helps fund testing for Drupal Acquia logo

Comments

andypost created an issue. See original summary.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

markdorison’s picture

Status: Needs review » Needs work
FileSize
3.16 KB

Patch no longer applies cleanly. Re-rolled against 8.2.x.

markdorison’s picture

Status: Needs work » Needs review
heykarthikwithu’s picture

Status: Needs review » Reviewed & tested by the community

Patch applies cleanly and looks good.

andypost’s picture

rtbc++ for 8.2.x

drupal$ git grep hook_field_schema
core/lib/Drupal/Core/Field/FieldConfigBase.php:127:   * hook_field_schema(). If the number of items exceeds the cardinality of the
core/modules/field/field.api.php:21: * hook_field_schema().
core/modules/field/src/Entity/FieldStorageConfig.php:170:   * field type in hook_field_schema() to determine the actual set of indexes
core/modules/field/src/Entity/FieldStorageConfig.php:175:   * defined by the field type in hook_field_schema(), are allowed.

8.1.x - 5 pleaces

core8# git b
* 8.1.x
core8# git grep hook_field_schema
core/lib/Drupal/Core/Field/FieldConfigBase.php:127:   * hook_field_schema(). If the number of items exceeds the cardinality of the
core/lib/Drupal/Core/Field/FieldStorageDefinitionInterface.php:239:   *   by hook_field_schema():
core/modules/field/field.api.php:21: * hook_field_schema().
core/modules/field/src/Entity/FieldStorageConfig.php:170:   * field type in hook_field_schema() to determine the actual set of indexes
core/modules/field/src/Entity/FieldStorageConfig.php:175:   * defined by the field type in hook_field_schema(), are allowed.
catch’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/field/src/Entity/FieldStorageConfig.php
@@ -167,12 +167,12 @@ class FieldStorageConfig extends ConfigEntityBase implements FieldStorageConfigI
+   * field type in schema() method to determine the actual set of indexes

Shouldn't this link to the fully qualified interface name + method?

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

kkalashnikov’s picture

Assigned: Unassigned » kkalashnikov
kkalashnikov’s picture

Updated patch tested on D9.

andypost’s picture

Status: Needs work » Needs review
+++ b/core/modules/field/field.api.php
@@ -17,8 +17,7 @@
- * and so on. The data type(s) accepted by a field are defined in
- * hook_field_schema().
+ * and so on.

Looks this place still needs better explanation about stored data

kkalashnikov’s picture

Thanks for the quick response @andypost. Here is the updated patch.

andypost’s picture

+++ b/core/modules/field/field.api.php
@@ -18,7 +18,7 @@
  * and so on. The data type(s) accepted by a field are defined in
- * hook_field_schema().
+ * hook_schema().

still not sure about it...

It looks this place should mention propertyDefinitions() method of the field plugin

atul4drupal’s picture

Regarding #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

andypost’s picture

Status: Needs review » Reviewed & tested by the community

Thanks, that's why another couple of eyes helps!

atul4drupal’s picture

Thanks 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.

atul4drupal’s picture

Status: Reviewed & tested by the community » Needs work

update patch at #19

b/core/modules/field/field.api.php

replace: hook_field_schema()

with: schema() method

Thanks.

saurabh-2k17’s picture

Hi @atul4drupal as per your suggestion i have updated the patch.

saurabh-2k17’s picture

Status: Needs work » Needs review
kkalashnikov’s picture

Assigned: kkalashnikov » Unassigned
atul4drupal’s picture

Status: Needs review » Needs work

Hi Saurabh_sgh thanks for working on this. The changes look good.

It will however be more helpful if you ensure adding interdiff file.

atul4drupal’s picture

Status: Needs work » Needs review

apologies for the mess, I mistakenly have this set to needs work

saurabh-2k17’s picture

FileSize
572 bytes

Hi @atul4drupal I have added the interdiff.

Bunty Badgujar’s picture

Status: Needs review » Reviewed & tested by the community

patch #25 looks good to me also includes suggestion #24. Moving back to RTBC.

xjm’s picture

Status: Reviewed & tested by the community » Needs work

Thanks for fixing this; good find.

+++ b/core/lib/Drupal/Core/Field/FieldConfigBase.php
@@ -125,8 +125,8 @@
+   * defined by the "field schema" for the field type, as exposed by schema()

+++ b/core/modules/field/field.api.php
@@ -18,7 +18,7 @@
- * hook_field_schema().
+ * schema() method.

+++ b/core/modules/field/src/Entity/FieldStorageConfig.php
@@ -175,12 +175,12 @@ class FieldStorageConfig extends ConfigEntityBase implements FieldStorageConfigI
-   * field type in hook_field_schema() to determine the actual set of indexes
+   * field type in schema() method to determine the actual set of indexes
...
-   * defined by the field type in hook_field_schema(), are allowed.
+   * defined by the field type in schema() method, are allowed.

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!

saurabh-2k17’s picture

Status: Needs work » Needs review
FileSize
2.72 KB
2.52 KB

Hi @xjm,

I hope this is the final change. I have updated the patch as per your suggestion.

Thanks

priyanka.sahni’s picture

priyanka.sahni’s picture

Assigned: priyanka.sahni » Unassigned
Bunty Badgujar’s picture

Status: Needs review » Reviewed & tested by the community

Movie again to RTBC as suggestions from #32 added in #33.

xjm’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Novice

Thanks @Saurabh_sgh. Two more small things:

  1. +++ b/core/lib/Drupal/Core/Field/FieldConfigBase.php
    @@ -125,8 +125,9 @@
    +   * \Drupal\Core\Field\FieldItemInterface::schema() method of the field. ¶
    
    +++ b/core/modules/field/src/Entity/FieldStorageConfig.php
    @@ -175,12 +175,13 @@ class FieldStorageConfig extends ConfigEntityBase implements FieldStorageConfigI
    +   * field type in \Drupal\Core\Field\FieldItemInterface::schema() method to ¶
    

    There are trailing spaces on these lines that need to be removed.

  2. +++ b/core/modules/field/src/Entity/FieldStorageConfig.php
    @@ -175,12 +175,13 @@ class FieldStorageConfig extends ConfigEntityBase implements FieldStorageConfigI
    +   * defined by the field type in \Drupal\Core\Field\FieldItemInterface::schema()
    +   * method, are allowed.
    

    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!

walangitan’s picture

Status: Needs work » Needs review
FileSize
2.8 KB
1.78 KB

Removed trailing spaces and rewrapped the line.

daffie’s picture

Status: Needs review » Reviewed & tested by the community

The 2 points of @xjm are addressed.
Back to RTBC.

atul4drupal’s picture

Status: Reviewed & tested by the community » Needs work

Regarding #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

This set of indexes is merged with the "default" indexes specified by the field type in \Drupal\Core\Field\FieldItemInterface::schema() method to determine the actual set of indexes that get created.

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.

Bunty Badgujar’s picture

@atul4drupal,

Here this statement gives an impression as if the method is implemented in "FieldItemInterface" interface itself, wherein it only holds signature of the method.

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"

atul4drupal’s picture

Regarding #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

himanshu_sindhwani’s picture

Assigned: Unassigned » himanshu_sindhwani
atul4drupal’s picture

Status: Needs work » Needs review
FileSize
2.83 KB

updated 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.

atul4drupal’s picture

Reagrding #43 Its my bad .. seems I didn't have the page refreshed before posting the patch.

atul4drupal’s picture

FileSize
2.64 KB

Adding interdiff for #38 & #44

himanshu_sindhwani’s picture

Assigned: himanshu_sindhwani » Unassigned

Hi @atul4drupal,

* and so on. The data type(s) accepted by a field are defined in
 * SnippetsItem class implementing

There is no such class SnippetsItem present in the core. So, I don't think it is useful to mention.

atul4drupal’s picture

Regarding #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.

atul4drupal’s picture

And 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)

himanshu_sindhwani’s picture

Yes you are correct its a generic word, for me it will make more sense to just write

 * and so on. The data type(s) accepted by a field are defined in a
 * class implementing \Drupal\Core\Field\FieldItemInterface::schema() method.

instead of

 * and so on. The data type(s) accepted by a field are defined in
 * SnippetsItem class implementing
 * \Drupal\Core\Field\FieldItemInterface::schema() method.

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.

atul4drupal’s picture

#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.

himanshu_sindhwani’s picture

Submitting a patch covering points from #50.

atul4drupal’s picture

Status: Needs review » Needs work

#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.

himanshu_sindhwani’s picture

Status: Needs work » Needs review
FileSize
2.92 KB
2.62 KB

Thanks for your valuable feedback, I have worked on all the points mentioned and here the patch.

atul4drupal’s picture

Status: Needs review » Reviewed & tested by the community

#54 looks clean.

alexpott’s picture

Version: 9.1.x-dev » 8.9.x-dev
Status: Reviewed & tested by the community » Fixed

Committed 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 :)

diff --git a/core/modules/field/src/Entity/FieldStorageConfig.php b/core/modules/field/src/Entity/FieldStorageConfig.php
index 5dc4b3c204..250edd6e8d 100644
--- a/core/modules/field/src/Entity/FieldStorageConfig.php
+++ b/core/modules/field/src/Entity/FieldStorageConfig.php
@@ -176,7 +176,7 @@ class FieldStorageConfig extends ConfigEntityBase implements FieldStorageConfigI
    *
    * This set of indexes is merged with the "default" indexes specified by the
    * field type in the class implementing
-   * \Drupal\Core\Field\FieldItemInterface::schema() method, to determine the
+   * \Drupal\Core\Field\FieldItemInterface::schema() method to determine the
    * actual set of indexes that get created.
    *
    * The indexes are defined using the same definition format as Schema API

I don't think the comma here is correct so I removed it on commit.

  • alexpott committed 8d67348 on 9.1.x
    Issue #2673688 by himanshu_sindhwani, kkalashnikov, atul4drupal,...

  • alexpott committed 0285b30 on 9.0.x
    Issue #2673688 by himanshu_sindhwani, kkalashnikov, atul4drupal,...

  • alexpott committed 9522bf2 on 8.9.x
    Issue #2673688 by himanshu_sindhwani, kkalashnikov, atul4drupal,...

Status: Fixed » Closed (fixed)

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