Problem/Motivation

In #3117171: Bulk Form field for SAPI, we've introduced a the bulk form SAPI field. As we've used SearchApiFieldTrait, this trait adds 4 default options (link_to_item, use_highlighting, multi_type, multi_separator), the field will receive these options, even, I think, it doesn't need them. As the options schema of search_api_bulk_form plugin is the same as for views.field.bulk_form, we're getting:

views.view.*:display.default.display_options.fields.search_api_bulk_form.link_to_item failed with: missing schema

on a config sanity test that we're running.

Proposed resolution

I see 2 options:

  1. Quick fix: Add missed mapping to views.field.search_api_bulk_form schema.
  2. Complex fix:
    • Keep in SearchApiFieldTrait only methods regarding these field plugin options: ::defineOptions(), ::buildOptionsForm(), etc and all the logic that depends on these options (not an easy job!).
    • Move the other methods and logic in a new trait.
    • Use the new trait in SearchApiFieldTrait. In this way we are not breaking BC.
    • In SearchApiBulkForm use the new trait.

The 1st approach is effective, the 2nd is too complex. I will provide a fix for the 1st, while discussing all options.

Remaining tasks

None.

Issue fork search_api-3195199

Command icon 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

claudiu.cristea created an issue. See original summary.

claudiu.cristea’s picture

Status: Active » Needs review

Created MR on option 1.

pfrenssen’s picture

This is looking good. I don't see how this patch can make that test fail so I restarted it. Possibly a random failure. If test comes back green this is RTBC.

drunken monkey’s picture

Component: General code » Views integration
StatusFileSize
new492 bytes

Thanks a lot for reporting this, good catch!

The Composer test fails are apparently due to #3190024: Problem with test dependencies when testing issue forks. However, I don’t have an explanation for the others, either.

In any case, now that we are aware of the problem, I’d prefer fixing it correctly, not just with a band-aid – that is, not include options we don’t use in the field config.
The attached patch tries to implement that, please test/review!

drunken monkey’s picture

Any feedback on my patch?

claudiu.cristea’s picture

Sorry for late feedback. Just now, I've tested #5. Unfortunately, I'm still getting:

Schema key views.view.manage_collection_solutions:display.default.display_options.fields.search_api_bulk_form.link_to_item failed with: missing schema

With the code from https://git.drupalcode.org/project/search_api/-/merge_requests/6, the tests is passing. We're running this test https://github.com/ec-europa/joinup-dev/blob/develop/web/modules/custom/... to catch missing or erroneous schemas in exported config.

However, due to some infrastructure issues, we're still using Search API 1.13.0. I don't know if this influences the outcome of the test.

drunken monkey’s picture

StatusFileSize
new471 bytes

Seems like you just need to adapt the export of your manage_collection_solutions accordingly? I.e., remove those settings keys (link_to_item and use_highlighting) from the search_api_bulk_form field.
We could of course also add an update hook to do that for you (and others), but I’m not sure that’s worthwhile.

Patch was also outdated, attaching a re-roll.

claudiu.cristea’s picture

Assigned: Unassigned » claudiu.cristea

OK, will assign to do a review on a vanilla install.

drunken monkey’s picture

Any update? Otherwise, I’ll just commit.

  • drunken monkey committed 64acd73 on 8.x-1.x
    Issue #3195199 by drunken monkey, claudiu.cristea: Fixed config schema...
drunken monkey’s picture

Committed.
Thanks again, everyone!

drunken monkey’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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

claudiu.cristea’s picture

I was only today able to test the patch from #8, as only now I've updated to Search API 1.21. Unfortunately, #8 doesn't fix. I'm still getting the error from issue summary and #5.

claudiu.cristea’s picture

Opened #3250991: Issue #3195199 is not fixed as I cannot re-open this one.

drunken monkey’s picture

Status: Closed (fixed) » Active

Sorry it took me a while to read the new issue. In the future, please feel free to ping me on Slack in such cases. (Or even by mail/contact form, I guess, if it’s really just “please re-open issue XYZ”.)

Anyways, thanks for reporting back, even if it was a bit late. Does re-saving the view help? Or when you manually remove those keys from the config, and then re-save, do they stay removed? In the latter case, we could add an update function to implement this, even if it’s rather a lot of effort for a small problem (schema errors don’t really do much harm, right?). Otherwise, I think we should be happy with at least keeping saved views correct going forward.

If nothing helps, do you have any theory on why the options still get added? Did we miss something?

herved’s picture

I just checked this, here is why: https://3v4l.org/J99Af#vnull
Aliasing in traits does not remove or disable the original method, it only gives the method an additional name.
So the committed fix doesn't work.

Maybe what we could do is override defineOptions and buildOptionsForm as empty in the SearchApiBulkForm class.

herved’s picture

Status: Active » Needs review
herved’s picture

Status: Needs review » Needs work

oops it didn't pass, checking...

herved’s picture

Status: Needs work » Needs review

drunken monkey’s picture

@herved: Looks great, thanks a lot! Also thanks for the explanation – I was (obviously) not aware of that, very good to know.

@claudiu.cristea: Want to give the MR a try to ensure this finally gets resolved?

claudiu.cristea’s picture

Status: Needs review » Reviewed & tested by the community

Thank you @herved. Looks good to me and works on my project

claudiu.cristea’s picture

Assigned: claudiu.cristea » Unassigned
drunken monkey’s picture

Status: Reviewed & tested by the community » Fixed

Great to hear, thanks for confirming!
Merged.
Thanks again!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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