Page MenuHomePhabricator

Restore fragment in broken links
Open, LowPublic

Description

At some point, MW started stripping the URL's fragment of broken links (= red links); as a result, a link to a non-existent [[asdf#fragment]] target title and the specified section would render as /w/index.php?title=asdf&action=edit&redlink=1 (note that the section is omitted). However, some JS scripts could still take advantage of that currently missing #fragment bit. This is the case of a plwiktionary's popular gadget, running since 2011: one of its features consisted in generating a customized edit form for a new language section, according to the specified fragment of a link pointing to a missing title. We noticed that this used to work some time ago, hence the Regression tag.

Event Timeline

PeterBowman raised the priority of this task from to Needs Triage.
PeterBowman updated the task description. (Show Details)
PeterBowman subscribed.

Possibly related code in Linker.php:

private static function linkUrl( $target, $query, $options ) {
    # We don't want to include fragments for broken links, because they
    # generally make no sense.
    if ( in_array( 'broken', $options ) && $target->hasFragment() ) {
        $target = clone $target;
        $target->setFragment( '' );
    }

    ...