Page MenuHomePhabricator

localurl discards section id
Open, LowPublic

Description

Author: jim

Description:
{{localurl:User:Bob#section}} discards the '#section' part in building the local URL.

That seems inconsistent with {{fullurl:User:Bob#section}} which keeps it.


Version: 1.15.x
Severity: minor

Details

Reference
bz24343

Event Timeline

bzimport raised the priority of this task from to Low.Nov 21 2014, 11:06 PM
bzimport added a project: MediaWiki-Parser.
bzimport set Reference to bz24343.
bzimport added a subscriber: Unknown Object (MLST).

#section is known as a fragment.
Title::getLocalURL() does not return the fragment. To get it, one should use Title::getLinkUrl().

Committed in trunk as r73976

(In reply to comment #1)

#section is known as a fragment.
Title::getLocalURL() does not return the fragment. To get it, one should use
Title::getLinkUrl().

Committed in trunk as r73976

You added a new magic word instead of fixing the current one? I don't understand.

To me getLocalURL() and getLinkUrl() are two different functions and deserve differents magic word.

But what's the usecase for having a magic word which strips the fragment?

Since Title has two functions, I though we could have two magic words as well.

One possibility was to map {{localurl:}} with Title::getLinkUrl() instead of Title::getLocalURL(), but that looks weird and inconsistent.

(In reply to comment #7)

Since Title has two functions, I though we could have two magic words as well.

One possibility was to map {{localurl:}} with Title::getLinkUrl() instead of
Title::getLocalURL(), but that looks weird and inconsistent.

I think you should re-read the opening post. :-)

"{{localurl:User:Bob#section}}" returns "/wiki/User:Bob". This is wrong. This is the bug. Instead, "{{localurl:User:Bob#section}}" should return "/wiki/User:Bob#section", just like {{fullurl:}} does currently. (And "{{localurl:User:Bob#section|action=edit}}" should return "/w/index.php?title=User:Bob&action=edit#section".)

I can't see any reason {{localurl:}} would intentionally strip the section anchor.

If there are use-cases for other magic words, I think they should be the topic of other bugs. This one is about {{localurl:}} stripping the section anchor needlessly and unexpectedly.

patch r73976 reverted with r75250

Aklapper changed the task status from Duplicate to Resolved.Mar 9 2019, 5:08 PM