Currently when an aggregated field is added or changed the persistent cache is not cleared. The user has to manually do a cache clear before the aggregated field appears in the fields tab.

Steps to replicate

  1. Go to the "Filters" tab.
  2. Enable "Aggregated fields".
  3. Add a new aggregated field and save the configuration.
  4. Go to the "Fields" tab.

Expected result: the new aggregated field appears in the list.

Actual result: the field does not appear, only after manually clearing the caches the field becomes visible.

Comments

pfrenssen’s picture

Patch uses drupal_array_diff_assoc_recursive() which was added in Drupal 7.23 so this raises the required minimum Drupal version.

If this is a problem we can backport it as a protected method, or rename it as search_api_array_diff_assoc_recursive().

pfrenssen’s picture

Status: Active » Needs review
drunken monkey’s picture

Thanks for reporting!
You're right, for some reason we clear the static cache when saving the index, but not the persistent one, instead trying to only do that when it's really necessary. We could add additional code that makes sure the available fields also stay the same, but I think it makes more sense to just get rid of that and always clear the persistent cache, too, when editing the index. It shouldn't happen that often, after all.
Patch attached.

drunken monkey’s picture

Oops, the previous patch would have failed to call fieldsUpdated() when the fields change. Good thing I just spotted this when I wanted to commit …

Could you please test the attached patch and see if that works for you? Then I would commit it in a few days.

drunken monkey’s picture

Status: Needs review » Fixed

Committed.

  • drunken monkey committed 74d16a8 on 7.x-1.x
    Issue #2305755 by drunken monkey, pfrenssen: Fixed invalidation of the...

Status: Fixed » Closed (fixed)

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