Page MenuHomePhabricator

Unable to access $OutputPage::mLinktags from extensions since MW 1.24 (changed to "protected")
Closed, ResolvedPublic

Description

Since commit df49428, the $OutputPage::mLinktags property has been protected. This broke my hook code, which was inspecting the link tag array to see whether the page already had a rel=canonical tag before adding one.

This wouldn't be a big issue (as the code needed updating for MW 1.24 anyway), if there was an accessor method that I could use instead, but unfortunately no such method exists. Effectively, as far as extension code is concerned, this field is currently write-only.

I'd thus like to request that either:

  • the mLinktags (and, while we're at it, mMetatags and mCanonicalUrl) properties of the OutputPage class should be made public, or
  • accessor methods should be added to allow extension code to examine these fields.

(Ps. I managed to rewrite that particular hook not to require access to these OutputPage properties, but it's not quite as fail-safe as it used to be -- there's a chance that the new code may stomp on a rel=canonical URL set by a later MediaWiki version or another extension. In any case, I would expect these fields to be of general interest to extension authors, even if they're not strictly necessary for my specific use case.)

For a similar case about styles, see T76461.
For a similar case about mCoreRights, see T76264.
For a similar case about mLinktags, see T76168.

Event Timeline

Ilmari_Karonen raised the priority of this task from to Needs Triage.
Ilmari_Karonen updated the task description. (Show Details)
Ilmari_Karonen changed Security from none to None.
Ilmari_Karonen subscribed.

Why is this in the Core Features team's project..?

Aklapper renamed this task from Unable to access $OutputPage::mLinktags from extensions since MW 1.24 to Unable to access $OutputPage::mLinktags from extensions since MW 1.24 (changed to "protected").Dec 3 2014, 3:54 PM
Aklapper triaged this task as Low priority.
Aklapper updated the task description. (Show Details)

Having seen two complaints by 3rd party devs about turning numerous values from public into protected, I wonder if providing getter/setter() methods is something that the core team should consider rather sooner than later.
CC'ing Greg for his opinion.

Change 177256 had a related patch set uploaded (by Legoktm):
OutputPage: Add accessors for some protected properties

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

Patch-For-Review

Change 177256 merged by jenkins-bot:
OutputPage: Add accessors for some protected properties

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

Change 177290 had a related patch set uploaded (by Legoktm):
OutputPage: Add accessors for some protected properties

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

Patch-For-Review

Change 177290 merged by Legoktm:
OutputPage: Add accessors for some protected properties

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

Fixed and backported to REL1_24.