Page MenuHomePhabricator

add exposed JS wgRevisionId as a magic word
Closed, DeclinedPublic


Hello .. I'm using Extension:Approved Revisions [1] and I have a need to be able to display the revision ID of the page revision currently being viewed. From the MW Manual page on Javascript [2] I see that the variable "wgRevisionId" contains this information and is exposed to mediawiki for use, but it is not clear to me how to do so. I would like to create a "magic word" [3] called <code>{{VIEWEDREVID}}</code> that outputs the revision ID of the revision being viewed such that it can be used in other parser logic

For example:

{{#ifexpr:( {{VIEWEDREVID}} < {{APPROVEDREVID}} )
|if true
|if false

Can this feature be added to Approved Revisions, please. (Is it already somehow?)

Thank you!
-Rich [[User:revansx]]


Event Timeline

Revansx created this task.Oct 24 2018, 1:56 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptOct 24 2018, 1:56 PM


To get the revisionid of the shown revision you can use {{REVISIONID}}. It should be equal to the js variable. If not, the extension may handle this kind other and that sounds like a bug.

Hi Umherirrender,

HexMode explained to me that placing the revision id of the revision that the user is presently viewing (rather than simply the latest) would actually break the whole caching systems. He helped me realize that what I'm trying to do is best done in Mediawiki:Common.js. That said, I was able to write a simple JS line like this:

document.getElementById('MyDiv001').innerHTML = mw.config.get('wgRevisionId');

in Mediawiki:Common.js and get the information I needed into a wiki article. Cool!

Yaron_Koren closed this task as Declined.Dec 3 2019, 3:33 AM
Yaron_Koren added a subscriber: Yaron_Koren.

Marking this as "Declined"... I hope that's okay.

Restricted Application added a subscriber: Liuxinyu970226. · View Herald TranscriptDec 3 2019, 3:33 AM