Comments

berdir’s picture

Issue tags: +Entity Field API

Tagging.

eugene.ilyin’s picture

Assigned: Unassigned » eugene.ilyin

Hello.
DrupalSib team (Russia, Novosibirsk) want to implements this on today code sprint.

eugene.ilyin’s picture

Assigned: eugene.ilyin » Unassigned

Sorry.
We do not have time to solve this problem today. Anybody can take this task.

klausi’s picture

Status: Active » Needs review
StatusFileSize
new4.01 KB

First patch with test case - not much to validate here except for the term name?

Status: Needs review » Needs work

The last submitted patch, term-validation-2002168-4.patch, failed testing.

klausi’s picture

Status: Needs work » Needs review
StatusFileSize
new3.48 KB

OK, converting the parent field to entity reference breaks a lot of things and is confusing, so that should be splitted out to a separate issue.

klausi’s picture

Opened #2048555: Convert term parent to entity reference for the term parent reference conversion.

klausi’s picture

OK, since the automated tests actually pass we can move the parent entity reference back in here and close #2048555: Convert term parent to entity reference as duplicate.

I opened #2049121: Regression: Moving out term children on term listing page is broken to deal with the problem I experienced during my manual testing, which is independent of this issue.

klausi’s picture

#8: term-validation-2002168-8.patch queued for re-testing.

andypost’s picture

moshe weitzman’s picture

Status: Needs review » Needs work

I'm a little surprised to see a new attachLoad() method with no corresponding deletion. I thought this issue just moved around existing code?

berdir’s picture

Yeah, not too happy about front-loading the parents, we didn't do that for a reason. Also related is the issue that attempts to add methods to TermInterface.

I guess we'd rather have to make this a computed field, we already made terms slow enough...

klausi’s picture

Status: Needs work » Needs review
StatusFileSize
new4.33 KB
new7.01 KB

Ok, so I implemented a custom field class for the term parent field that lazy loads the parents.

The tests will fail because the parent is a entity reference field and the validation should flag invalid references, but I have no idea why that does not work right now.

Status: Needs review » Needs work

The last submitted patch, term-validation-2002168-13.patch, failed testing.

klausi’s picture

Status: Needs work » Needs review
StatusFileSize
new1.49 KB
new7.25 KB

It all makes a lot more sense if the parent field is not computed, because we are just loading it on demand.

We could even add a generic abstract LazyLoadField to core, so that the taxonomy module would only have to implement one lazyLoad() method that returns the field values suitable for the setValues() method.

klausi’s picture

Status: Needs review » Needs work

Does not apply anymore.

klausi’s picture

Status: Needs work » Needs review
StatusFileSize
new712 bytes
new6.88 KB

Rerolled. I also removed a @todo about integrating the description format with the description field, but that would require the creation of a TextFormattedItem (text_formatted_field) class to handle that, and that would be a bit too much for this issue. There is already a @todo in the code about that.

klausi’s picture

Patch does not apply anymore rerolled. Also fixed a module dependency in the test.

klausi’s picture

Status: Needs review » Needs work
Issue tags: +Entity Field API, +Entity validation

The last submitted patch, term-validation-2002168-18.patch, failed testing.

klausi’s picture

Status: Needs work » Needs review
StatusFileSize
new721 bytes
new6.95 KB

So the class Field is now FieldItemList, fixed that.

effulgentsia’s picture

Issue summary: View changes
StatusFileSize
new7.05 KB

Straight reroll for HEAD changes. No changes to real lines of code.

Status: Needs review » Needs work

The last submitted patch, 22: term-validation-2002168-22.patch, failed testing.

The last submitted patch, 22: term-validation-2002168-22.patch, failed testing.

effulgentsia’s picture

StatusFileSize
new7.04 KB
new460 bytes
effulgentsia’s picture

Status: Needs work » Needs review

The last submitted patch, 25: term-validation-2002168-25.patch, failed testing.

effulgentsia’s picture

StatusFileSize
new6.45 KB
new6.11 KB

The test failure is due to parent=0 being treated as an empty value and being filtered out before getting saved to {taxonomy_term_hierarchy}. There were other nasty hacks in the patch working around other difficulties in making parent into an ER field, so let's defer that to #2048555: Convert term parent to entity reference, and proceed with this, in order to move us closer to #2002180: Entity forms skip validation of fields that are edited without widgets.

jibran’s picture

Looks good to me.

berdir’s picture

  1. +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Entity/Term.php
    @@ -215,6 +215,8 @@ public static function baseFieldDefinitions($entity_type) {
         $properties['vid'] = array(
           'label' => t('Vocabulary ID'),
           'description' => t('The ID of the vocabulary to which the term is assigned.'),
    +      // @todo Convert this to an entity_reference_field once that works with
    +      // config entities.
           'type' => 'string_field',
         );
    

    This should be possible now.

    However, doing it here is only partially related to this issue, not sure. The @todo would have to be reworded at least.

    As it's the bundle, wondering if that needs special validation (could be separate issue, for all entities with bundles) as it's basically read-only, you can't just change the bundle of an entity that has fields.

  2. +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Entity/Term.php
    @@ -247,10 +253,11 @@ public static function baseFieldDefinitions($entity_type) {
           'description' => t('The parents of this term.'),
    +      // @todo Convert this to an entity_reference_field: #2048555: Convert term parent to entity reference
    

    I think we reference the URL in code comments, not just the ID like this?

fago’s picture

Status: Needs review » Needs work

Patch needs to be updated :/

effulgentsia’s picture

klausi’s picture

Status: Needs work » Needs review
StatusFileSize
new7.73 KB
new3.59 KB

Rerolled.

The last submitted patch, 33: term-validation-2002168-33.patch, failed testing.

Github sync’s picture

StatusFileSize
new7.77 KB

A new pull request was opened by klausi for this issue.

fago’s picture

As it's the bundle, wondering if that needs special validation (could be separate issue, for all entities with bundles) as it's basically read-only, you can't just change the bundle of an entity that has fields.

I think we should at least verify the bundle is there and exits, but that should be solved already by setting it to required and converting it to an ER.

OK, converting the parent field to entity reference breaks a lot of things and is confusing, so that should be splitted out to a separate issue.

Is this still the case? What's problematic about it? Could we put that all into a new issue so we can work on it there?

Please also see my comment @ [#8381407] about whether max_length on the string field makes sense?

Github sync’s picture

StatusFileSize
new8.27 KB

Some commits were pushed to the pull request.

klausi’s picture

Converting the bundle field is a separate issue: #2181593: Convert entity bundle base fields to entity reference.

Converting the parent field is a separate issue: #1915056: Use entity reference for taxonomy parents.

Synced over the changes to StringItem.php from #2002158: Convert form validation of comments to entity validation.

Status: Needs review » Needs work

The last submitted patch, 37: 2002168.patch, failed testing.

The last submitted patch, 37: 2002168.patch, failed testing.

Github sync’s picture

Status: Needs work » Needs review
StatusFileSize
new11.51 KB

Some commits were pushed to the pull request.

chx’s picture

You can't stop with this Github sync shit, can you? https://drupal.org/node/2172149 reopened, raised to critical.

andypost’s picture

Looks RTBC except minor

+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/StringItem.php
@@ -62,4 +62,18 @@ public static function schema(FieldDefinitionInterface $field_definition) {
+    $constraint_manager = \Drupal::typedDataManager()->getValidationConstraintManager();
+    $constraints[] = $constraint_manager->create('ComplexData', array(
+      'value' => array('Length' => array('max' => $this->getFieldSetting('max_length')))
+    ));

I'd just suggest to wrap this in if ($this->getFieldSetting('max_length')) see related #2150511: [meta] Deduplicate the set of available field types

Github sync’s picture

StatusFileSize
new11.56 KB

klausi pushed some commits to the pull request.

klausi’s picture

andypost’s picture

So I see no nitpicks and like to see this commited asap

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8.x, thanks!

Status: Fixed » Closed (fixed)

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