Page MenuHomePhabricator

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

Description

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

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 1:43 AM
bzimport set Reference to bz51583.

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 http://lists.wikimedia.org/pipermail/wikitech-l/2013-September/072030.html "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 set Security to None.

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 ?

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

https://gerrit.wikimedia.org/r/218275

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

https://gerrit.wikimedia.org/r/219629

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

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-User-Interface; removed MediaWiki-General.

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

https://gerrit.wikimedia.org/r/218275

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

Why?

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

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

Why?

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 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 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.

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.

@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

https://gerrit.wikimedia.org/r/219629

@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)

@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 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.

Although this certainly has been discussed somewhere already, I'd suggest adding classes .mw-diff and .mw-catlinks, that would be used instead of table.diff and .catlinks respectively (of course, keeping these for BC).

And we could still keep the [data-mw="interface"] attributes, for cases we want to be really sure to avoid matching user-generated markup.

Refs https://github.com/wikimedia/mediawiki/commit/b1e3f9e38d7c74e080e99e58dac55629b9f0b097