Index: branches/jhb/phase3/extensions/FlaggedRevs.php |
— | — | @@ -54,6 +54,8 @@ |
55 | 55 | $wgLogActions['review/unapprove'] = 'review-logentryrevoke'; |
56 | 56 | |
57 | 57 | class FlaggedRevs { |
| 58 | + /* 50MB allows fixing those huge pages */ |
| 59 | + const MAX_INCLUDE_SIZE = 50000000; |
58 | 60 | |
59 | 61 | function __construct() { |
60 | 62 | $this->dimensions = array( 'accuracy' => array( 0=>'acc-0', |
— | — | @@ -69,12 +71,53 @@ |
70 | 72 | 2=>'style-2', |
71 | 73 | 3=>'style-3') ); |
72 | 74 | } |
| 75 | + |
| 76 | + function pageOverride() { |
| 77 | + global $wgFlaggedRevsAnonOnly, $wgUser; |
| 78 | + return !( $wgFlaggedRevsAnonOnly && !$wgUser->isAnon() ); |
| 79 | + } |
| 80 | + |
| 81 | + function getFlaggedRevision( $rev_id ) { |
| 82 | + $db = wfGetDB( DB_SLAVE ); |
| 83 | + // select a row, this should be unique |
| 84 | + $result = $db->select( 'flaggedrevs', array('*'), array('fr_rev_id' => $rev_id) ); |
| 85 | + if ( $row = $db->fetchObject($result) ) { |
| 86 | + return $row; |
| 87 | + } |
| 88 | + return NULL; |
| 89 | + } |
| 90 | + |
| 91 | + function getFlaggedRevText( $rev_id ) { |
| 92 | + $db = wfGetDB( DB_SLAVE ); |
| 93 | + // select a row, this should be unique |
| 94 | + $result = $db->select( 'flaggedcache', array('fc_cache'), array('fc_rev_id' => $rev_id) ); |
| 95 | + if ( $row = $db->fetchObject($result) ) { |
| 96 | + return $row->fc_cache; |
| 97 | + } |
| 98 | + return NULL; |
| 99 | + } |
| 100 | + |
| 101 | + /** |
| 102 | + * @param string $text |
| 103 | + * @returns string |
| 104 | + * All included pages are expanded out to keep this text frozen |
| 105 | + */ |
| 106 | + function expandText( $text ) { |
| 107 | + global $wgParser, $wgTitle; |
| 108 | + // Do not treat this as paring an article on normal view |
| 109 | + // enter the title object as wgTitle |
| 110 | + $options = new ParserOptions; |
| 111 | + $options->setRemoveComments( true ); |
| 112 | + $options->setMaxIncludeSize( self::MAX_INCLUDE_SIZE ); |
| 113 | + $output = $wgParser->preprocess( $text, $wgTitle, $options ); |
| 114 | + return $output; |
| 115 | + } |
73 | 116 | |
74 | 117 | function getFlagsForRevision( $rev_id ) { |
75 | 118 | // Set default blank flags |
76 | 119 | $flags = array( 'accuracy' => 0, 'depth' => 0, 'style' => 0 ); |
77 | 120 | |
78 | | - $db = wfGetDB( DB_MASTER ); |
| 121 | + $db = wfGetDB( DB_SLAVE ); |
79 | 122 | // select a row, this should be unique |
80 | 123 | $result = $db->select( 'flaggedrevs', array('*'), array('fr_rev_id' => $rev_id) ); |
81 | 124 | if ( $row = $db->fetchObject($result) ) { |
— | — | @@ -83,7 +126,9 @@ |
84 | 127 | return $flags; |
85 | 128 | } |
86 | 129 | |
87 | | - function getLatestRev( $page_id ) { |
| 130 | + function getLatestFlaggedRev( $page_id ) { |
| 131 | + # Call getReviewedRevs(), |
| 132 | + # this will prune things out if needed |
88 | 133 | if ( $row = $this->getReviewedRevs($page_id) ) { |
89 | 134 | return $row[0]; |
90 | 135 | } |
— | — | @@ -105,17 +150,19 @@ |
106 | 151 | while ( $row = $db->fetchObject( $result ) ) { |
107 | 152 | // Purge deleted revs from flaggedrev table |
108 | 153 | if ( $row->rev_deleted ) { |
109 | | - $cache_text = $this->expandText( $row->fr_cache ); |
110 | | - $db->delete( 'flaggedrevs', array( 'fr_rev_id' => $rev->getId ) ); |
| 154 | + $cache_text = $this->expandText( $this->getFlaggedRevText( $row->fr_rev_id ) ); |
| 155 | + $db->delete( 'flaggedrevs', array( 'fr_rev_id' => $row->rev_id ) ); |
111 | 156 | // Delete stable images if needed |
112 | | - $images = $this->findLocalImages( $cache_text ); |
| 157 | + list($images,$thumbs) = $this->findLocalImages( $cache_text ); |
113 | 158 | $copies = $this->deleteStableImages( $images ); |
114 | 159 | // Update stable image table |
115 | 160 | $this->removeStableImages( $row->rev_id, $copies ); |
| 161 | + $this->deleteStableThumbnails( $thumbs ); |
116 | 162 | // Clear cache... |
117 | 163 | $this->updatePage( Title::newFromID($page_id) ); |
| 164 | + } else { |
| 165 | + $rows[] = $row; |
118 | 166 | } |
119 | | - $rows[] = $row; |
120 | 167 | } |
121 | 168 | return $rows; |
122 | 169 | } |
— | — | @@ -133,11 +180,6 @@ |
134 | 181 | // Return count of revisions |
135 | 182 | return $db->numRows($result); |
136 | 183 | } |
137 | | - |
138 | | - function pageOverride() { |
139 | | - global $wgFlaggedRevsAnonOnly, $wgUser; |
140 | | - return !( $wgFlaggedRevsAnonOnly && !$wgUser->isAnon() ); |
141 | | - } |
142 | 184 | |
143 | 185 | function setPageContent( &$out ) { |
144 | 186 | global $wgArticle, $wgRequest, $wgTitle, $wgOut, $action; |
— | — | @@ -157,7 +199,7 @@ |
158 | 200 | // Set new body html text as that of now |
159 | 201 | $flaghtml = ''; $newbodytext = $out->mBodytext; |
160 | 202 | // Check the newest stable version |
161 | | - $top_frev = $this->getLatestRev( $wgArticle->getId() ); |
| 203 | + $top_frev = $this->getLatestFlaggedRev( $wgArticle->getId() ); |
162 | 204 | if ( $wgRequest->getVal('diff') ) { |
163 | 205 | // Do not clutter up diffs any further... |
164 | 206 | } else if ( $top_frev ) { |
— | — | @@ -176,25 +218,40 @@ |
177 | 219 | $diff = ($revid > $top_frev->fr_rev_id) ? $revid : $top_frev->fr_rev_id; |
178 | 220 | $flaghtml = wfMsgExt('revreview-newest', array('parse'), $top_frev->fr_rev_id, $oldid, $diff, $time ); |
179 | 221 | } |
180 | | - } # Viewing the page normally |
| 222 | + } # Viewing the page normally: override the page |
181 | 223 | else { |
182 | | - global $wgUser, $wgUploadDirectory; |
183 | | - // We will be looking at the reviewed revision... |
| 224 | + global $wgUser, $wgUploadDirectory, $wgUseSharedUploads, $wgUploadPath; |
| 225 | + # We will be looking at the reviewed revision... |
184 | 226 | $visible_id = $top_frev->fr_rev_id; |
185 | 227 | $revs_since = $this->getUnreviewedRevCount( $wgArticle->getId(), $visible_id ); |
186 | 228 | $flaghtml = wfMsgExt('revreview-replaced', array('parse'), $visible_id, $wgArticle->getLatest(), $revs_since, $time ); |
187 | | - # Hack...temporarily change image dir |
| 229 | + |
| 230 | + # Hack...temporarily change image directories |
| 231 | + # There is no nice option to set this for each parse |
188 | 232 | # This lets the parser know where to look... |
| 233 | + $uploadPath = $wgUploadPath; |
189 | 234 | $uploadDir = $wgUploadDirectory; |
190 | | - $wgUploadDirectory = "{$wgUploadDirectory}/stable"; |
| 235 | + $useSharedUploads = $wgUseSharedUploads; |
| 236 | + # Stable thumbnails need to have the right path |
| 237 | + $wgUploadPath = ($wgUploadPath) ? "{$uploadPath}/stable" : false; |
| 238 | + # Create <img> tags with the right url |
| 239 | + $wgUploadDirectory = "{$uploadDir}/stable"; |
| 240 | + # Stable images are never stored at commons |
| 241 | + $wgUseSharedUploads = false; |
| 242 | + |
191 | 243 | $parse_ops = ParserOptions::newFromUser($wgUser); |
192 | 244 | # Don't show section-edit links |
| 245 | + # They can be old and misleading |
193 | 246 | $parse_ops->setEditSection( false ); |
194 | | - // Parse the new body, wikitext -> html |
195 | | - $newbody = $wgParser->parse( $top_frev->fr_cache, $wgTitle, $parse_ops ); |
| 247 | + # Parse the new body, wikitext -> html |
| 248 | + $text = $this->getFlaggedRevText( $top_frev->fr_rev_id ); |
| 249 | + $newbody = $wgParser->parse( $text, $wgTitle, $parse_ops ); |
196 | 250 | $newbodytext = $newbody->getText(); |
197 | | - // Reset image dir |
| 251 | + |
| 252 | + # Reset image directories |
| 253 | + $wgUploadPath = $uploadPath; |
198 | 254 | $wgUploadDirectory = $uploadDir; |
| 255 | + $wgUseSharedUploads = $useSharedUploads; |
199 | 256 | } |
200 | 257 | // Construct some tagging |
201 | 258 | $flaghtml .= "<table align='center' cellspadding=\'0\'><tr>"; |
— | — | @@ -205,7 +262,8 @@ |
206 | 263 | $flaghtml .= '</tr></table>'; |
207 | 264 | // Should use CSS? |
208 | 265 | $flaghtml = "<small>$flaghtml</small>"; |
209 | | - // Copy over the old body |
| 266 | + |
| 267 | + // Set the new body HTML! and place the tag on top |
210 | 268 | $out->mBodytext = '<div class="mw-warning plainlinks">' . $flaghtml . '</div>' . $newbodytext; |
211 | 269 | } else { |
212 | 270 | $flaghtml = wfMsgExt('revreview-noflagged', array('parse')); |
— | — | @@ -216,7 +274,11 @@ |
217 | 275 | // Show review links for the VISIBLE revision |
218 | 276 | // We cannot review deleted revisions |
219 | 277 | if ( is_object($wgArticle->mRevision) && $wgArticle->mRevision->mDeleted ) return; |
220 | | - $this->addQuickReview( $visible_id, false, $out ); |
| 278 | + // Add quick review links IF we did not override, otherwise, they might |
| 279 | + // review a revision that parses out newer templates/images than what they say |
| 280 | + // Note: overrides are never done when viewing with "oldid=" |
| 281 | + if ( $visible_id==$revid || !$this->pageOverride() ) |
| 282 | + $this->addQuickReview( $visible_id, false, $out ); |
221 | 283 | } |
222 | 284 | |
223 | 285 | function addToEditView( &$editform ) { |
— | — | @@ -235,7 +297,7 @@ |
236 | 298 | // Set new body html text as that of now |
237 | 299 | $flaghtml = ''; |
238 | 300 | // Check the newest stable version |
239 | | - $top_frev = $this->getLatestRev( $editform->mArticle->getId() ); |
| 301 | + $top_frev = $this->getLatestFlaggedRev( $editform->mArticle->getId() ); |
240 | 302 | if ( is_object($top_frev) ) { |
241 | 303 | global $wgParser, $wgLang; |
242 | 304 | $time = $wgLang->timeanddate( wfTimestamp(TS_MW, $top_frev->fr_timestamp), true ); |
— | — | @@ -253,7 +315,7 @@ |
254 | 316 | } # Editing the page normally |
255 | 317 | else { |
256 | 318 | if ( $revid==$top_frev->rev_id ) |
257 | | - $flaghtml = wfMsgExt('revreview-isnewest', array('parse')); |
| 319 | + $flaghtml = wfMsgExt('revreview-isnewest', array('parse'), $time); |
258 | 320 | else |
259 | 321 | $flaghtml = wfMsgExt('revreview-newest', array('parse'), $top_frev->fr_rev_id, $top_frev->fr_rev_id, $revid, $time ); |
260 | 322 | } |
— | — | @@ -286,7 +348,7 @@ |
287 | 349 | // If we are viewing a page normally, and it was overrode |
288 | 350 | // change the edit tab to a "current revision" tab |
289 | 351 | if ( !$wgRequest->getVal('oldid') ) { |
290 | | - $top_frev = $this->getLatestRev( $wgArticle->getId() ); |
| 352 | + $top_frev = $this->getLatestFlaggedRev( $wgArticle->getId() ); |
291 | 353 | // Note that revisions may not be set to override for users |
292 | 354 | if ( is_object($top_frev) && $this->pageOverride() ) { |
293 | 355 | # Remove edit option altogether |
Index: branches/jhb/phase3/extensions/FlaggedRevs.sql |
— | — | @@ -1,4 +1,5 @@ |
| 2 | +-- (c) Joerg Baach, Aaron Schulz, 2007
|
| 3 | +
|
2 | 4 | -- Table structure for table `revisiontags`
|
3 | 5 | -- This stores expanded revision wikitext caches
|
4 | 6 | -- along with rating/user/notes data
|
— | — | @@ -6,7 +7,6 @@ |
7 | 8 | fr_id int(10) NOT NULL auto_increment,
|
8 | 9 | fr_page_id int(10) NOT NULL,
|
9 | 10 | fr_rev_id int(10) NOT NULL,
|
10 | | - fr_cache mediumblob NOT NULL default '',
|
11 | 11 | fr_acc int(2) NOT NULL,
|
12 | 12 | fr_dep int(2) NOT NULL,
|
13 | 13 | fr_sty int(2) NOT NULL,
|
— | — | @@ -18,8 +18,18 @@ |
19 | 19 | UNIQUE KEY (fr_id),
|
20 | 20 | INDEX fr_page_rev (fr_page_id,fr_rev_id),
|
21 | 21 | INDEX fr_acc_dep_sty (fr_acc,fr_dep,fr_sty)
|
22 | | -) ENGINE=MyISAM AUTO_INCREMENT=9 DEFAULT CHARSET=latin1 COMMENT='Revision Tags Extension' AUTO_INCREMENT=0;
|
| 22 | +) TYPE=InnoDB;
|
23 | 23 |
|
| 24 | +-- This stores cached, expanded revisions text
|
| 25 | +CREATE TABLE /*$wgDBprefix*/flaggedcache (
|
| 26 | + fc_id int(10) NOT NULL auto_increment,
|
| 27 | + fc_rev_id int(10) NOT NULL,
|
| 28 | + fc_cache mediumblob NOT NULL default '',
|
| 29 | +
|
| 30 | + PRIMARY KEY fc_rev_id (fc_rev_id),
|
| 31 | + UNIQUE KEY (fc_id)
|
| 32 | +) TYPE=InnoDB;
|
| 33 | +
|
24 | 34 | -- This stores image usage for the stable image directory
|
25 | 35 | -- along with rating/user/notes data
|
26 | 36 | CREATE TABLE /*$wgDBprefix*/flaggedimages (
|
Index: branches/jhb/phase3/extensions/FlaggedRevsPage.body.php |
— | — | @@ -8,8 +8,6 @@ |
9 | 9 | |
10 | 10 | class Revisionreview extends SpecialPage |
11 | 11 | { |
12 | | - /* 50MB allows fixing those huge pages */ |
13 | | - const MAX_INCLUDE_SIZE = 50000000; |
14 | 12 | |
15 | 13 | function Revisionreview() { |
16 | 14 | SpecialPage::SpecialPage('Revisionreview', 'review'); |
— | — | @@ -124,7 +122,7 @@ |
125 | 123 | } |
126 | 124 | $form .= '</td></tr></table></fieldset>'; |
127 | 125 | |
128 | | - $images = $this->findLocalImages( $this->expandText( $rev->getText() ) ); |
| 126 | + list($images,$thumbs) = $this->findLocalImages( FlaggedRevs::expandText( $rev->getText() ) ); |
129 | 127 | if ( $images ) { |
130 | 128 | $form .= wfMsg('revreview-images') . "\n"; |
131 | 129 | $form .= "<ul>"; |
— | — | @@ -213,12 +211,11 @@ |
214 | 212 | $user = $wgUser->getId(); |
215 | 213 | $timestamp = wfTimestampNow(); |
216 | 214 | |
217 | | - $cache_text = $this->expandText( $rev->getText() ); |
| 215 | + $cache_text = FlaggedRevs::expandText( $rev->getText() ); |
218 | 216 | // Add or update entry for this revision |
219 | 217 | $set = array( |
220 | 218 | 'fr_page_id' => $rev->getPage(), |
221 | 219 | 'fr_rev_id' => $rev->getId(), |
222 | | - 'fr_cache' => $cache_text, |
223 | 220 | 'fr_acc' => $this->dimensions['accuracy'], |
224 | 221 | 'fr_dep' => $this->dimensions['depth'], |
225 | 222 | 'fr_sty' => $this->dimensions['style'], |
— | — | @@ -226,12 +223,17 @@ |
227 | 224 | 'fr_timestamp' => $timestamp, |
228 | 225 | 'fr_comment'=> $this->notes |
229 | 226 | ); |
| 227 | + $set2 = array('fc_rev_id' => $rev->getId(), 'fc_cache' => $cache_text); |
| 228 | + // Update flagrevisions table |
230 | 229 | $db->replace( 'flaggedrevs', array( array('fr_page_id','fr_rev_id') ), $set, __METHOD__ ); |
| 230 | + // Store/update the text |
| 231 | + $db->replace( 'flaggedcache', array('fc_rev_id'), $set2, __METHOD__ ); |
231 | 232 | // Update the article review log |
232 | 233 | $this->updateLog( $this->page, $this->dimensions, $this->comment, $this->oldid, true ); |
233 | 234 | // Clone images to stable dir |
234 | | - $images = $this->findLocalImages( $cache_text ); |
| 235 | + list($images,$thumbs) = $this->findLocalImages( $cache_text ); |
235 | 236 | $copies = $this->makeStableImages( $images ); |
| 237 | + $this->deleteStableThumbnails( $thumbs ); |
236 | 238 | // Update stable image table |
237 | 239 | $this->insertStableImages( $rev->getId(), $copies ); |
238 | 240 | // Clear cache... |
— | — | @@ -250,14 +252,22 @@ |
251 | 253 | $db = wfGetDB( DB_MASTER ); |
252 | 254 | $user = $wgUser->getId(); |
253 | 255 | $timestamp = wfTimestampNow(); |
254 | | - |
255 | | - $cache_text = $this->expandText( $rev->getText() ); |
| 256 | + // get the flagged revision to access its cache text |
| 257 | + $frev = FlaggedRevs::getFlaggedRevision( $rev->getId ); |
| 258 | + if( !$frev ) { |
| 259 | + // This shouldn't happen... |
| 260 | + return; |
| 261 | + } |
256 | 262 | $db->delete( 'flaggedrevs', array( 'fr_rev_id' => $rev->getId ) ); |
257 | 263 | // Update the article review log |
258 | 264 | $this->updateLog( $this->page, $this->dimensions, $this->comment, $this->oldid, false ); |
| 265 | + |
| 266 | + $cache_text = FlaggedRevs::getFlaggedRevText( $rev->getId ) ; |
259 | 267 | // Delete stable images if needed |
260 | | - $images = $this->findLocalImages( $cache_text ); |
| 268 | + list($images,$thumbs) = $this->findLocalImages( $cache_text ); |
261 | 269 | $copies = $this->deleteStableImages( $images ); |
| 270 | + // Stable versions must remake this thumbnail |
| 271 | + $this->deleteStableThumbnails( $thumbs ); |
262 | 272 | // Update stable image table |
263 | 273 | $this->removeStableImages( $rev->getId(), $copies ); |
264 | 274 | // Clear cache... |
— | — | @@ -274,31 +284,17 @@ |
275 | 285 | function updatePage( $title ) { |
276 | 286 | $title->invalidateCache(); |
277 | 287 | } |
278 | | - |
279 | | - /** |
280 | | - * @param string $text |
281 | | - * @returns string |
282 | | - * All included pages are expanded out to keep this text frozen |
283 | | - */ |
284 | | - function expandText( $text ) { |
285 | | - global $wgParser, $wgTitle; |
286 | | - // Do not treat this as paring an article on normal view |
287 | | - // enter the title object as wgTitle |
288 | | - $options = new ParserOptions; |
289 | | - $options->setRemoveComments( true ); |
290 | | - $options->setMaxIncludeSize( self::MAX_INCLUDE_SIZE ); |
291 | | - $output = $wgParser->preprocess( $text, $wgTitle, $options ); |
292 | | - return $output; |
293 | | - } |
294 | 288 | |
295 | 289 | /** |
296 | 290 | * Get all local image files and generate an array of them |
297 | 291 | * @param string $s, wikitext |
298 | | - * $output array, string titles |
299 | | - */ |
| 292 | + * $output array, (string title array, string thumbnail array) |
| 293 | + */ |
300 | 294 | function findLocalImages( $s ) { |
| 295 | + global $wgUploadPath; |
| 296 | + |
301 | 297 | $fname = 'findLocalImages'; |
302 | | - $imagelist = array(); |
| 298 | + $imagelist = array(); $thumblist = array(); |
303 | 299 | |
304 | 300 | if ( !$s || !strval($s) ) return $imagelist; |
305 | 301 | |
— | — | @@ -313,25 +309,39 @@ |
314 | 310 | $e1_img = "/^([:{$tc}]+)(.+)$/sD"; |
315 | 311 | # Loop for each link |
316 | 312 | for ($k = 0; isset( $a[$k] ); $k++) { |
317 | | - if ( preg_match( $e1_img, $a[$k], $m ) ) { |
| 313 | + if( preg_match( $e1_img, $a[$k], $m ) ) { |
318 | 314 | # page with normal text or alt of form x or ns:x |
319 | 315 | $nt = Title::newFromText( $m[1] ); |
320 | 316 | $ns = $nt->getNamespace(); |
321 | 317 | # add if this is an image |
322 | | - if ( $ns == NS_IMAGE ) |
| 318 | + if( $ns == NS_IMAGE ) { |
323 | 319 | $imagelist[] = $nt->getPrefixedText(); |
| 320 | + } |
| 321 | + $image = $nt->getDBKey(); |
| 322 | + # check for data for thumbnails |
| 323 | + $part = array_map( 'trim', explode( '|', $m[2]) ); |
| 324 | + foreach( $part as $val ) { |
| 325 | + if( preg_match( '/^([0-9]+)px$/', $val, $n ) ) { |
| 326 | + $width = intval( $n[1] ); |
| 327 | + $thumblist[$image] = $width; |
| 328 | + } else if( preg_match( '/^([0-9]+)x([0-9]+)(px|)$/', $val, $n ) ) { |
| 329 | + $width = intval( $n[1] ); |
| 330 | + $thumblist[$image] = $width; |
| 331 | + } |
| 332 | + } |
324 | 333 | } |
325 | 334 | } |
326 | | - return $imagelist; |
| 335 | + return array( $imagelist, $thumblist ); |
327 | 336 | } |
328 | 337 | |
329 | 338 | /** |
330 | 339 | * Showtime! Copy all used images to a stable directory |
331 | | - * Get all local image files and generate an array of them |
| 340 | + * This updates (overwrites) any existing stable images |
| 341 | + * Won't work for sites with unhashed dirs that have subfolders protected |
332 | 342 | * The future FileStore migration might effect this, not sure... |
333 | 343 | * @param array $imagelist, list of string names |
334 | 344 | * $output array, list of string names of images sucessfully cloned |
335 | | - */ |
| 345 | + */ |
336 | 346 | function makeStableImages( $imagelist ) { |
337 | 347 | global $wgUploadDirectory, $wgSharedUploadDirectory; |
338 | 348 | // All stable images are local, not shared |
— | — | @@ -361,7 +371,6 @@ |
362 | 372 | if( !is_dir($stableDir . $hash) ) { |
363 | 373 | wfMkdirParents($stableDir . $hash); |
364 | 374 | } |
365 | | - // Copy over our files |
366 | 375 | copy("{$path}{$name}","{$stableDir}{$hash}{$name}"); |
367 | 376 | $usedimages[] = $name; |
368 | 377 | } |
— | — | @@ -385,9 +394,9 @@ |
386 | 395 | * Delete an a list of stable image files |
387 | 396 | * @param array $imagelist, list of string names |
388 | 397 | * $output array, list of string names of images to be deleted |
389 | | - */ |
| 398 | + */ |
390 | 399 | function deleteStableImages( $imagelist ) { |
391 | | - global $wgUploadDirectory, $wgSharedUploadDirectory; |
| 400 | + global $wgSharedUploadDirectory; |
392 | 401 | // All stable images are local, not shared |
393 | 402 | // Otherwise, we could have some nasty cross language/wiki conflicts |
394 | 403 | $stableDir = "$wgUploadDirectory/stable"; |
— | — | @@ -419,6 +428,26 @@ |
420 | 429 | } |
421 | 430 | |
422 | 431 | /** |
| 432 | + * Delete an a list of stable image thumbnails |
| 433 | + * New thumbnails don't normally override old ones, causing outdated images |
| 434 | + * This allows for tagged revisions to be re-reviewed with newer images |
| 435 | + * @param array $imagelist, list of string names |
| 436 | + * $output array, list of string names of images to be deleted |
| 437 | + */ |
| 438 | + function deleteStableThumbnails( $thumblist ) { |
| 439 | + global $wgUploadDirectory; |
| 440 | + // We need valid input |
| 441 | + if ( !is_array($thumblist) ) return false; |
| 442 | + foreach ( $thumblist as $name => $width ) { |
| 443 | + $thumburl = "{$wgUploadDirectory}/stable/thumb" . wfGetHashPath( $name, false ) . "$name/". $width."px-".$name; |
| 444 | + if ( is_file($thumburl) ) { |
| 445 | + unlink($thumburl); |
| 446 | + } |
| 447 | + } |
| 448 | + return true; |
| 449 | + } |
| 450 | + |
| 451 | + /** |
423 | 452 | * Update the stable image usage table |
424 | 453 | * Add some images if not redundant |
425 | 454 | * @param array $imagelist, list of string names |
Index: branches/jhb/phase3/extensions/FlaggedRevsPage.i18n.php |
— | — | @@ -16,8 +16,8 @@ |
17 | 17 | ([{{fullurl:{{FULLPAGENAMEE}}|oldid=$2&diff=$3}} compare]) was [{{fullurl:Special:Log/review|page={{FULLPAGENAMEE}}}} approved] |
18 | 18 | on <i>$4</i>, rated as:', |
19 | 19 | 'revreview-replaced' => 'This is the latest [[Help:Article validation|reviewed]] revision of this page, |
20 | | - [{{fullurl:Special:Log/review|page={{FULLPAGENAMEE}}}} approved] on <i>$4</i>. The [{{fullurl:{{FULLPAGENAMEE}}|oldid=$2}} current revision] |
21 | | - can be found in the [{{fullurl:{{FULLPAGENAMEE}}|action=history}} page history]. There {{plural:$3|is $3 revision|are $3 revisions}} |
| 20 | + [{{fullurl:Special:Log/review|page={{FULLPAGENAMEE}}}} approved] on <i>$4</i>. The [{{fullurl:{{FULLPAGENAMEE}}|oldid=$2}} current revision] |
| 21 | + is editable and may be more up to date. There {{plural:$3|is $3 revision|are $3 revisions}} |
22 | 22 | ([{{fullurl:{{FULLPAGENAMEE}}|oldid=$1&diff=$2}} changes]) awaiting review.', |
23 | 23 | |
24 | 24 | 'revisionreview' => 'Review revisions', |