Page MenuHomePhabricator

mw.Title should provide a function to get a Title object from a URL
Open, LowPublic

Description

Like the new Title.newFromImg method a method to get the Title object for a link or its href attribute would be very useful. Such a function would have to:

  • Check that the link is a local link.
  • Get the title either from the title parameter or from the path.
  • Unescape it and create a title object.

Currently gadgets that need to determine the title for a given link mostly use the title attribute of the link (and temporarily broke on bug 542, and regularly break if other gadgets change the title, and don't work for missing pages, which have a "page does not exist" in the title). Having a function that takes care to get everything right would help very much in programming gadgets, and would make bug 38598 comment 3 really true.


Version: 1.22.0
Severity: enhancement

Details

Reference
bz56303

Event Timeline

bzimport raised the priority of this task from to Low.Nov 22 2014, 2:16 AM
bzimport set Reference to bz56303.
bzimport added a subscriber: Unknown Object (MLST).
Schnark created this task.Oct 29 2013, 9:34 AM
MarkTraceur added a subscriber: MarkTraceur.

Assigning to a new contributor...

matmarex removed Scottboydai as the assignee of this task.Jun 3 2015, 4:24 PM
matmarex set Security to None.
matmarex removed a subscriber: Unknown Object (MLST).
matmarex added a subscriber: Scottboydai.
m4tx claimed this task.Jul 5 2015, 10:34 AM

Change 222887 had a related patch set uploaded (by M4tx):
Add mw.Title.newFromLink function

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

Krinkle renamed this task from mw.Title should provide a function to get a Title object from a link to mw.Title should provide a function to get a Title object from a URL.Oct 6 2015, 9:04 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptOct 6 2015, 9:04 PM

@Jdlrobson Is there a use case you need this for? If not, I'd decline.

We would use this in VE, in a few places we get a URL from the user (e.g. when directly inserting a link, or when handling copy-pasted HTML), and we need to treat it differently if it corresponds to a page on that wiki. For example ve.dm.MWInternalLinkAnnotation.static.getTargetDataFromHref.

@Jdlrobson Is there a use case you need this for? If not, I'd decline.

Not that I currently know of. I am okay with declining.