Page MenuHomePhabricator

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

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

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).
MarkTraceur subscribed.

Assigning to a new contributor...

matmarex set Security to None.
matmarex removed a subscriber: Unknown Object (MLST).
matmarex added a subscriber: Scottboydai.

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

@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.

m4tx removed m4tx as the assignee of this task.Oct 27 2020, 3:59 PM
m4tx subscribed.
Aklapper changed the subtype of this task from "Task" to "Feature Request".Feb 4 2022, 11:13 AM
Aklapper removed a subscriber: TrevorParscal.