Index: trunk/extensions/ApprovedRevs/ApprovedRevs.hooks.php |
— | — | @@ -70,6 +70,10 @@ |
71 | 71 | $summary, $flags, $unused1, $unused2, &$flags, $revision, |
72 | 72 | &$status, $baseRevId ) { |
73 | 73 | |
| 74 | + if ( is_null( $revision ) ) { |
| 75 | + return true; |
| 76 | + } |
| 77 | + |
74 | 78 | $title = $article->getTitle(); |
75 | 79 | if ( ! $title->userCan( 'approverevisions' ) ) { |
76 | 80 | return true; |
— | — | @@ -91,6 +95,7 @@ |
92 | 96 | return true; |
93 | 97 | } |
94 | 98 | } |
| 99 | + |
95 | 100 | // save approval without logging |
96 | 101 | ApprovedRevs::saveApprovedRevIDInDB( $title, $revision->getID() ); |
97 | 102 | return true; |
— | — | @@ -114,24 +119,39 @@ |
115 | 120 | } |
116 | 121 | |
117 | 122 | public static function showBlankIfUnapproved( &$article, &$content ) { |
118 | | - if ( ! ApprovedRevs::isDefaultPageRequest() ) { |
| 123 | + global $egApprovedRevsBlankIfUnapproved; |
| 124 | + if ( ! $egApprovedRevsBlankIfUnapproved ) { |
119 | 125 | return true; |
120 | 126 | } |
121 | 127 | |
122 | 128 | $title = $article->getTitle(); |
123 | 129 | $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; |
135 | 132 | } |
| 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 | + |
136 | 156 | return true; |
137 | 157 | } |
138 | 158 | |
— | — | @@ -216,6 +236,7 @@ |
217 | 237 | $latestRevID = $title->getLatestRevID(); |
218 | 238 | if ( ! empty( $approvedRevID ) && $approvedRevID != $latestRevID ) { |
219 | 239 | ApprovedRevs::addCSS(); |
| 240 | + wfLoadExtensionMessages( 'ApprovedRevs' ); |
220 | 241 | global $wgOut; |
221 | 242 | $wgOut->addHTML( '<p class="approvedRevsEditWarning">' . wfMsg( 'approvedrevs-editwarning' ) . "</p>\n" ); |
222 | 243 | } |