(bug 23427) PAGEID magic word
authorWaldir Pimenta <waldir@email.com>
Sat, 2 Jun 2012 16:58:31 +0000 (18:58 +0200)
committerAntoine Musso <hashar@free.fr>
Fri, 22 Jun 2012 08:56:01 +0000 (10:56 +0200)
Please note on preview of a new page, this magic word will return 0 so
we have to set the vary-revision flag.

Change-Id: I11d42ca773ad84b73cc84f2c7dd2d09f1982d97a

RELEASE-NOTES-1.20
includes/MagicWord.php
includes/parser/Parser.php
languages/messages/MessagesEn.php

index ecae5de..1577b14 100644 (file)
@@ -72,6 +72,8 @@ upgrade PHP if you have not done so prior to upgrading MediaWiki.
   them.
 * Added new hook ChangePasswordForm to allow adding of additional fields in Special:ChangePassword
 * Added new function getDomain to AuthPlugin for getting a user's domain
+* (bug 23427) New magic word {{PAGEID}} which gives the current page ID.
+  Will be null on previewing a page being created.
 
 === Bug fixes in 1.20 ===
 * (bug 30245) Use the correct way to construct a log page title.
index f838ad0..9745b9a 100644 (file)
@@ -99,6 +99,7 @@ class MagicWord {
                'numberoffiles',
                'numberofedits',
                'articlepath',
+               'pageid',
                'sitename',
                'server',
                'servername',
index 4beb8fd..7bd2aab 100644 (file)
@@ -2720,6 +2720,18 @@ class Parser {
                                $subjPage = $this->mTitle->getSubjectPage();
                                $value = wfEscapeWikiText( $subjPage->getPrefixedUrl() );
                                break;
+                       case 'pageid': // requested in bug 23427
+                               $pageid = $this->getTitle()->getArticleId();
+                               if( $pageid == 0 ) {
+                                       # 0 means the page doesn't exist in the database,
+                                       # which means the user is previewing a new page.
+                                       # The vary-revision flag must be set, because the magic word
+                                       # will have a different value once the page is saved.
+                                       $this->mOutput->setFlag( 'vary-revision' );
+                                       wfDebug( __METHOD__ . ": {{PAGEID}} used in a new page, setting vary-revision...\n" );
+                               }
+                               $value = $pageid ? $pageid : null;
+                               break;
                        case 'revisionid':
                                # Let the edit saving system know we should parse the page
                                # *after* a revision ID has been assigned.
index 86954ba..a0b044e 100644 (file)
@@ -288,7 +288,8 @@ $magicWords = array(
        'nse'                    => array( 0,    'NSE:'                   ),
        'localurl'               => array( 0,    'LOCALURL:'              ),
        'localurle'              => array( 0,    'LOCALURLE:'             ),
-       'articlepath'            => array( 0,    'ARTICLEPATH'            ),
+       'articlepath'            => array( 0,    'ARTICLEPATH'            ),
+       'pageid'                 => array( 0,    'PAGEID'                 ),
        'server'                 => array( 0,    'SERVER'                 ),
        'servername'             => array( 0,    'SERVERNAME'             ),
        'scriptpath'             => array( 0,    'SCRIPTPATH'             ),