Our Views query plugin already has such a method, to let a filter (or some other plugin) say, "something is very wrong here, please abort the search". The effect is that the view won't have any results and show an error message instead (if given/appropriate).
I think the same would make a lot of sense for our own query class, too – an abort() (and isAborted()) method that will just set an internal flag to not return any results from the search (and maybe, optionally, to set a warning, although that could also use the current addWarning() mechanism – a lot easier, if #2641396: Add a way to add warnings or ignored keys right on the query gets in).
A place where we could really use this is the "Content access" processor, which currently has no clean way of aborting a search if the user doesn't have the permission to see any results. But might come in handy in other contexts, too.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | 2641398-4--add_query_abort_method.patch | 6.48 KB | drunken monkey |
Comments
Comment #2
drunken monkeyComment #3
drunken monkeyThis blocks #2641392: Review our language/translation support, so we should finally do this.
The patch is pretty simple, the biggest question marks regard naming and phrasing (methods, documentation, content access processor error message). Any comments, anyone?
Comment #4
drunken monkeyHuh, interesting question, though: should results from aborted queries be post-processed?
Usually, I guess with empty results it won't matter much one way or another, but we'll still have to decide.
The attached patch would add post-processing, but I'm not sure.
Comment #5
drunken monkeyI guess it feels more intuitive to me if it does get postprocessed. This is also less likely to cause problems later, I'd say. So, committed #4.
Comment #7
drunken monkey???