On Sat, May 28, 2016 at 8:42 AM, Nicolas Vervelle <nvervelle@gmail.com> wrote:
I find that the result of list=backlinks for page XXX is odd when one of the backlinks is a redirect on a different page than XXX, but has also contents with a link to XXX.

See for example backlinks to en:Spin-off
https://en.wikipedia.org/w/api.php?bltitle=Spin-off&continue=&action=query&blredirect=&list=backlinks&format=xml&bllimit=max

Among the backlinks, there's for example "User talk:SummerPhD" and all pages linking to this talk page :
  • It's content contains a link to Spin-off page, so it's normal to see it.
  • It's also a redirect (bad practice to have a redirect page with contents), so all backlinks to this talk page are also listed while they have no relation at all to "Spin-off"

Is it normal to have this behaviour ?

This is the documented behavior: the description of the blredirect parameter[1] says "If linking page is a redirect, find all pages that link to that redirect as well." [[Spin-off]] is indeed linked from [[User talk:SummerPhD]], and [[User talk:SummerPhD]] is indeed a redirect.

If you're looking for actual redirects to [[Spin-off]] rather than all redirect pages that link to [[Spin-off]], you want to use prop=redirects[2] instead. You might also consider using prop=linkshere[3] instead of list=backlinks, as the former allows you to specify multiple titles at the cost of not having a "blredirect"-style subquery.

 [1]: https://en.wikipedia.org/w/api.php?modules=query+backlinks
 [2]: https://en.wikipedia.org/w/api.php?modules=query+redirects
 [3]: https://en.wikipedia.org/w/api.php?modules=query+linkshere


--
Brad Jorsch (Anomie)
Senior Software Engineer
Wikimedia Foundation