Page MenuHomePhabricator

Add Image: Handle differences in invalidation logic
Closed, DuplicatePublic

Description

For Add Link we want to invalidate the recommendation when the user accepts some links, or rejects some links, or some non-AddLink edit is made to the article. For Add Image we don't want the last case as most edits don't affect the "needs image" status of the article. (In theory we could try to detect whether an image has been added and selectively invalidate but it's probably not worth the hassle. It's easier to detect on the client side and show a no suggestion error, and we don't expect it to be that frequent.)

Also, for Add Link invalidation involves deleting from the index and the database; for Add Image there's only the search index. For Add Link we are also relying on the database to decide when to delete, for Add Image that won't work.

Update the code to handle the differences. Probably the easiest is to do invalidation in the submission handler (see T289024: Add Image: Backend handling of user acceptance/rejection of image recommendations), and leave HomepageHooks::onSearchDataForIndex() as it is (to only handle Add Link edits), so this can probably be done as part of T289024.

Event Timeline

kostajh triaged this task as Medium priority.Aug 25 2021, 11:36 AM

for Add Image there's only the database.

My understanding is that for Add Image, there's only the search index.

@Tgr after reading the task I'm not sure what the actionable item is here. Are we supposed to remove an item from the search index after a user accepts and/or rejects an image as part of the add image workflow?

My understanding is that for Add Image, there's only the search index.

Right, it should say search index. Fixed.

@Tgr after reading the task I'm not sure what the actionable item is here. Are we supposed to remove an item from the search index after a user accepts and/or rejects an image as part of the add image workflow?

Yes. For rejection it would happen like for Add Link; for acceptance Add Link does it in the search index update hook, and that doesn't work without having an accompanying DB table, so for add Add Image it will also have to happen in the submit handler or the VE-postedit hook that's calling it.