Last modified: 2008-12-18 19:54:07 UTC

Wikimedia Bugzilla is closed!

Wikimedia has migrated from Bugzilla to Phabricator. Bug reports should be created and updated in Wikimedia Phabricator instead. Please create an account in Phabricator and add your Bugzilla email address to it.
Wikimedia Bugzilla is read-only. If you try to edit or create any bug report in Bugzilla you will be shown an intentional error message.
In order to access the Phabricator task corresponding to a Bugzilla report, just remove "static-" from its URL.
You could still run searches in Bugzilla or access your list of votes but bug reports will obviously not be up-to-date in Bugzilla.
Bug 6158 - Using Linker::makeKnownLink("interwiki:Page#anchor") gives repeated anchor
Using Linker::makeKnownLink("interwiki:Page#anchor") gives repeated anchor
Status: RESOLVED FIXED
Product: MediaWiki
Classification: Unclassified
General/Unknown (Other open bugs)
1.7.x
All All
: Low normal (vote)
: ---
Assigned To: Nobody - You can work on this!
: patch
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2006-06-01 08:23 UTC by Phil Harnish
Modified: 2008-12-18 19:54 UTC (History)
0 users

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments
Patches one line of Linker.php (902 bytes, patch)
2006-06-01 08:25 UTC, Phil Harnish
Details

Description Phil Harnish 2006-06-01 08:23:56 UTC
This does not seem to affect ordinary MediaWiki operation.

Steps to reproduce:
$sk  =&$wgUser->getSkin();
$ret = $sk->makeKnownLink('Wikipedia:Main Page#Anchor');
(Any interwiki link will do)

$ret contains:
<a href="http://en.wikipedia.org/wiki/Main_Page#anchor#anchor"
title="wikipedia:Main Page">wikipedia:Main Page</a>

This is because Linker::makeKnownLinkObj uses Title::escapeLocalURL which is
documented to *not* add a fragment. However, after Title checks if
$this->isExternal(), it calls getFullURL(). Unlike getLocalURL(), getFullURL()
includes the fragment. Then Linker::makeKnownLinkObj adds a second anchor before
returning.

Patch in the next comment.
Comment 1 Phil Harnish 2006-06-01 08:25:31 UTC
Created attachment 1872 [details]
Patches one line of Linker.php

Patches one line of Linker.php

May be better to use escapeFullURL() instead? I cannot predict the
reprocussions of that.
Comment 2 Brion Vibber 2006-06-01 08:25:49 UTC
Note that makeKnownLink (non-obj) is deprecated.
Comment 3 Phil Harnish 2006-06-01 08:35:09 UTC
I did not realize that. This should still produce the bug:
$sk  =&$wgUser->getSkin();
echo $sk->makeKnownLinkObj(Title::newFromText('Wikipedia:Main Page#anchor'));

I take back the suggestion to use "escapeFullURL" *instead*. That would make
absolute URLs when shorter ones would do.

Adding keyword 'patch'
Comment 4 Rob Church 2006-06-01 10:16:13 UTC
It's marked as "deprecated - do not use" in the code.
Comment 5 Rob Church 2006-06-08 13:00:19 UTC
(In reply to comment #3)
> I did not realize that. This should still produce the bug:
> $sk  =&$wgUser->getSkin();
> echo $sk->makeKnownLinkObj(Title::newFromText('Wikipedia:Main Page#anchor'));

"#" isn't a valid character in page titles, so that would produce a very
interesting error, since Title::newFromText() would choke and return NULL.
Comment 6 Brion Vibber 2006-06-08 20:00:15 UTC
# is the separator between primary title and fragment ID, which 
will be parsed by the title object.
Comment 7 Brion Vibber 2008-12-18 19:54:07 UTC
This is working ok for me in current 1.14 dev trunk:

> return $wgUser->getSkin()->makeKnownLink('Project:Main Page#Anchor');
<a href="/trunk/index.php/ShortWiki:Main_Page#Anchor" title="ShortWiki:Main Page">ShortWiki:Main Page</a>

I believe that makeKnownLink() and friends have been redone to run through the more modern funcs using the title objs, and everything is now parsed correctly.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links