Page MenuHomePhabricator

Provide consistent normalised title information in PHP output for "backlinks" and "imageinfo" operations
Closed, InvalidPublic

Description

Author: marco

Description:
When using the link as shown above (with localized name spaces!!!), there is no
information about the page ID delivered in the serialized PHP output, only a
index key in the array which sizeof() can't detect. This renders the backlink
function pretty unusable as I can't access the page's backlinks.

Strange is, if you use English namespace names like in
http://de.wikipedia.org/w/query.php?what=backlinks&titles=User:HardDisk&bllimit=11&format=php
the page ID is delivered at $array["pages"][-1]["refid"].


Version: unspecified
Severity: minor
URL: http://de.wikipedia.org/w/query.php?what=backlinks&titles=Benutzer:HardDisk&bllimit=11&format=php

Details

Reference
bz8959

Event Timeline

bzimport raised the priority of this task from to Low.Nov 21 2014, 9:32 PM
bzimport set Reference to bz8959.
bzimport added a subscriber: Unknown Object (MLST).

robchur wrote:

Referring to http://mediawiki.pastey.net/6500, which is the result of print_r(
unserialize( <contents of URL in URL field> ) ), it's quite obvious that there
is an easily accessible page identifier, and this is duplicated, in fact, so
it's quite possible to access the information required.

I'm guessing that the information Marco's talking about is injected to indicate
any applicable namespace translations between languages and so forth, and so
won't be present when viewing the thing in German. We should *probably* be
consistent about providing this.

marco wrote:

Well, you cannot access the page ID that easily. It is hidden in itself (lines
160/164 at http://mediawiki.pastey.net/6501), so you cannot access them without
a really huge mess with foreach.

marco wrote:

Same thing is going on with imageinfo. Again, here the image ID is hidden in
itself when the name supplied is English namespace.

marco wrote:

Same thing is going on with imageinfo. Again, here the image ID is hidden in
itself when the name supplied is English namespace.

So if I understand you well, you are complaining about the fact that

Array (

[12345] => Array(
    [pageid] => 12345
    etc.
)

)
(rough sketch)

hides the pageid inside the pageid. This is true. But you may be forgetting that backlinks can take multiple page titles:

http://de.wikipedia.org/w/query.php?what=backlinks&titles=User:HardDisk|User%20talk:HardDisk&bllimit=11

in which case the result looks like:

Array (

[12345] => Array(
    [pageid] => 12345
    [title] => User:HardDisk
    more info
)
[130569] => Array(
    [pageid] => 130569
    [title] => User talk:HardDisk
)

)

So you will *have* to foreach() the pages array, which contains only one element if you specified one title (or two if the title had to be localized). Foreach()ing on a one-element array doesn't sound that horrible to me, especially considering what=backlinks is designed to be usable for multiple targets in one request.

Closing as INVALID. If you still have complaints, please reopen this bug.