Closed (fixed)
Project:
Search API
Version:
8.x-1.x-dev
Component:
Views integration
Priority:
Major
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
30 Sep 2016 at 16:14 UTC
Updated:
16 Feb 2017 at 10:27 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
strykaizerWe probably need an upgrade path too if we want to disable the tags caching, like I did in this patch.
Also, its totaly fine for me to keep tag caching, although it does break facets, so we'll need to add some description in that case (which can happen in facets, if no other module has issues with tags-caching)
Comment #3
strykaizerComment #4
borisson_Just asked @StryKaizer to also test time based caching. Attached patch also fixes cs.
Comment #5
borisson_Let's see if I can figure out the upgrade path.
Comment #6
borisson_I tested time-based and that doesn't seem to be working either. So adding in that as well. I also added the upgrade path.
Comment #7
nick_vhQuite major as it is causing a lot of confusion from what I heard. Only "clones" of the default view is working till "it is all broken". Let's get this in asap.
Comment #8
nick_vhWe need some tests to make sure that the "old" views get updated accordingly. If we decide to not do this, we should make it clear in the release notes. Borisson told me there were 4 issues in Facets that were caused by this bug. drunken_monkey, opinions?
Comment #9
andypostbtw is there schema for this value
Comment #10
drunken monkeyThanks for creating this issue. I wasn't aware that a cache plugin is set by default, but this really does sound like a problem we need to fix. Facets won't be the only components affected by this, and this might also mess with the search results itself.
However, I don't think the approach in the patch is the best way to fix the problem.
First off, there were a number of smaller problems with the patch, fixed in the attached revision.
Secondly, though, it seems to me that
search_api_views_plugins_cache_alter()would be a much better place to restrict the available cache plugins. It would be quite a bit of data to set, granted, but the code should be simple: just set'bases'to all non-Search API base tables for all cache plugins that don't have the key set already. Doing a form alter seems a much shakier solution for this.Also, regarding
hook_view_presave(): wouldn't this result in overwriting the cache backend even when importing a finished view – which might have caching set to "None" (as, I think, is even what we want to recommend – "Search API specific" is better than the default ones, but will still often report stale results and have a very low rate on cache hits for a typical site)? If we want to set a default, I'm for "None", and in any case we should take care not to overwrite existing settings.(Regarding that, even in my attached patch we might want to change the update function to only change the cache plugin if it is one of the two we're removing.)
As for tests, does anyone know how to write update path tests? Are there any examples we can look at?
If it's easy, we should definitely add a test (good practice, and best to start early with that), but otherwise I think we can also skip it for this issue.
That's Views default configuration. If that doesn't have a schema, it's Views' problem, not ours.
Comment #11
borisson_Just had another bugreport for this: #2817269: facets blocks appear only when the cache is cleared
Comment #12
borisson_I don't know how to write update tests, not sure if that's easy to do. It's also a very simple change. I wouldn't mind just committing as-is. I did work on this patch so feel free to not commit this just on my rtbc alone.
Comment #13
drunken monkeyI agree regarding tests, but what about all the other arguments I make in #10?
Also, I think
hook_ENTITY_TYPE_create()might be more appropriate thanhook_ENTITY_TYPE_presave().Comment #14
borisson_create does sound like a better place to do this. I also agree that having none as a default is a good idea.
Comment #15
borisson_I don't think create is a good idea, as that's not when a first save is triggered. I did change the default cacheing mechanism though.
Comment #17
drunken monkeyBut if we do it in the create hook, people will get the right default, right? I.e., if someone creates a new view, it will be right there when they get to the edit UI for the view?
Also, the update hook still needs to be fixed, to only change the plugin if it isn't
'none'(or already'search_api').Comment #18
pfrenssenI wouldn't do this, this might break existing sites.
There are two valid reasons where people will not be using the default cache plugin: the first is because they use no caching (which is the default), and secondly because they are using their own custom plugin that is tailored to their use case.
This also contradicts what this issue is about - to default to the Search API cache on NEW views.
Comment #19
pfrenssenIs this reliable? This code will be executed whenever a View is saved, not only when one is created through the interface. The
!isset($entity->original)seems to be to detect if the entity is new, but that can be better achieved with$entity->isNew().The problem is that this will force the disabling of the cache on any new view that is being saved to the storage, so this will also happen when importing a new view in production using CMI, or whenever any view is created programmatically or through REST etc.
I think the idea is that if a site builder sets up a new view through the UI, the caching plugin should default to 'none', but not when saving a new view entity programmatically.
How does Views decide that the 'tag' plugin is the default? Can't that be altered somehow?
Comment #20
drunken monkeyThanks for weighing in here, pfrenssen!
For the update hook, maybe a compromise would be to only update this if the setting is one of the two cache plugins provided by Views itself (
tagortime)? That should let us cover most accidental misconfigurations, while also not changing any (or only very few) configurations that are deliberate.But maybe leaving this out completely is indeed the better option. It's just that a lot of existing sites already seem to have problems, so we'd need a different solution for those. (Maybe a
hook_requirements()warning?)You're right about the pre-save code – like this, it's not acceptable, since it would prevent any kind of cache plugin changes. Might be acceptable if it only changes the two Core Views cache plugins, though. But I'd still prefer it as post-create code.
Another thing I now noticed, though: Why do we only change this for the default display? Can't this be overridden in other displays?
Comment #21
borisson_I think leaving it out and just making a mention in the next release notes should be sufficient.
Sure, I guess that might help, I don't really have time to look at it this week but if no one has picked this up when I find time for this, I'll change that.
No idea. We should probably loop over all displays.
Comment #22
borisson_Removed the update hook en only react on hook_insert. Tested locally and it looks like it works like a charm.
Comment #23
pfrenssenI think this is OK. I would add some documentation here though to explain why we are forcing people's cache plugins to 'none' when they save using the standard 'tag' or 'time' plugins. People might wonder what is going on here, why we're messing with their entities on save :) If possible also maybe log a message in the watchdog to alert them.
Comment #24
borisson_Maybe we can do a drupal_set_message if we changed the cache plugin?
How about
drupal_set_message(t("We changed the cacheing strategy of this view 'none' to make sure that you don't run in to unexpected problems, such as facets not working"));?Comment #25
drunken monkeyUnfortunately, no-one really reads release notes, so this might still get us a few issues with people complaining about this. So I'm not sure we shouldn't just do it with an update function. After all, if we just change "time" and "tag", it's sure to be the right thing to do in almost all cases.
Also, I don't like this checking for dependencies. Doesn't checking for the query plugin make more sense? Patch attached, please test/review!
Comment #26
borisson_Hm, I understand. I'll have a look at the patch after dinner, do you have an opinion on the message? (should we add it / is it a good one?)
Comment #27
borisson_Setting this to rtbc. I think this new default is good and the implementation makes sense, the update hook will only works for the core cacheing methods that were previously also unsupported.
Comment #28
drunken monkeyThe message would make sense, yes. My suggested wording (see attached patch):
I don't really understand your argument against (or is it in favor?) an update function. Changing the cache setting away from unsupported plugins is exactly what we want, isn't it? So I'd just do that, and notify the user in the update function's return value of the changes.
Comment #29
drunken monkeyAnd now again with a proper update function. Already tested it, too.
Comment #30
borisson_That looks great!
Comment #32
drunken monkeyGood to hear, thanks for your continued input on this!
Committed.
Thanks again, everyone!
Comment #34
strykaizerCurrently broken.
Once #2836237: Views with a different query plugin created via the UI do not have the correct query plugin ID in the view config is fixed, this will be working again