Page MenuHomePhabricator

Hook request for onCategorizationChange
Closed, ResolvedPublic

Description

I want to request a new hook that can be called when categorization changed.

Use case: I store all category names and number of childs in memcache.

Atm I have to call all kinds of hooks for that: edit, move and deletition hooks.

And onPageContentSaveComplete won't tell you if categorization changed so I flush my cache uselessly 90% of the time.

So a hook would be nice that is fired whenever the category table changes.

Event Timeline

Subfader raised the priority of this task from to Needs Triage.
Subfader updated the task description. (Show Details)
Subfader added a project: MediaWiki-Categories.
Subfader subscribed.
Aklapper triaged this task as Lowest priority.Feb 2 2016, 12:36 PM

Update: MW 1.27 destroyed the usage of all these hooks since categorization is fired after onPageContentSaveComplete.

onPageContentSaveComplete does not like this :(

Subfader raised the priority of this task from Lowest to Medium.Sep 9 2016, 9:00 PM

@Subfader: The priority of this task was increased.
As priority reflects reality and does not cause it, do you plan to work on this task? If so, please claim the task by setting yourself as assignee. Thank you for your help!

Aklapper lowered the priority of this task from Medium to Lowest.Sep 24 2016, 7:25 PM

Having the hooks run from within the web request that "makes" the change is mostly not possible because of cascading updates via templates where the template edit request cannot be allowed to also re-parse all the pages that use the template. There is also an unattended way that things change, which is that conditional templates may change based on the current date, which means after they expire, they are categorised differently.

In both cases, the change is managed by LinksUpdate and queues CategoryMembershipChangeJob. This job makes a public interface via Recent changes, that external parties can listen to via RCFeed (e.g. EventStreams in case of Wikipedia).

On the server-side, there is also hook for these. RecentChange::newForCategorization()->save() triggers Hooks::run('RecentChange_save'). The RecentChange_save hook can be used to do additional logic in your extension to synchronise data to the Memcached use case that was described. This is also how the CheckUser extension works, for example.