Page MenuHomePhabricator

VisualEditor hangs after producing a null title for an internal link
Closed, DeclinedPublic1 Estimated Story Points


I have an extension that produces a valid link using the Linker class, but this link causes VisualEditor to hang. This problem is new since we upgraded to MediaWiki 1.27 from 1.26.

The rendered HTML of the link is:

<a href="/w/index.php?title=Special:CodeView&amp;;platform=bar" title="View this code" target="_blank">foo</a>

When VisualEditor tries to load on a page with this link, it throws an error about a null title:

TypeError: Cannot read property 'toText' of null(...)

Apparently, the function (in file modules/ve-mw/dm/annotations/ is getting confused by this link. The function correctly detects that the link is internal (setting isInternal = true), but then it comes to the final test:

// The href is simply the title, unless we're dealing with a page that has slashes in its name
// in which case it's preceded by one or more instances of "./" or "../", so strip those
matches = href.match( /^((?:\.\.?\/)*)(.*)$/ );
return { title: matches[ 2 ], hrefPrefix: matches[ 1 ], isInternal: isInternal };

Here, the href is not "simply the title." As a result, matches[2] is set to null, causing the calling function ( to blow up on the first line, because title is null.

var target = title.toText()

Here is the approximate PHP code we use to render the link, so you know it's kosher:

public function doRender() {
	$title = SpecialPage::getTitleFor('CodeView');
	$url = 'http://whatever...';
	$attribs = array(
		'target' => '_blank',
		'title' => wfMessage( 'whatever' )->text(),
	$query = array(
		'path' => $url,
		'platform' => 'whatever',n
	return Linker::link( $title, $linkText, $attribs, $query );

Are we doing something wrong, or is the VisualEditor code not handling this link properly? Thank you.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptNov 22 2016, 6:12 PM

If I use the same PHP code but keep the querystring empty ($query = array()), VisualEditor loads without any errors.

maiden_taiwan added a comment.EditedNov 22 2016, 6:52 PM

A-ha. Got it. If the link's query string contains "http", the VisualEditor code hangs. My link's query string includes:


If I remove the "http", VisualEditor loads.

Jdforrester-WMF triaged this task as Low priority.Nov 22 2016, 8:08 PM
Jdforrester-WMF moved this task from To Triage to TR0: Interrupt on the VisualEditor board.
Jdforrester-WMF set the point value for this task to 1.

This problem no longer occurs in MediaWiki 1.28.0, with the Linker class (deprecated) replaced by calls to LinkRenderer.

maiden_taiwan closed this task as Declined.Jan 10 2017, 6:49 PM