Page MenuHomePhabricator

Reply links disappear after replying, and reply is not highlighted, when replying to a transcluded comment
Closed, ResolvedPublic

Description

Reply links disappear after replying, and reply is not highlighted, when replying to a transcluded comment.

Example page: https://en.wikipedia.beta.wmflabs.org/wiki/Talk:T266195

image.png (2×3 px, 414 KB) image.png (2×3 px, 584 KB)

Also, an exception occurs:

jQuery.Deferred exception: Cannot read property 'replies' of undefined TypeError: Cannot read property 'replies' of undefined
    at Object.init (...:6:633)
    at mw.dt.init (...:1:366)
    at fire (...:279:209)
    at Object.add (...:279:710)
    at ...:8:21
    at mightThrow (...:282:149)
    at process (...:282:808)

Event Timeline

matmarex added a subscriber: Esanders.

This is because when replying to transcluded comments, we update the page after saving using action=parse output, and it does not include our server-generated reply links. The exception occurs because we can't find the reply to highlight.

Note that everything else works correctly, the comments are posted in the right place etc.

We fixed in the VE API by ensuring the OutputPageBeforeHTML hooks runs on the content. We should either do the same in the core API (with an option param), or do this update via the VE API.

Looks like there's this in ApiParse.php:

if ( $skin || isset( $prop['headhtml'] ) || isset( $prop['categorieshtml'] ) ) {
	// Enabling the skin via 'useskin', 'headhtml', or 'categorieshtml'
	// gets OutputPage and Skin involved, which (among others) applies
	// these hooks:
	// - ParserOutputHooks
	// - Hook: LanguageLinks
	// - Hook: OutputPageParserOutput
	// - Hook: OutputPageMakeCategoryLinks
	$context = new DerivativeContext( $this->getContext() );
	$context->setTitle( $titleObj );
	$context->setWikiPage( $pageObj );

We should probably be using the useskin param to get the correct list of modules back.

Change 635828 had a related patch set uploaded (by Esanders; owner: Esanders):
[mediawiki/core@master] ApiParse: Run OutputPageBeforeHTML when in 'skin' mode

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

Change 635829 had a related patch set uploaded (by Esanders; owner: Esanders):
[mediawiki/extensions/DiscussionTools@master] Set 'useskin' when using API action=parse

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

Change 635830 had a related patch set uploaded (by Esanders; owner: Esanders):
[mediawiki/extensions/VisualEditor@master] No longer run OutputPageBeforeHTML hook now it happens in core

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

We should probably be using the useskin param to get the correct list of modules back.

If useskin is set, uselang would make sense, too, wouldn’t it?

The API already uses the user language, so setting it wouldn't change behaviour (except maybe if the user was debugging with the uselang= param). That said adding it would be harmless.

Setting useskin triggers a different codepath that results in various hooks being run. I'm not sure this is the best functionality, but it is what it is.

Change 635829 merged by jenkins-bot:
[mediawiki/extensions/DiscussionTools@master] Set 'useskin' when using API action=parse

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

Change 635828 merged by jenkins-bot:
[mediawiki/core@master] ApiParse: Run OutputPageBeforeHTML when in 'skin' mode

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

Change 635830 merged by jenkins-bot:
[mediawiki/extensions/VisualEditor@master] No longer run OutputPageBeforeHTML hook now it happens in core

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

The API already uses the user language, so setting it wouldn't change behaviour (except maybe if the user was debugging with the uselang= param). That said adding it would be harmless.

Although I haven’t missed it in DT yet, I made use of this several times using the live preview—when I want to check something in connection with i18n, it’s much faster to just append the URL parameter than to set the language in Preferences/ULS.

Setting useskin triggers a different codepath that results in various hooks being run. I'm not sure this is the best functionality, but it is what it is.

What the…? I would have been certain that useskin=vector and passing nothing is the same if the user/site has Vector set as the default skin.

Change 636002 had a related patch set uploaded (by Esanders; owner: Esanders):
[mediawiki/extensions/DiscussionTools@master] Pass uselang with API requests

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

Change 636002 merged by jenkins-bot:
[mediawiki/extensions/DiscussionTools@master] Pass uselang with API requests

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

Setting useskin triggers a different codepath that results in various hooks being run. I'm not sure this is the best functionality, but it is what it is.

What the…? I would have been certain that useskin=vector and passing nothing is the same if the user/site has Vector set as the default skin.

It behaves differently in the API than in the normal interface. With the action=parse API and no useskin, the API is supposed to not generate some skin-specific elements at all, kind of like action=render in the normal interface. But it ends up having a lot of weird consequences.