Page MenuHomePhabricator

Add redirecting page based wg variable(s) to page JS variables
Closed, ResolvedPublic

Description

If the page is the target of redirect (user sees "redirected from Foo" message), it would be handy to have variables

  • wgRedirPageName
  • wgRedirTitle
  • wgRedirCanonicalNamespace
  • wgRedirNamespaceNumber

as complements to existing appropriate variables.


Version: unspecified
Severity: enhancement

Details

Reference
bz11040

Event Timeline

bzimport raised the priority of this task from to Low.Nov 21 2014, 9:53 PM
bzimport added a project: MediaWiki-Parser.
bzimport set Reference to bz11040.
bzimport added a subscriber: Unknown Object (MLST).

alexsm333 wrote:

Would it add something that you cannot get from document.getElementById('contentSub').getElementsByTagName('a')[0] (and then maybe some API calls)?

jlerner wrote:

Four simple functions that make redirected page information available in Skin.php as JavaScript variables

attachment Article.php.patch.bug11040 ignored as obsolete

jlerner wrote:

Add four new JavaScript variables to makeVariablesScript()

attachment Skin.php.patch.bug11040 ignored as obsolete

  • Bug 16028 has been marked as a duplicate of this bug. ***

sylvain.brunerie wrote:

@AlexSm: I think many of the "wg-" JS variables don't give informations that we cannot get by using DOM or API (wgServer, wgUserName, wgUserLanguage, wgVersion...). But it's more simple and "elegant" to use generated JS variables, isn't it?

*Bulk BZ Change: +Patch to open bugs with patches attached that are missing the keyword*

sumanah wrote:

Adding the "need-review" keyword for patches that need review by developers. Joshua, thank you for your patches, and sorry it's taken so long for a response on this!

Created attachment 9501
Revised patch

Attaching a revised patch.

Changes relative to the original patch:

  • Applies to MW as it is now rather than as it was four years ago :)
  • Introduces only one Article getter and one variable. JS only needs the full title text, we've got mw.Title to figure out the rest (namespace number etc) on the JS side if you need it

Not committing this because it uses $wgArticle, which is very much deprecated and not used in trunk. However, RequestContext doesn't have an Article, so I'm not sure how to proceed here. Should the redirected from stuff be moved into OutputPage or something?

Thoughts?

Attached:

CC Chad in the hope he'll advise re comment 8.

Maybe something along the lines of a $out->setRedirectedFrom. Perhaps that can also set the subtitle implicitly. Then Article can call the OutputPage function where needed.

(In reply to comment #10)

Maybe something along the lines of a $out->setRedirectedFrom. Perhaps that can
also set the subtitle implicitly. Then Article can call the OutputPage function
where needed.

Yeah, I was thinking refactoring in that direction would probably be best.

(In reply to comment #11)

(In reply to comment #10)

Maybe something along the lines of a $out->setRedirectedFrom. Perhaps that can
also set the subtitle implicitly. Then Article can call the OutputPage function
where needed.

Yeah, I was thinking refactoring in that direction would probably be best.

Turns out someone has already done this on bug 32230. Duping up because the patch on that bug is better.

  • This bug has been marked as a duplicate of bug 32230 ***