Problem/Motivation
Upgrading views exposed filters from the 'as a reference filter' does not automatically convert the version of the patch that had the 'as a reference' suffix on each label.
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
Trigger the update from hook_install
Remaining tasks
MR
User interface changes
N/A
API changes
N/A
Data model changes
N/A
Issue fork views_core_entity_reference-3492343
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
scott_euser commentedCould be one of two things.
Thanks
Comment #3
en-cc-org commentedThank 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
Comment #4
scott_euser commentedYeah 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 #3438054: Configurable views filters to allow for different widgets.
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.
Comment #5
scott_euser commentedComment #8
scott_euser commentedHad to fix a gitlab CI deprecation but updated the install process to also trigger the update now.
Comment #9
en-cc-org commentedThanks 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.
Comment #10
scott_euser commentedSure no problem at all
Comment #11
scott_euser commentedAnd thanks for raising in the first place, always helps make things better for the next person!
Comment #12
znerol commentedThis MR introduced the following chunk in
views_core_entity_reference.install:If I'm not mistaken, the new
hook_install()implementation is in fact ahook_update_Nimplementation (whereN=installinstead of a number).Comment #13
scott_euser commentedHook 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.
Comment #14
znerol commentedTrue. 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_installashook_update_Ninstead ofhook_install.Comment #17
scott_euser commentedAha I see, thank you! Updated hook name, manually tested. Thanks
Comment #18
scott_euser commentedComment #19
znerol commentedThank you!