Page MenuHomePhabricator

Page Curation toolbar fails to fire wikipage.content hook when adding content
Open, Needs TriagePublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

  • Open an unreviewed page so the Page Curation toolbar (page triage) appears.
  • Use a user script that listens to the wikipage.content hook.
  • Click the "Info" (i) button in the toolbar to load the article information and history.

What happens?:

The page information content is dynamically added into the .mwe-pt-tool-content container, but the wikipage.content hook is not fired. Any script or gadget relying on that hook to process new links or content is unable to detect the update. This prevents scripts and gadgets that perform functions such as highlighting blocked users, adding content previews, etc. from working within the Page Curation toolbar.

What should have happened instead?:

The extension should call mw.hook('wikipage.content').run($content) when new content is added to the DOM.

That applies to all content additions by the Page Curation toolbar, not just the "Info" button.

Software version (on Special:Version page; skip for WMF-hosted wikis like Wikipedia):

English Wikipedia

Other information (browser name/version, screenshots, etc.):

When the "Info" button is clicked, this:

<div class="mwe-pt-tool-content">
		<!-- content goes here -->
	</div>

is updated to something like this:

<div class="mwe-pt-tool-content"><!-- basic article information -->
<div class="mwe-pt-info-basic">
	<!-- status icon -->
	<div class="mwe-pt-info-status-icon">
		
			<img src="/w/extensions/PageTriage/modules/ext.pageTriage.toolbar/images/pageInfo/icon_reviewed.png" width="21" height="21" title="This page has been reviewed.">
		
	</div>
	<!-- page status  -->
	<div class="mwe-pt-info-page-status">
		<p>Marked as reviewed on 19 April 2026 by <a href="//en.wikipedia.org/wiki/User:CostalCal" class="">CostalCal</a> (<a href="//en.wikipedia.org/wiki/User_talk:CostalCal" class="">talk</a> | <a href="//en.wikipedia.org/wiki/Special:Contributions/CostalCal" class="">contribs</a>)</p>
		<!-- talk page comments exist -->
		
	</div>
	<!-- author info -->
	<span class="mwe-pt-author">
		
			This page was created on 19 April 2026 by <a href="//en.wikipedia.org/wiki/User:CoryGlee" class="">CoryGlee</a> (<a href="//en.wikipedia.org/wiki/User_talk:CoryGlee" class="">talk</a> | <a href="//en.wikipedia.org/wiki/Special:Contributions/CoryGlee" class="">contribs</a>)
			<div>
				<!-- if user is registered (user_id is 0 for IP users) -->
				
					14624 edits since 10 July 2019
				
			</div>
		
	</span>
	<div class="mew-pt-info-stat">
		Stats: 7580 bytes · 2 edits · 10 categories
	</div>
</div>
<br>

<!-- possible problems section -->


<!-- history section -->
<div class="mwe-pt-info-header">
	History
	<span class="mwe-pt-info-header-details">
		2 edits ·
		<a href="https://en.wikipedia.org/w/index.php?title=2026_state_visit_by_Javier_Milei_to_Israel&amp;action=history">show full history</a> ·
		<a href="https://en.wikipedia.org/w/index.php?title=Special:Log&amp;page=2026_state_visit_by_Javier_Milei_to_Israel">show logs</a>
	</span>
</div>
<div class="mwe-pt-info-content" id="mwe-pt-info-history-container"><div id="mwe-pt-info-history"><span class="mwe-pt-info-history-date">

	19 April 2026

</span>
<li class="mwe-pt-info-history-entry">
	<!-- TODO(sohom): This section seems to not be in line with what is shown in MediaWiki history,
	we should clean this up and have it reflect the styles used in the MediaWiki history page -->
	
		
			<a href="/w/index.php?title=2026_state_visit_by_Javier_Milei_to_Israel&amp;oldid=1349970605">18:24</a> ·
			<a href="/wiki/User:CoryGlee">CoryGlee</a>
			
		
		
	
</li>
<span class="mwe-pt-info-history-date">

</span>
<li class="mwe-pt-info-history-entry">
	<!-- TODO(sohom): This section seems to not be in line with what is shown in MediaWiki history,
	we should clean this up and have it reflect the styles used in the MediaWiki history page -->
	
		
			<a href="/w/index.php?title=2026_state_visit_by_Javier_Milei_to_Israel&amp;oldid=1349970512">18:24</a> ·
			<a href="/wiki/User:CoryGlee">CoryGlee</a>
			
		
		
			· creating // I will ad pictures and stylize dates when it is over
		
	
</li>
</div></div>
</div>

without the wikipage.content hook firing.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Are we sure the wikipage.content JS hook is supposed to fire for content outside of #mw-content-text? The docs say Fired when wiki content has been added to the DOM.. Is the Page Curation toolbar "wiki content", or does that word refer to stuff in the parsed wikicode area of the DOM?

The toolbar Info includes content that's almost always part of #mw-content-text: various standard links for the page creator, and the page history. Scripts that use and modify those elements generally monitor the wikipage.content hook.

I take advantage of this in several of my user scripts. For example, https://en.wikipedia.org/wiki/User:Daniel_Quinlan/Scripts/Blame.js fires wikipage.content so usernames are processed by any user highlighter, block-marking, etc., scripts that use that hook. Blame isn't really part of the page content, though, and I also don't put it inside of #mw-content-text. It's a dialog that's more like the Page Curation toolbar.

It might make sense to use a different general-purpose hook for this although I don't see an applicable one in https://doc.wikimedia.org/mediawiki-core/master/js/Hooks.html. Perhaps something like a wikipage.overlay hook would work well for this case as well as other gadgets and scripts.

I'm in team "we shouldn't do this". The wikipage.content hook, to my understanding, was typically used for "this content loaded is either a preview or loaded user-gen content from a different page". PageTriage does not do any previewing for the most part and so would be abusing the hook itself (imo). If we really do need to signal to outside scripts, every time anything gets loaded we should ideally use a custom hook.

to load the article information and history

that's not article content. so it should use its own hook.

There is a desire for a 'one hook to fix all the things I want to do' tendency among people, but the reality is that this is simply not possible. If people want to customize specific parts of the page, they will have to hook into specific hooks for those specific areas and handle it separately with another hook handler. wikipage.content is NOT page ready. The problem is often that these hooks do not exist.

The primary areas covered by wikipage.content should be:

  • the main content generated by wikitext
  • the indicators of the main content
  • the preview content
  • VE post save
  • Live editor preview of wikitexteditor

There are many good arguments against using wikipage.content for this purpose and I agree with them.

Putting that aside, a common hook for this type of wikipage updates that include user links, page links, etc. would be useful for scripts and gadgets. As mentioned above:

It might make sense to use a different general-purpose hook for this although I don't see an applicable one in https://doc.wikimedia.org/mediawiki-core/master/js/Hooks.html. Perhaps something like a wikipage.overlay hook would work well for this case as well as other gadgets and scripts.

I'll copy some of these comments over to T394707: Do something about misconceptions of the wikipage.content hook. I think that's a better spot to discuss adding a broad new MediaWiki hook, or better documenting what the wikipage.content hook does.