A disabled index could have an item_type that's no longer available, and that would cause an exception when we do $wrapper = $index->entityWrapper(NULL, TRUE); in search_api_views_views_data().
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | 1414048-4--catch_exception_in_views_inc.patch | 885 bytes | drunken monkey |
| #2 | 1414048--views-wrapper-exception-2.patch | 834 bytes | drunken monkey |
| #1 | 1414048-views-disabled-indexes.patch | 641 bytes | amateescu |
Comments
Comment #1
amateescu commentedThis should do it :)
Comment #2
drunken monkeyViews based on disabled indexes should be disabled automatically. However, since we don't want to delete these views just because the index is disabled, we have to include them in the list of base tables. If you remove a module providing an item type, you should just make sure to delete all indexes using that item type beforehand.
We can, should, must however catch the exception. Please test the attached patch and see if this fixes this.
Comment #3
maciej.zgadzaj commentedRelevant (duplicate?): #2069023: Fix reaction to disabled modules
Comment #4
drunken monkeyNot really a duplicate, but this issue has already been half-solved by adding a try-catch to the whole function. Also, the issue you linked should minimize the number of exceptions that occur.
Still, we should also catch the exception nearer to where it occurs, so the valid tables will still appear, even if one index is defect.
Patch attached.
Comment #5
amateescu commentedWhoa, it's been a while since I opened this issue, sorry for taking so long to reply :/ The thing is, I don't have the original code/project where I encountered this so I can't test the try/catch approch, but it seems like a sane thing to do..
Maybe Maciej can reproduce this more easily? :)
Comment #6
drunken monkeyIt's no problem. After such a long time, most people don't reply at all, so thanks for posting that!
I don't think that this patch could cause any harm, so I'll just wait a few days if someone wants to test it and then commit.
If maciej.zgadzaj wants to test, that would of course be great, though.
Comment #7
maciej.zgadzaj commentedI've already tried, and so far I've been able to get a different error when adding a view on disabled index: Call to a member function range() on a non-object in /var/www/drupal7/sites/all/modules/search_api/contrib/search_api_views/includes/query.inc on line 254 - but I'll see if I'm able to reproduce this one too.
Anyway, adding the try/catch clause around the wrapper as in #4 definitely wouldn't hurt.
Comment #8
drunken monkeyAs far as I can see there wouldn't be any exceptions: it's just that when an index has an invalid item type (because the module that defines it isn't enabled) all indexes (not just the faulty one) should vanish from VIews' base table list. That's what this patch would fix, by just removing the faulty index and still including the sane ones.
Comment #9
drunken monkeyCommitted. Hope this helps at least a bit.