Problem/Motivation

I've noticed that when a read-only index is deleted the deleteItems() function for that service is called.

Should it be? Doesn't this contradict the fact that it's read-only?
Would this be a problem out in the wild?

The only reason I've come across this is I haven't yet implemented indexItems() or deleteItems() for the IDOL search service (data is currently populated by IDOL, not Drupal).
Instead these functions throw an exception.

Proposed resolution

Prevent deleteItems() being called when deleting read-only indexes. ??

Remaining tasks

Evaluate if this is an issue and it's impact to everyday users of Search API.

User interface changes

Mention on the "Do you really want to delete this index?" page for a read-only index that data will not be removed. ??

API changes

None.

Comments

drunken monkey’s picture

Your point makes sense, I guess we really shouldn't delete items from a read-only index. Do you want to provide a patch? (Mentioning this on the deletion confirm form would also be a good idea, probably.)

Akaoni’s picture

Title: Deleteing Read-Only Indexes Calls deleteItems() » Deleting Read-Only Indexes Calls deleteItems()

Fixing typo and also pushing this higher up in my queue so I don't forget (again). ;)

drunken monkey’s picture

Status: Active » Needs review
StatusFileSize
new1.72 KB

I guess this will have to be fixed by service classes, as we can't know what they'll do in deleteItems(). The attached patch would add documentation to that effect, fixes the default implementation (which had a bug anyways) and also refrains from calling the deleteItems() method later for currently disabled servers if the removed index was read-only (since then the server would only get the index's ID and wouldn't be able to tell whether it was read-only).
Please review and see if these changes make sense to you. And again, thanks for reporting!

See also #2020903: Fix deletion of indexed data when a read-only index is removed from the server for the database search. The Solr backend already fixed this a while ago.

drunken monkey’s picture

Status: Needs review » Fixed

Committed.

Status: Fixed » Closed (fixed)

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