r78430 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r78429‎ | r78430 | r78431 >
Date:05:36, 15 December 2010
Author:yaron
Status:deferred
Tags:
Comment:
Fixes for three bugs: code was crashing on "saves" where no page content changed; "blank if unapproved" setting was also showing blank if user was explicitly looking at a page's latest revision; a user message didn't load correctly for MW < 1.16
Modified paths:
  • /trunk/extensions/ApprovedRevs/ApprovedRevs.hooks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ApprovedRevs/ApprovedRevs.hooks.php
@@ -70,6 +70,10 @@
7171 $summary, $flags, $unused1, $unused2, &$flags, $revision,
7272 &$status, $baseRevId ) {
7373
 74+ if ( is_null( $revision ) ) {
 75+ return true;
 76+ }
 77+
7478 $title = $article->getTitle();
7579 if ( ! $title->userCan( 'approverevisions' ) ) {
7680 return true;
@@ -91,6 +95,7 @@
9296 return true;
9397 }
9498 }
 99+
95100 // save approval without logging
96101 ApprovedRevs::saveApprovedRevIDInDB( $title, $revision->getID() );
97102 return true;
@@ -114,24 +119,39 @@
115120 }
116121
117122 public static function showBlankIfUnapproved( &$article, &$content ) {
118 - if ( ! ApprovedRevs::isDefaultPageRequest() ) {
 123+ global $egApprovedRevsBlankIfUnapproved;
 124+ if ( ! $egApprovedRevsBlankIfUnapproved ) {
119125 return true;
120126 }
121127
122128 $title = $article->getTitle();
123129 $revisionID = ApprovedRevs::getApprovedRevID( $title );
124 - if ( empty( $revisionID ) ) {
125 - global $egApprovedRevsBlankIfUnapproved;
126 - if ( $egApprovedRevsBlankIfUnapproved ) {
127 - $content = '';
128 - global $wgOut;
129 - if ( $wgOut->getSubtitle() != '' ) {
130 - $wgOut->appendSubtitle( "<br />" . wfMsg( 'approvedrevs-blankpageshown' ) );
131 - } else {
132 - $wgOut->setSubtitle( wfMsg( 'approvedrevs-blankpageshown' ) );
133 - }
134 - }
 130+ if ( !empty( $revisionID ) ) {
 131+ return true;
135132 }
 133+
 134+ // This looks extreme - disable the cache for every page,
 135+ // if users aren't meant to see pages with no approved
 136+ // revision, and this page has no approved revision - but
 137+ // there doesn't seem to be any other way to distinguish
 138+ // between a user looking at the main view of page, and a
 139+ // user specifically looking at the latest revision of the
 140+ // page (which we don't want to show as blank.)
 141+ global $wgEnableParserCache;
 142+ $wgEnableParserCache = false;
 143+
 144+ if ( ! ApprovedRevs::isDefaultPageRequest() ) {
 145+ return true;
 146+ }
 147+
 148+ $content = '';
 149+ global $wgOut;
 150+ if ( $wgOut->getSubtitle() != '' ) {
 151+ $wgOut->appendSubtitle( "<br />" . wfMsg( 'approvedrevs-blankpageshown' ) );
 152+ } else {
 153+ $wgOut->setSubtitle( wfMsg( 'approvedrevs-blankpageshown' ) );
 154+ }
 155+
136156 return true;
137157 }
138158
@@ -216,6 +236,7 @@
217237 $latestRevID = $title->getLatestRevID();
218238 if ( ! empty( $approvedRevID ) && $approvedRevID != $latestRevID ) {
219239 ApprovedRevs::addCSS();
 240+ wfLoadExtensionMessages( 'ApprovedRevs' );
220241 global $wgOut;
221242 $wgOut->addHTML( '<p class="approvedRevsEditWarning">' . wfMsg( 'approvedrevs-editwarning' ) . "</p>\n" );
222243 }

Status & tagging log