When you enable a field for indexing, it doesn't show up in the Facets tab until you clear cache. The reverse is also true, in that when you disable a field for indexing the facet is not removed from the list until the cache is cleared. This is due to Facet API's caching of hook_facetapi_facet_info() implementation as discussed as mentioned at #1400136: Facets are not removed / added from the list when a field's indexing status changes. The solution is to add a submission handler that clears the appropriate caches when the search_api_admin_index_fields() form is submitted.

Comments

cpliakas’s picture

Status: Active » Needs review
StatusFileSize
new984 bytes

The attached patch adds a form submission handler and clears the appropriate caches.

cpliakas’s picture

StatusFileSize
new992 bytes

Same patch, fixed form alter docblock.

Status: Needs review » Needs work

The last submitted patch, facet-info-cache-invalidation-1569874-2.patch, failed testing.

cpliakas’s picture

Status: Needs work » Needs review

Hm, tests are passing locally. Let's try again?

cpliakas’s picture

Status: Needs review » Needs work

The last submitted patch, facet-info-cache-invalidation-1569874-2.patch, failed testing.

drunken monkey’s picture

Status: Needs work » Fixed

Thanks a lot for the patch! Didn't realise Facet API was now doing caching, as you previously opposed it so fervently. ;)
Your patch looks good, don't be out off too much by the test bot's rejecting it. I already removed that particular assertion which inexplicably always failed for the online test bot. The testing suite seems to have some problem with messages not being displayed sometimes. I already reported it, although it's of course been ignored ever since.

Aaaaanyways, thanks again for the patch! Committed.

Status: Fixed » Closed (fixed)

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