Upgrade from 'as a reference filter' not working with core 10.4.0-rc1

Created on 6 December 2024, 12 days ago

Problem/Motivation

Upgrading views exposed filters from the 'as a reference filter' is not working with core 10.4.0-rc1 and views_core_entity_reference 1.0.0-alpha2; what am I missing?

Steps to reproduce

With core 10.2.7 and this patch https://www.drupal.org/files/issues/2024-04-17/3347343-comment156-10.2.x β†’ ...
I had updated my views exposed filters as needed to use this patch's "field_name as a reference filter" method.

Now that a fix has been backported to 10.4, I remove the patch, installed module views_core_entity_reference 1.0.0-alpha2 and upgraded core to 10.4.0-rc1, then enabled views_core_entity_reference

Expected: My views exposed filters using the 'field_name as a reference filter" method would be upgraded to the new "Related..." versions provided by the fix (ideally). Or at least I could edit the filters to use the new method.

Actual: My views exposed filters using the 'field_name as a reference filter" method are listed as 'Broken/Missing handler', there is no way for me to edit those filters, and if I try to 'Add' I don't see the new "Related...." filters as mentioned in the change notice https://www.drupal.org/node/3403710 β†’

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States en-cc-org

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @en-cc-org
  • πŸ‡¬πŸ‡§United Kingdom scott_euser

    Could be one of two things.

    1. Update hook not running on fresh install, maybe we need to call it from hook install, but for now you can run it manually https://drupal.stackexchange.com/a/179811
    2. Your version of the patch differs from the update hook. There were so many versions of the patch over the years, contributions are needed to cover more versions (see module homepage) but for now if you check the source code, the test submodule has configuration for one 'as a Reference' version, if your version matches that then (1) should work.

    Thanks

  • πŸ‡ΊπŸ‡ΈUnited States en-cc-org

    Thank you for the quick reply!

    I don't think it's #2 because mine fits what I see in the module & test submodule code, for example (looks the same before and after this module):
    field_topics_target_id_reference:
    id: field_topics_target_id_reference
    table: node__field_topics
    field: field_topics_target_id_reference
    relationship: none
    group_type: group
    admin_label: ''
    plugin_id: entity_reference
    operator: or
    value: { }
    group: 1
    exposed: true
    expose:
    operator_id: field_topics_target_id_reference_op

    Looks like this module attempts to remove the '_reference' but that didn't happen for me. I wasn't sure if this line was a factor:
    if (
    $filter['plugin_id'] !== 'entity_reference'

    Either way, I am able to delete the broken exposed filters and add them again, and they work as expected.

    Question:
    I am able to add the filters by adding 'field_name' but NOT the 'Related field_name..' as illustrated in the change record at https://www.drupal.org/node/3403710 β†’ Is that expected? Maybe because this module successfully opted me in?

    Thanks again, appreciate all your efforts

  • πŸ‡¬πŸ‡§United Kingdom scott_euser

    Question:
    I am able to add the filters by adding 'field_name' but NOT the 'Related field_name..' as illustrated in the change record at https://www.drupal.org/node/3403710 β†’ Is that expected? Maybe because this module successfully opted me in?

    Yeah when I made those screenshots I had actually named the fields 'Related articles' that's all. At the moment in core, there is no option to choose between them other than programmatically (like this module does for you) until ✨ Configurable views filters to allow for different widgets Active .

    Looks like this module attempts to remove the '_reference' but that didn't happen for me. I wasn't sure if this line was a factor:
    if (
    $filter['plugin_id'] !== 'entity_reference'

    That condition ends in a continue; as in don't proceed if not entity_reference filter (along with the other criteria). From what I can see from your config, your code should pass that condition so I think it is more that the install hook should trigger the same update.

    You said you resolved it manually, so that means you did not try the https://drupal.stackexchange.com/a/179811 - is that correct? I think yes.

  • πŸ‡¬πŸ‡§United Kingdom scott_euser
  • Merge request !4Resolve #3492343 "Automated update" β†’ (Merged) created by scott_euser
  • Pipeline finished with Skipped
    7 days ago
    #366046
  • πŸ‡¬πŸ‡§United Kingdom scott_euser

    Had to fix a gitlab CI deprecation but updated the install process to also trigger the update now.

  • πŸ‡ΊπŸ‡ΈUnited States en-cc-org

    Thanks Scott! Correct, I did not try the https://drupal.stackexchange.com/a/179811 as I didn't want to add to my own confusion lol. Thanks for the clarifications! I'm almost done manually re-adding my filters & they're working as expected. Thanks again for your help.

  • πŸ‡¬πŸ‡§United Kingdom scott_euser

    Sure no problem at all

  • πŸ‡¬πŸ‡§United Kingdom scott_euser

    And thanks for raising in the first place, always helps make things better for the next person!

  • πŸ‡¨πŸ‡­Switzerland znerol

    This MR introduced the following chunk in views_core_entity_reference.install:

    /**
     * Implements hook_install().
     */
    function views_core_entity_reference_update_install($is_syncing) {
      _views_core_entity_reference_update_as_a_reference();
    }
    

    If I'm not mistaken, the new hook_install() implementation is in fact a hook_update_N implementation (where N = install instead of a number).

  • πŸ‡¬πŸ‡§United Kingdom scott_euser

    Hook install should be called on initial install for new installations (according to the docs at least) whereas hook updates are only called when a module is already installed and is then subsequently updated to a new version.

  • πŸ‡¨πŸ‡­Switzerland znerol

    True. But the function is named like this: views_core_entity_reference_update_install.

    The module name is: views_core_entity_reference. Hence, module handler will interpret the remaining _update_install as hook_update_N instead of hook_install.

Production build 0.71.5 2024