Back in #2777483: Unmet dependencies we introduced the "Search API Taxonomy Term Handlers" module (search_api_views_taxonomy) as a means to avoid fatal errors when the Plugin API would try to evaluate our taxonomy term-specific Views handlers and the Taxonomy module was disabled.

However, isn't that exactly what plugin alter hooks (hook_views_plugins_filter_alter() and hook_views_plugins_argument_alter(), in our case) are there for?
In the other issue we tried it by removing the plugins if the taxonomy module isn't installed – which doesn't work, the hook is called too late in the process (can't really be called early enough, conceptually) and there's no fitting hook for before.
However, the opposite should work fine, as far as I see: Remove the annotations from those two plugin classes and only set them in the alter hooks if the Taxonomy module is enabled. Not ideal, but much better than an additional module, I'd say.

Open question (if this actually works): How can we make the update as painless as possible for people who already have the module enabled? Probably we should keep the module for some time but set it to hidden? Can it still be disabled in the UI that way?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

drunken monkey created an issue. See original summary.

drunken monkey’s picture

Issue summary: View changes
odavydyuk’s picture

drunken monkey’s picture

Huh, seems this is a duplicate of #2917399: Missing / broken handler when adding a filter for a field, we apparently overlooked it. At this point, really the only thing to do is removing the module, so: thanks for the patch!
We should probably still wait a bit with that, though, to give people time to disable it. But good to already have the patch prepared.
It would be great if you, or someone else, could bump this issue again in a few months (after another Search API release or two).

borisson_’s picture

I don't think we can do this in the 1.x branch. We should probably create a new branch and add this issue to the new branch?

drunken monkey’s picture

I don't think we can do this in the 1.x branch.

Why not? If we wait for a few more months and releases (we can even check the usage statistics for the pre-1.6 releases), this should affect almost no one. And even for those, it would only cause log messages about the missing module.

I don't really plan on creating a 2.x branch, I planned on just removing deprecated stuff either over time or with Drupal 9. Module can't use semver anyways, so no use feeling too bound by its rules.

VitaliyB98’s picture

Status: Needs review » Needs work
3li’s picture

I'm getting this error but If I uninstall the module It will remove blocks, views & facets?
What steps should I take to prevent this?

Edit: I managed to continue with the update, by pressing 'try again' at the bottom of the page but this is still a problem. I cannot remove this module without deleting all of the content.

drunken monkey’s picture

Try re-saving the views, that should remove the dependency on the module.

craneswalker’s picture

I was having the same issue as #9. I saved the views again and no dependency change happened. Any other ideas?

drunken monkey’s picture

You could try manually removing the dependency, by exporting, changing and importing the config.

idebr’s picture

legolasbo’s picture

We can't just assume that people have read the deprecation warning and uninstalled the module. Just removing the module has a high probability of coming back to bite us in the form of people complaining of missing module warnings. I therefore propose to add an intermediate release with an update hook that safely uninstalls the module and then actually remove it in a subsequent release. See attached patch for the safe uninstallation update_hooks.

borisson_’s picture

I like that #14 is very cautious, should we do this in another issue? To keep the work/credit in the one intact?

legolasbo’s picture

I think this is all working towards the goal of removing the module. People working on individual commits get credited for those commits. People generally working on the issue would get credited for the issue being closed at some point, so all credits are properly divided when this issue closes (in my opinion).

So I vote for just making this a 2 step issue.

borisson_’s picture

Status: Needs review » Reviewed & tested by the community

Sounds good.

drunken monkey’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
897 bytes
1.41 KB

Huh, great idea! Wouldn’t have thought of actually uninstalling a module in its own update hook, but apparently it works fine.
However, I’m a bit worried about the first update hook: just loading and re-saving all views seems pretty time-consuming for larger sites (as we probably all know, some sites have staggering amounts of views, and views aren’t really small objects either), and might even lead to memory exhaustion for some. Checking whether the view in question actually has a dependency on the module should save a lot of time and database writes. But for preventing issues when all views are loaded at once, we might need to convert this to a batch-ed update. (On the other hand, I guess all (enabled) views are already loaded by Views under certain circumstances (e.g., determining all Views pages), so it might actually be fine. Still, not re-saving them if they have nothing to do with us seems like a good idea. No telling what problems we might trigger with that, on the potentially thousands of sites this would run on.)

Or, alternatively, just get rid of the first hook and leave the user dealing with it if there are still dependencies. It might not work in a lot of cases, but then at least everyone would know they need to uninstall the module.

Also, in the second hook, shouldn’t we rather throw an UpdateException if uninstalling fails, so we make it clear that the user has to take some action? I don’t think that would prevent other updates from running, right?

Also, two minor nitpicks (among them that first lines of doc blocks are exempt from the 80 character limit), see attached revision.

borisson_’s picture

Also, two minor nitpicks (among them that first lines of doc blocks are exempt from the 80 character limit), see attached revision.

This is new to me. I understood this rule as "should be only 80 cols, but can not wrap to another line".

legolasbo’s picture

drunken monkey’s picture

This is new to me. I understood this rule as "should be only 80 cols, but can not wrap to another line".

Yes, that’s what I meant. Poorly phrased, sorry. I just meant that a line break was “more forbidden” than an overlong line in this case.

Regarding the patch: Not sure why I didn’t pounce on that earlier, but we can’t actually load or save views in an update hook, according to the documentation:

In particular, loading, saving, or performing any other CRUD operation on an entity is never safe to do (they always involve hooks and services).

So, let’s get rid of the first update function after all, alright?
(We could also remove the dependency from the config object directly, of course – but not sure whether that’s wise.)

Also, it seems you included another issue’s code in your patch.

borisson_’s picture

Status: Needs review » Reviewed & tested by the community

Looks great now.

drunken monkey’s picture

Status: Reviewed & tested by the community » Postponed

Alright, thanks!
Postponing until the next release, then we should finally be free to remove this!
Thanks again for the great suggestion, legolasbo!

drunken monkey’s picture

Status: Postponed » Needs review
FileSize
2.59 KB

Alright, release created – let’s do this!

borisson_’s picture

Status: Needs review » Reviewed & tested by the community

Deleting code is the best! RTBC.

  • drunken monkey committed ce3aa0b on 8.x-1.x
    Issue #2867479 by drunken monkey, odavydyuk, VitaliyB98, idebr,...
drunken monkey’s picture

Status: Reviewed & tested by the community » Fixed

Awesome, thanks for reviewing!
Committed.

Status: Fixed » Closed (fixed)

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

DamienMcKenna’s picture

BTW this leaves sites showing the following error:

The following module is missing from the file system: search_api_views_taxonomy in drupal_get_filename() (line 277 of core/includes/bootstrap.inc).

I opened #3067640: Removal of search_api_views_taxonomy leaves systems showing "missing module" error to deal with this issue.