Page MenuHomePhabricator

Add more mw.hook events for wikipage: diff, categories etc.
Closed, ResolvedPublic


T32713 added "wikipage.content" passing it #mw-content-text, and fired it on initial load and from live preview (and other code like VisualEditor and other extensions/gadgets should also fire it when they replace/update the content).

A few others we should add for things outside the content:

  • wikipage.langlinks arguments: #p-lang

    Fire initially if #p-lang exists/non-empty, and from live preview.
  • [DONE in rMW9cfb9cb9fba4dcfd25a0924237681b7cc86a20df] wikipage.diff arguments: #wikiDiff

    Fire initially if page has a diff on it, and from live preview if user did "show changes".

    e.g. for patrolling tools to hook into the diff and the [mark as patrolled] link.
  • [DONE in rMW8d0dcb863701e78cb4b066f176da89091bba67b3] wikipage.editform arguments: (common parent of .mw-summary-preview, .templatesUsed, .hiddencats)

    e.g. for vector.footerCleanup and other things that hook into this.

Version: 1.21.x
Severity: normal


Related Gerrit Patches:
mediawiki/core : masterAdd wikipage.categories hook
mediawiki/core : masterAdd a wikipage.diff hook

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 1:43 AM
bzimport set Reference to bz51583.
Krinkle created this task.Jul 17 2013, 11:39 PM

These are easy to add. Holding off until usage of "wikipage.content" is slightly more widespread and we have more use cases for these (e.g. will HotCat be able to use this? etc.)

If you need one of these hooks, please let it know here including a brief description of how/where you'd like to use it. That'll help to shape the details of exactly where these hooks would go.

As the Target Milestone on this ticket has been set to 1.22.0:

According to "MediaWiki 1.22 is slated for release on November 30th, at the very latest."

If this is still intended to get fixed for 1.22.0, a patch is needed soon.

[Bumping TM as MediaWiki 1.22.0 tarball was released today.]

Removing target milestone that was in the past.

If you want this in a specific release, have a good reason AND you are willing to find resources to fix this bug, feel free to change it to something appropriate.

Krinkle removed Krinkle as the assignee of this task.Feb 21 2015, 12:19 AM
Krinkle set Security to None.
He7d3r updated the task description. (Show Details)Feb 22 2015, 9:12 PM
TheDJ added a comment.Mar 27 2015, 7:31 PM

So, now that I'm so much further along with LivePreview, I'm pondering taking on some of these elements next. I was thinking starting with templatesUsed, hiddencats and limit report (I've selected them because they are EditPage only elements, should be a safe start).

Do we still agree that this is the right approach ? Or have ideas changed over the past 2 years ?

matmarex updated the task description. (Show Details)May 25 2015, 10:15 PM

Change 218275 had a related patch set uploaded (by TheDJ):
Add a wikipage.diff hook

He7d3r added a subscriber: He7d3r.Jun 14 2015, 11:16 PM

Change 219629 had a related patch set uploaded (by TheDJ):
Add wikipage.categories and wikipage.languages hooks

Not mentioned yet, but IMHO makes sense, too: #firstHeading

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptSep 4 2015, 10:28 AM
Krinkle renamed this task from Add mw.hook event for wikipage: categories, langlinks, diff etc. to Add more mw.hook events for wikipage: diff, categories etc..Dec 1 2015, 1:54 AM
Krinkle edited projects, added MediaWiki-Interface; removed MediaWiki-General.

Change 218275 merged by jenkins-bot:
Add a wikipage.diff hook

Not mentioned yet, but IMHO makes sense, too: #firstHeading


Is this resolved? If not what's left to do?

Not mentioned yet, but IMHO makes sense, too: #firstHeading


There are tools that modify the first heading, for example append a link to edit the lead section only. or to change the heading via JS in cases where DISPLAYTITLE can't be used (e.g. fr:J sharp), just to name two examples. These scripts should run again when the content was updated.

Jdlrobson closed this task as Resolved.Dec 15 2015, 7:55 PM
Jdlrobson claimed this task.

Not sure what is left to do. Someone should re-open and clarify in the description (preferably via checkboxes if that's not true)

TheDJ reopened this task as Open.Dec 16 2015, 1:22 PM
TheDJ removed Jdlrobson as the assignee of this task.
TheDJ updated the task description. (Show Details)
TheDJ added a project: Patch-For-Review.

Of the 4 items in the list of the description, one was marked as done. A second one is now also marked as done. There is also one patch still under review... and a 5 item was being discussed as possibly qualifying for addition to the list.

Apologies and thanks for clarifying.

Patch open is:

TheDJ added a comment.Dec 16 2015, 7:40 PM

Rebased that patch to only cover the categories case (as it is analogous to diffs). langlinks first need templates per skin probably.

Triggering wikipage.categories post-save in VisualEditor will help HotCat. However triggering it in edit preview might be unexpected in the particular case of HotCat since it probably shouldn't be creating an edit interface for categories whilst on an edit page for wikitext already (since the two would conflict). Something to consider with regards to separation of concerns.

TheDJ added a comment.Dec 16 2015, 8:48 PM

@Krinkle, probably yes, but I think that is a concern for HotCat, and not for the hook I would assume.

Change 219629 merged by jenkins-bot:
Add wikipage.categories hook

matmarex updated the task description. (Show Details)Jan 6 2016, 1:03 AM
matmarex removed a project: Patch-For-Review.

@Krinkle, probably yes, but I think that is a concern for HotCat, and not for the hook I would assume.

True, but if HotCat shouldn't use it, then that leaves the use-case question empty for this hook. Which means I may want to revert it. (It got merged meanwhile by @Jdlrobson)

TheDJ added a comment.Jan 6 2016, 9:38 PM

@Krinkle you do not think there is enough value if hotcat only hooks into this after VE saved the page ?

@Krinkle you do not think there is enough value if hotcat only hooks into this after VE saved the page ?

That is valuable, but isn't compatible with using this hook. It would either need to hardcode VE, make exceptions for preview, or simply use the 'wikipage.content' or 'postEdit' hook instead. There doesn't seem to be an appropiate way for HotCat to use 'wikipage.categories' in that case.

Hm.. might make sense to fire the Language portlet from individual skin scripts, rather than making core responsible. That also avoids shipping potentially dead code to all skins (e.g. Minerva where it wouldn't be used).

Krinkle closed this task as Resolved.Oct 2 2018, 3:52 AM
Krinkle claimed this task.
Krinkle added a project: Performance-Team.

Marking as done for now. We can consider the last point if/when we have a use case. When it comes up, I'd recommend we place the mw.hook(..).fire() code in skins.vector.js and same for other skins that want to support the hook.