Updated: Comment #0

See Issue summary for #2010930: [META] Apply formatters and widgets to rendered entity base fields (all besides node.title)

- This issue is about the feed.title and feed.url base fields.
- A 'uri' widget (\Drupal\Core\Field\Plugin\Field\FieldWidget\UriWidget) has been added.

CommentFileSizeAuthor
#66 2225399-66-feed-base-field-uri.patch1.29 KBmr.baileys
#58 2225399-58-feed-base-field-formatters-widgets.patch18.55 KBvisabhishek
#58 interdiff-2225399-53-58.txt2.53 KBvisabhishek
#53 interdiff-52-53.txt745 bytesmarcvangend
#53 2225399-53-feed-base-field-formatters-widgets.patch18.4 KBmarcvangend
#52 2225399-53-feed-entity-base-fields.patch18.36 KBmr.baileys
#39 interdiff-32-39.txt2.13 KBmarcvangend
#39 2225399-39-feed-base-field-formatters-widgets.patch18.33 KBmarcvangend
#38 interdiff-32-38.txt3.05 KBmarcvangend
#38 2225399-38-feed-base-field-formatters-widgets.patch15.81 KBmarcvangend
#32 2225399-32-feed-base-field-formatters-widgets.patch18.32 KByanniboi
#32 interdiff-27-32.txt1.84 KByanniboi
#28 interdiff-27-28.txt1.84 KByanniboi
#28 2225399-28-feed-base-field-formatters-widgets.patch18.32 KByanniboi
#27 interdiff-23-27.txt954 bytesyanniboi
#27 2225399-27-feed-base-field-formatters-widgets-do-not-test.patch16.48 KByanniboi
#23 interdiff-17-23.txt3.19 KBmarcvangend
#23 2225399-23-feed-base-field-formatters-widgets.patch16.25 KBmarcvangend
#21 interdiff-17-21.txt3.19 KBmarcvangend
#21 2225399-21-feed-base-field-formatters-widgets.patch16.25 KBmarcvangend
#17 interdiff-11-17.txt12.59 KBmarcvangend
#17 2225399-17-feed-base-field-formatters-widgets.patch14.54 KBmarcvangend
#16 interdiff-11-16.txt1 KByanniboi
#16 2225399-16-feed-base-field-formatters-widgets-do-not-test.patch13.33 KByanniboi
#11 2225399-11-feed-base-field-formatters-widgets-do-not-test.patch13.46 KBmarcvangend
#11 interdiff.txt5.11 KBmarcvangend
#8 2225399-8-feed-title-base-field.patch9.78 KBmr.baileys
#8 2225399-6-8-interdiff.txt3.12 KBmr.baileys
#6 2225399-6-feed-title-base-field.patch7.06 KBmr.baileys
#6 interdiff-2225399-2-6.txt5.16 KBmr.baileys
#2 interdiff.txt862 bytesWim Leers
#2 feed_base_fields_configurable-2225399-2.patch2.11 KBWim Leers
#1 feed_base_fields_configurable-2225399-1.patch2.04 KBWim Leers
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Wim Leers’s picture

Status: Active » Needs review
FileSize
2.04 KB
Wim Leers’s picture

FileSize
2.11 KB
862 bytes

The last submitted patch, 1: feed_base_fields_configurable-2225399-1.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 2: feed_base_fields_configurable-2225399-2.patch, failed testing.

mr.baileys’s picture

Assigned: Unassigned » mr.baileys

Assigning to me to resolve the test failures during the Szeged sprint.

mr.baileys’s picture

Assigned: mr.baileys » Unassigned
Status: Needs work » Needs review
FileSize
5.16 KB
7.06 KB

Fixed the test failures.

Status: Needs review » Needs work

The last submitted patch, 6: 2225399-6-feed-title-base-field.patch, failed testing.

mr.baileys’s picture

Status: Needs work » Needs review
FileSize
3.12 KB
9.78 KB

Fixed the remaining test failures.

yched’s picture

+++ b/core/modules/aggregator/lib/Drupal/aggregator/Entity/Feed.php
@@ -134,7 +134,14 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
+      ->setDisplayConfigurable('form', TRUE);

Note that 'title' was not exposed as an 'extra field' in HEAD, and so was not configurable (i.e eligible for drag-n-drop reorder) in Field UI "Manage forms" so far.

Probably no biggie, just pointing that this is a functionnal change.

Berdir’s picture

Good point, but we simply didn't bother with extra fields when making feeds fieldable, so this seems fine with me. It wasn't explicitly not added.

marcvangend’s picture

Here's my attempt at converting the URL form element to a base field. It also adds a 'uri' widget. I'm adding it as 'do-not-test' because relevant tests have not been adjusted yet, but I still wanted to share the progress.

Berdir’s picture

Maybe we could somehow use #2054011: Implement built-in support for internal URLs for that? Would be quite a bit an overhead just to store the URL though, so maybe not.

yanniboi’s picture

Status: Needs review » Needs work

Re-triggering tests on last patch...

yanniboi’s picture

Status: Needs work » Needs review

Oops, didnt see the 'do-not-test'. My mistake!

marcvangend’s picture

Re #12: Maybe I didn't understand your question correctly, but usually feed URL's would be external, not internal, right?

yanniboi’s picture

After having had a look at the UI, there doesn't seem to be an admin page for configuring feed fields (I may be wrong, I have never actually used the aggregate module).

Therefore I have made the title and url non-configurable.

Also the patch in #11 doesn't 'create' the file, UriWidget, but modifies a non-existent file... (not sure how that happened) so I fixed that in the patch.

marcvangend’s picture

Thanks for reviewing, yanniboi.

Here's a new patch and interdiff, including tests for the url field.

ToDo: convert the interval field.

yanniboi’s picture

Assigned: Unassigned » yanniboi

I am attempting to convert the interval field.

yanniboi’s picture

Assigned: yanniboi » Unassigned

I'm not sure if @marcvangend is actually already working on the interval field so unassigning myself...

marcvangend’s picture

Assigned: Unassigned » marcvangend
marcvangend’s picture

New patch. This one includes the field for the refresh interval. I also made sure that the order of fields and all labels and descriptions exactly match the current situation.

Status: Needs review » Needs work

The last submitted patch, 21: 2225399-21-feed-base-field-formatters-widgets.patch, failed testing.

marcvangend’s picture

marcvangend’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 23: 2225399-23-feed-base-field-formatters-widgets.patch, failed testing.

yanniboi’s picture

One small nitpick:

+++ b/core/modules/aggregator/lib/Drupal/aggregator/Entity/Feed.php
@@ -151,11 +157,27 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
+
+    $intervals = array(900, 1800, 3600, 7200, 10800, 21600, 32400, 43200, 64800, 86400, 172800, 259200, 604800, 1209600, 2419200);
+    $period = array_map('format_interval', array_combine($intervals, $intervals));
+    $period[AGGREGATOR_CLEAR_NEVER] = t('Never');
+

You add the allowed values here.

+++ b/core/modules/aggregator/lib/Drupal/aggregator/FeedFormController.php
@@ -27,35 +27,14 @@ public function form(array $form, array &$form_state) {
     $period[AGGREGATOR_CLEAR_NEVER] = $this->t('Never');

but forget to delete them here...

I'll quickly patch that because its not really a big deal.

yanniboi’s picture

Not testing because I haven't fixed the test failures.

yanniboi’s picture

Status: Needs work » Needs review
FileSize
18.32 KB
1.84 KB

I spent quite a while looking at DependencyTest, and I have no idea why our patch would change the order of the expected_modules variable, but the test is out of date anyway (and needs a follow up issue to look at it). This should pass tests.... (Fingers crossed)

Status: Needs review » Needs work

The last submitted patch, 28: 2225399-28-feed-base-field-formatters-widgets.patch, failed testing.

Berdir’s picture

Yeah, DependencyTest is the pain.

This looks great, once we have the language widget we can completely remove the form method. Not sure what's messing with the user permission test, maybe the form isn't being submitted?

marcvangend’s picture

Assigned: Unassigned » marcvangend

Good catch in #26.

The DependencyTest must have changed because aggregator module now lists options module as a dependency, because it has a select widget on the form.

I'll try to fix the permission test.

yanniboi’s picture

Status: Needs work » Needs review
FileSize
1.84 KB
18.32 KB

Ok, @marcvangend and I had a look at the UserPermissionsTest and @Berdir suggested we replace the module enable form submit with a ModuleHandler()->install() function because that handles dependencies by default. We think this is OK because the test isn't concerned with module dependencies, but the permissions resulting from them.

Patch attached!

marcvangend’s picture

Assigned: marcvangend » Unassigned
jibran’s picture

+++ b/core/modules/aggregator/lib/Drupal/aggregator/FeedFormController.php
@@ -23,39 +23,15 @@ class FeedFormController extends ContentEntityFormController {
+    // Blocked on https://drupal.org/node/2226493 which adds a generic language widget.

more then 80 chars and 2nd line after @todo starts after t of @todo :). See 1354#todo.

Wim Leers’s picture

Status: Needs review » Needs work

Great work! :) I only have nitpicks.

  1. +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/UriWidget.php
    @@ -0,0 +1,86 @@
    + *   label = @Translation("Uri field"),
    

    s/Uri field/URI/

  2. +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/UriWidget.php
    @@ -0,0 +1,86 @@
    +      '#title' => t('Size of textfield'),
    

    s/textfield/URI field/

  3. +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/UriWidget.php
    @@ -0,0 +1,86 @@
    +    $summary[] = t('URL field size: !size', array('!size' => $this->getSetting('size')));
    

    s/URL/URI/

  4. +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/UriWidget.php
    @@ -0,0 +1,86 @@
    +      '#maxlength' => $this->getFieldSetting('max_length'),
    +    );
    +
    +    return $element;
    +  }
    

    I know that the e-mail widget also has this whitespace, but it feels unnecessary. Let's delete it?

  5. +++ b/core/modules/aggregator/lib/Drupal/aggregator/Entity/Feed.php
    @@ -151,11 +157,27 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
    -    $fields['refresh'] = FieldDefinition::create('integer')
    ...
    +    $fields['refresh'] = FieldDefinition::create('list_integer')
    

    I still feel a bit ambiguous about this change. It's confusing (to me at least) that it doesn't match the Feed entity's schema (hook_schema().

    However, if Berdir thinks this is good, then I'm fine with it :)

    Please note that once entity schemas will be autogenerated based on baseFieldDefinitions(), this will cause a DB index to be created that currently doesn't exist.

marcvangend’s picture

Assigned: Unassigned » marcvangend
Wim Leers’s picture

Sorry, point 1 was nonsensical: just capitalize the "Uri", so please change "Uri field" to "URI field".

marcvangend’s picture

Assigned: marcvangend » Unassigned
Issue summary: View changes
Status: Needs work » Needs review
FileSize
15.81 KB
3.05 KB

New patch. This fixes the points from #34 and #35. I didn't run all the tests again because I have a plane to catch, but I guess it will be fine :-)

marcvangend’s picture

Sorry, forget #38, I missed a file.

Wim Leers’s picture

Status: Needs review » Reviewed & tested by the community

Awesome! Thanks a lot :)

This is good to go.

The last submitted patch, 38: 2225399-38-feed-base-field-formatters-widgets.patch, failed testing.

Berdir’s picture

Only list_integer has support for allowed values, so I guess we need to make that switch.

We're working on unifying the field types in #2150511: [meta] Deduplicate the set of available field types, but I'm not sure if this is subject to that. Would be nice to only have integer field type and make options.module just provide widgets, but not sure if that's feasible.

yched’s picture

list_integer is not duplicating any other field type, so it is not in the current scope of #2150511: [meta] Deduplicate the set of available field types.

IIRC, one of the last blockers for moving list field types into Core/Field (aside from list_boolean, which is a bit aside and has its own issue already) is #2171397: Move options_allowed_values() to a method somewhere ?. @andypost is probably more up-to-speed on that topic that I have been lately :-/

Berdir’s picture

True, it's not an exact duplicate, that's why I said it's not really in the scope of that :)

*But*, I find the name misleading (it's not about having a list of integers, but an integer field with a list of allowed values and select/options/checkboxes widgets) and it woud be nice if we could have just a single integer field type. Anyway, not a huge problem.

yched’s picture

name: true :-/
single integer field type: the problem is that a 'select' or 'checkbox' widget can only be applied to a field type that has a finite set of allowed values. If we have a single int field type that can be either opened- or closed-values, then it becomes fuzzy to decide when the select widget is applicable. Widgets are only eligible by field type.

Wim Leers’s picture

#42–45: that's why I thought that having an IntervalSelectWidget for IntegerItem might be more appropriate ("there are many interval options, but only one interval can be chosen, and an interval is an integer"). But IIRC marcvangend talked to fago, and fago guided him to this solution.

marcvangend’s picture

Re #46, I mainly guided myself to that solution, wondering if it was really needed to add a new widget while we already have a select widget (you know, DRY). Fago helped me when I got stuck on some typeddata error, he did not express an opinion about this specific solution.

Wim Leers’s picture

Oh, ok. I must've misunderstood then. Apologies. And thanks for clarifying! :)

Berdir’s picture

Yeah, I think this is the preferred way as well. Then we have this information available through the field definition and can validate it when entities are created in a different way instead of relying on a special widget.

Wim Leers’s picture

Alrighty :)

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 39: 2225399-39-feed-base-field-formatters-widgets.patch, failed testing.

mr.baileys’s picture

Status: Needs work » Needs review
FileSize
18.36 KB

Straight re-roll.

marcvangend’s picture

The patch in #52 removes one of the lines (introduced in #2177799: Allow IntegerItem's to be unsigned) that made the re-roll necessary in the first place. I'm adding it back in.

@mr.baileys, please try to create interdiffs, so small mistakes like this are easier to spot.

mr.baileys’s picture

@marcvanged: apologies... Didn't know you could create an interdiff for rerolls btw...

Wim Leers’s picture

Status: Needs review » Reviewed & tested by the community

Back to RTBC.

marcvangend’s picture

@mr.baileys: no apologies needed, thanks for your help.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
  1. +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldWidget/UriWidget.php
    @@ -0,0 +1,85 @@
    +      '#title' => t('Size of URI field'),
    ...
    +      '#title' => t('Placeholder'),
    ...
    +      '#description' => t('Text that will be shown inside the field until a value is entered. This hint is usually a sample value or a brief description of the expected format.'),
    ...
    +    $summary[] = t('URI field size: !size', array('!size' => $this->getSetting('size')));
    ...
    +      $summary[] = t('Placeholder: @placeholder', array('@placeholder' => $placeholder));
    

    $this->t()

  2. +++ b/core/modules/aggregator/lib/Drupal/aggregator/Tests/UpdateFeedTest.php
    @@ -23,7 +23,7 @@ public static function getInfo() {
    -    $remamining_fields = array('title', 'url', '');
    +    $remamining_fields = array('title[0][value]', 'url[0][value]', '');
         foreach ($remamining_fields as $same_field) {
    

    Let's fix the spelling mistake considering you are touching the line.

visabhishek’s picture

Status: Needs work » Needs review
FileSize
2.53 KB
18.55 KB

i have updated the patch based on #57.

Wim Leers’s picture

Status: Needs review » Reviewed & tested by the community

Back to RTBC.

catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed/pushed to 8x, thanks!

Wim Leers’s picture

Issue tags: -sprint

Well done, marcvangend :)

tim.plunkett’s picture

Status: Fixed » Reviewed & tested by the community

No auto-commit message, must not have pushed

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed af9cd0f and pushed to 8.x. Thanks!

  • Commit af9cd0f on 8.x by alexpott:
    Issue #2225399 by marcvangend, yanniboi, mr.baileys, Wim Leers,...
andypost’s picture

Status: Fixed » Needs work

Filed follow-up #2236599: Inherit UriWidget from StringTextfieldWidget

+++ b/core/modules/aggregator/lib/Drupal/aggregator/Entity/Feed.php
@@ -152,12 +158,28 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
+      ->setSetting('max_length', NULL)

is wrong, 'uri' field type sets to 2048 but the schema defines 'text' so there's no way to build schema from this definition

mr.baileys’s picture

Status: Needs work » Needs review
FileSize
1.29 KB

Changed the data type for uri to varchar.

andypost’s picture

#66 does not help here, base table defines 'text' (unlimited) about varchar has limits

yched’s picture

Issue summary: View changes

Status: Needs review » Needs work

The last submitted patch, 66: 2225399-66-feed-base-field-uri.patch, failed testing.

Berdir’s picture

Status: Needs work » Closed (fixed)

We are now generating the schema, so I assume whatever fix was necessary for this was done already. Closing again.