Page MenuHomePhabricator

please add scribunto function title:getTranscluded()
Open, Needs TriagePublic

Description

returned value: table listing transcluded pages. if possible, in a tree form of some sort:

{ 
    ['trans 1'] = {}, 
    ['trans 2'] = { ['trans trans 1'] = {} }
}

where the keys are full pages names, acceptable by maketitle functions.

example usecase:
allow scribunto modules to read transcluded pages, in order to look into sources for extensions enclosed in tags ("note", "graph" et al).

peace.

Event Timeline

Kipod created this task.Mar 28 2016, 3:07 AM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptMar 28 2016, 3:07 AM
Anomie added a subscriber: Anomie.Mar 28 2016, 11:14 AM

Recursive transclusions are unlikely to be at all well-performing. Even
fetching one level should probably be considered expensive, and should have
a limit of some sort so it doesn't explode when someone asks for
transclusions of Template:Citation_needed.

Can you make it clearer what you're asking for? I'm not sure if you want all pages that transclude a page, or all pages that are transcluded by a page.

Kipod added a comment.EditedApr 2 2016, 6:17 PM

Recursive transclusions are unlikely to be at all well-performing. Even
fetching one level should probably be considered expensive, and should have
a limit of some sort so it doesn't explode when someone asks for
transclusions of Template:Citation_needed.

i think this is a misunderstanding. the request was not for "all pages transcluding template X", but rather for "all pages *transcluded in* page X". i can't think of a way for this to "explode".

i can see the "recursive" part can be difficult to control, although i don't think "explosive":
for instance, when opening any page in the source editor, we get a list of transcluded pages (including invoked modules), and this list is basically the tree i asked for, simply flattened.
can't recall seeing a page where this list explodes.

in the original request i wrote "if possible, in a tree form of some sort...", implying that if it isn't possible, a list of pages transcluded directly will also be much appreciated.

scribunto calls are resource-bounded, so any actual use that abuses system resources, will eventually fail.
IMO, this is good enough to prevents abuse: things that do not work are not widely deployed.

Can you make it clearer what you're asking for? I'm not sure if you want all pages that transclude a page, or all pages that are transcluded by a page.

@Jackmcbarn: i thought i was clear, and i hope my reply to anomie clears it further: the request is for list of pages *transcluded* in a given page, not those transcluding it.

peace.

The problem with listing all pages transcluded on a given page is that it can't be accurate on a given page. Imagine if it were, and someone created a template called "IsTranscluded", that returned whether a given template was transcluded on a given page. Then suppose a page called {{#if:{{IsTranscluded|{{FULLPAGENAME}}|Template:Foobar}}||{{Foobar}}}}. Now the result of that will never be accurate.

Anomie added a comment.Apr 3 2016, 6:25 AM

in the original request i wrote "if possible, in a tree form of some sort...", implying that if it isn't possible, a list of pages transcluded directly will also be much appreciated.

It isn't possible, transclusion records are stored as a flat list (e.g. Page A transcludes template B which transcludes template C, it just records A→B and A→C with no distinction that A→C is not direct).

A flat list would work, although it would need a limit so it won't use excessive resources if a page has a huge number of templates, and possibly continuation. Each call would likely have to count as expensive.

Kipod added a comment.Apr 4 2016, 3:06 PM

in the original request i wrote "if possible, in a tree form of some sort...", implying that if it isn't possible, a list of pages transcluded directly will also be much appreciated.

It isn't possible, transclusion records are stored as a flat list (e.g. Page A transcludes template B which transcludes template C, it just records A→B and A→C with no distinction that A→C is not direct).

A flat list would work, although it would need a limit so it won't use excessive resources if a page has a huge number of templates, and possibly continuation. Each call would likely have to count as expensive.

both limitations are acceptable, even with hardcoded limit on list size, as long as the returned structure has some way to indicate "incomplete".

in the original request i wrote "if possible, in a tree form of some sort...", implying that if it isn't possible, a list of pages transcluded directly will also be much appreciated.

It isn't possible, transclusion records are stored as a flat list (e.g. Page A transcludes template B which transcludes template C, it just records A→B and A→C with no distinction that A→C is not direct).

A flat list would work, although it would need a limit so it won't use excessive resources if a page has a huge number of templates, and possibly continuation. Each call would likely have to count as expensive.

fair enough. IMO, a small comment in the doc claiming that if current page invoked is the target, or is transcluded in the target, the result is no deterministic. it may be worthwhile to include another field in the returned structure indicating this state.

peace.