Broken/missing handler for view relationship after upgrade from D8 to D9

Created on 7 February 2022, over 2 years ago
Updated 24 February 2024, 4 months ago

Problem/Motivation

After upgrading my site from Drupal 8.9.20 to 9.3.2, I found that various views I'd created were reporting relationships as "broken/missing handler". These broken relationships all involved Paragraph entities, which make use of Entity Reference Revisions .

Several other people have reported a similar problem following a D8 to D9 upgrade. See here 🐛 Views Term ID has broken filters ("All of", "Is none of") and contextual filters "allow multiple" Needs work and here and here .

Steps to reproduce

I haven't tried to reproduce this problem from scratch.

Proposed resolution

Others who have come across this problem have said that the solution is to simply delete the broken relationship, and recreate it. Whilst this solution is effective, it is rather tedious and error prone, especially if you have lots of views, or your views have lots of fields which use the broken relationship - all will need to be created again. Instead, I looked for a better way.

Having deleted the broken relationship and re-created it in one of my views, I examined the exported config file to see what had actually changed. I found that the difference was trivial. In the original (broken) config file, the relationship referred to "field_XXXXX_target_id" or "field_XXXXX_target_revision_id", whereas in the fixed config file, the relationship is simply "field_XXXXX". (There was also a difference to the admin_label for the relationship, but that's purely cosmetic.)

So, it seems that in D9, views (in some circumstances) store relationships differently to the way they were stored in D8. I would have expected an update hook to modify the definition for D8 views to make them D9 compatible. Writing such a hook is beyond me, but I've found that views can be updated by applying some simple text edits to their config files. Here are the steps that worked for me.

  1. Find the details of the broken relationships: Go to the view edit page, open the Advanced section, and look under Relationships to see where it says "Broken/Missing handler". Click on that link and you'll get details of the relationship. Take a note of the id - it will be something like "field_XXXXX_target_id" (or possibly "field_XXXXX_target_revision_id")
  2. If your view has multiple broken relationships, get the id for each one. (Ignore any bits about "broken/missing handlers" on fields or filters or otherwise - these are all just implications of the broken relationship.)
  3. Edit the view config file: Use your favourite text editor to open the config file for the view, and do a search/replace for the broken relationships. Search for " field_XXXXX_target_id", and replace with " field_XXXXX". (Note: include a space in front of the id to avoid picking up partial string matches relating to something else.)
  4. Re-import the revised view definitions: drush cim.

I did find that one view was so badly broken that I wasnt able to open the view edit page for it (the site crashed with a white screen of death). In this case, I simply looked in the config file, found the "relationships" section, and from that got the ids of all the relationships. I made a guess at which were the broken ones, and edited the file as above. When I re-imported the definition, all was well.

Remaining tasks

It would be nice to have a database update hook that can make the necessary changes to the view definitions.

User interface changes

None

API changes

None

Data model changes

None

Release notes snippet

None

🐛 Bug report
Status

Active

Version

11.0 🔥

Component
Views 

Last updated 15 minutes ago

Created by

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • I’m so excited my broken marriage has been restored “We recently made up, even though it was difficult. It’s been more than a month now, and everything feels like it’s returned to normal. He has began to treat me better, and it’s been a healing process for both of us. The nightmare that had lasted for almost 2 years before we broke up is finally over. It’s like we fell in love all over again! We’ve both put the past behind us, and are trying to move forward – and for the first time in a long time, the future looks a lot brighter. I can’t express in words how grateful I am to Dr Abuu! It’s like we’ve finally rediscovered those things about each other that made us fall in love in the first place. All of the worrying and stress has simply vanished. Thank you Dr Abuu for saving my broken marriage and bringing my husband back to me!”. Me and my husband are living together happily again.. All thanks to Dr Abuu. If you have any relationship problem contact Dr Abuu now and i guarantee you that he will help you. Email him now on drabuuspelltemple@gmail.com....you can also call him or add him up on whatsApp +2348073861816

  • Losing someone you truly love and shared a close bond with, can be one of our greatest sources of "pain, this was my exact story when my relationship with my husband fell apart! I'm delighted to let y'all know that through the help of a strong willed spell caster Dr Abu - my relationship was restored. Contact: -)
    drabuuspelltemple@gmail.com

Production build 0.69.0 2024