r76937 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r76936‎ | r76937 | r76938 >
Date:02:29, 18 November 2010
Author:yaron
Status:deferred
Tags:
Comment:
Two bug fixes: a hack-ish fix so that pages being edited with the Semantic Forms extension get their contents saved correctly, and a fix so that the latest revision, when it's different from the approved one, gets displayed correctly with MW >= 1.17.
Modified paths:
  • /trunk/extensions/ApprovedRevs/ApprovedRevs.hooks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ApprovedRevs/ApprovedRevs.hooks.php
@@ -20,6 +20,18 @@
2121 static public function setApprovedRevForParsing( &$parser, &$text, &$stripState ) {
2222 global $wgRequest;
2323 if ( $wgRequest->getCheck( 'wpSave' ) ) {
 24+ // @HACK !! If the Semantic Forms extension is being
 25+ // used, the form will be parsed right before the page
 26+ // is parsed, and there doesn't seem to be any way
 27+ // to determine, from within this hook function,
 28+ // which one is being parsed at the moment - we only
 29+ // want to modify the parsing of the main page, not
 30+ // of the form page. So look for a string that should
 31+ // appear in every form page, but should really never
 32+ // appear in non-form pages - '{{{for template'.
 33+ if ( strpos( $text, '{{{for template' ) !== false ) {
 34+ return true;
 35+ }
2436 $title = $parser->getTitle();
2537 if ( ! ApprovedRevs::pageIsApprovable( $title ) ) {
2638 return true;
@@ -137,6 +149,15 @@
138150
139151 global $wgRequest;
140152 if ( $wgRequest->getCheck( 'oldid' ) ) {
 153+ // If the user is looking at the latest revision,
 154+ // disable caching, to avoid the wiki getting the
 155+ // contents from the cache, and thus getting the
 156+ // approved contents instead (seems to be an issue
 157+ // only for MW >= 1.17).
 158+ if ( $revisionID == $article->getLatest() ) {
 159+ global $wgEnableParserCache;
 160+ $wgEnableParserCache = false;
 161+ }
141162 return true;
142163 }
143164

Status & tagging log