From: Waldir Pimenta Date: Sat, 2 Jun 2012 16:58:31 +0000 (+0200) Subject: (bug 23427) PAGEID magic word X-Git-Tag: 1.31.0-rc.0~23263 X-Git-Url: https://git.cyclocoop.org/%242?a=commitdiff_plain;h=0a7cf03e75cd6751711b24b1e74328e7da329515;p=lhc%2Fweb%2Fwiklou.git (bug 23427) PAGEID magic word 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 --- diff --git a/RELEASE-NOTES-1.20 b/RELEASE-NOTES-1.20 index ecae5debd6..1577b149b6 100644 --- a/RELEASE-NOTES-1.20 +++ b/RELEASE-NOTES-1.20 @@ -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. diff --git a/includes/MagicWord.php b/includes/MagicWord.php index f838ad0134..9745b9ada2 100644 --- a/includes/MagicWord.php +++ b/includes/MagicWord.php @@ -99,6 +99,7 @@ class MagicWord { 'numberoffiles', 'numberofedits', 'articlepath', + 'pageid', 'sitename', 'server', 'servername', diff --git a/includes/parser/Parser.php b/includes/parser/Parser.php index 4beb8fdad5..7bd2aabddc 100644 --- a/includes/parser/Parser.php +++ b/includes/parser/Parser.php @@ -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. diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 86954ba4d7..a0b044ed62 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -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' ),