Index: trunk/extensions/FlaggedRevs/specialpages/RevisionReview_body.php |
— | — | @@ -31,7 +31,8 @@ |
32 | 32 | |
33 | 33 | public function execute( $par ) { |
34 | 34 | global $wgRequest, $wgUser, $wgOut; |
35 | | - $confirm = $wgRequest->wasPosted() && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ); |
| 35 | + $confirm = $wgRequest->wasPosted() |
| 36 | + && $wgUser->matchEditToken( $wgRequest->getVal( 'wpEditToken' ) ); |
36 | 37 | if( $wgUser->isAllowed( 'review' ) ) { |
37 | 38 | if( $wgUser->isBlocked( !$confirm ) ) { |
38 | 39 | $wgOut->blockedPage(); |
— | — | @@ -150,7 +151,8 @@ |
151 | 152 | |
152 | 153 | private function retrieveNotes( $notes = '' ) { |
153 | 154 | global $wgUser; |
154 | | - $this->notes = ( FlaggedRevs::allowComments() && $wgUser->isAllowed('validate') ) ? $notes : ''; |
| 155 | + $this->notes = ( FlaggedRevs::allowComments() && $wgUser->isAllowed('validate') ) ? |
| 156 | + $notes : ''; |
155 | 157 | } |
156 | 158 | |
157 | 159 | public static function AjaxReview( /*$args...*/ ) { |
— | — | @@ -252,7 +254,8 @@ |
253 | 255 | return '<err#>' . wfMsgExt( 'revreview-failed', 'parseinline' ); |
254 | 256 | } |
255 | 257 | // Doesn't match up? |
256 | | - $k = self::validationKey( $form->templateParams, $form->imageParams, $form->fileVersion, $form->oldid ); |
| 258 | + $k = self::validationKey( $form->templateParams, $form->imageParams, |
| 259 | + $form->fileVersion, $form->oldid ); |
257 | 260 | if( $form->validatedParams !== $k ) { |
258 | 261 | return '<err#>' . wfMsgExt( 'revreview-failed', 'parseinline' ); |
259 | 262 | } |
— | — | @@ -361,7 +364,8 @@ |
362 | 365 | $form .= Xml::hidden( 'wpApprove', $this->approve ) . "\n"; |
363 | 366 | $form .= Xml::hidden( 'rcid', $this->rcid ) . "\n"; |
364 | 367 | # Special token to discourage fiddling... |
365 | | - $checkCode = self::validationKey( $this->templateParams, $this->imageParams, $this->fileVersion, $rev->getId() ); |
| 368 | + $checkCode = self::validationKey( $this->templateParams, $this->imageParams, |
| 369 | + $this->fileVersion, $rev->getId() ); |
366 | 370 | $form .= Xml::hidden( 'validatedParams', $checkCode ); |
367 | 371 | $form .= '</fieldset>'; |
368 | 372 | |
— | — | @@ -379,7 +383,8 @@ |
380 | 384 | $difflink = '(' . $this->skin->makeKnownLinkObj( $this->page, wfMsgHtml('diff'), |
381 | 385 | '&diff=' . $rev->getId() . '&oldid=prev' ) . ')'; |
382 | 386 | $revlink = $this->skin->makeLinkObj( $this->page, $date, 'oldid=' . $rev->getId() ); |
383 | | - return "<li>$difflink $revlink " . $this->skin->revUserLink($rev) . " " . $this->skin->revComment($rev) . "</li>"; |
| 387 | + return "<li>$difflink $revlink " . $this->skin->revUserLink($rev) . " " . |
| 388 | + $this->skin->revComment($rev) . "</li>"; |
384 | 389 | } |
385 | 390 | |
386 | 391 | public function isApproval() { |
— | — | @@ -482,7 +487,7 @@ |
483 | 488 | # Our flags |
484 | 489 | $flags = $this->dims; |
485 | 490 | # Some validation vars to make sure nothing changed during |
486 | | - $lastTempID = 0; |
| 491 | + $lastTempId = 0; |
487 | 492 | $lastImgTime = "0"; |
488 | 493 | # Our template version pointers |
489 | 494 | $tmpset = $tmpParams = array(); |
— | — | @@ -501,8 +506,8 @@ |
502 | 507 | if( is_null($tmp_title) ) |
503 | 508 | continue; // Page must be valid! |
504 | 509 | |
505 | | - if( $rev_id > $lastTempID ) |
506 | | - $lastTempID = $rev_id; |
| 510 | + if( $rev_id > $lastTempId ) |
| 511 | + $lastTempId = $rev_id; |
507 | 512 | |
508 | 513 | $tmpset[] = array( |
509 | 514 | 'ft_rev_id' => $rev->getId(), |
— | — | @@ -563,33 +568,33 @@ |
564 | 569 | |
565 | 570 | # Is this rev already flagged? |
566 | 571 | $flaggedOutput = false; |
567 | | - if( $oldfrev = FlaggedRevision::newFromTitle( $this->page, $rev->getId(), FR_TEXT | FR_MASTER ) ) { |
568 | | - $flaggedOutput = FlaggedRevs::parseStableText( $article, $oldfrev->getRevText(), $oldfrev->getRevId() ); |
| 572 | + $oldfrev = FlaggedRevision::newFromTitle( $this->page, $rev->getId(), |
| 573 | + FR_TEXT | FR_MASTER ); |
| 574 | + if( $oldfrev ) { |
| 575 | + $flaggedOutput = FlaggedRevs::parseStableText( $article, $oldfrev->getRevText(), |
| 576 | + $oldfrev->getRevId() ); |
569 | 577 | } |
570 | 578 | |
571 | 579 | # Be looser on includes for templates, since they don't matter much |
572 | 580 | # and strict checking breaks randomized images/metatemplates...(bug 14580) |
573 | 581 | global $wgUseCurrentTemplates, $wgUseCurrentImages; |
574 | | - $noMatch = ($rev->getTitle()->getNamespace() == NS_TEMPLATE && $wgUseCurrentTemplates && $wgUseCurrentImages); |
| 582 | + $noMatch = ($rev->getTitle()->getNamespace() == NS_TEMPLATE |
| 583 | + && $wgUseCurrentTemplates && $wgUseCurrentImages); |
575 | 584 | |
576 | 585 | # Set our versioning params cache |
577 | 586 | FlaggedRevs::setIncludeVersionCache( $rev->getId(), $tmpParams, $imgParams ); |
578 | | - # Get the expanded text and resolve all templates. |
579 | | - # Store $templateIDs and add it to final parser output later... |
580 | | - list($fulltext,$tmps,$tmpIDs,$err,$maxID) = FlaggedRevs::expandText( $rev->getText(), $rev->getTitle(), $rev->getId() ); |
581 | | - if( !$noMatch && (!empty($err) || $maxID > $lastTempID) ) { |
582 | | - wfProfileOut( __METHOD__ ); |
583 | | - return $err; |
584 | | - } |
585 | | - # Parse the rest and check if it matches up |
586 | | - $stableOutput = FlaggedRevs::parseStableText( $article, $fulltext, $rev->getId() ); |
| 587 | + # Parse the text and check if all templates/files match up |
| 588 | + $stableOutput = FlaggedRevs::parseStableText( $article, $rev->getText(), $rev->getId() ); |
587 | 589 | $err =& $stableOutput->fr_includeErrors; |
588 | | - if( !$noMatch && (!empty($err) || $stableOutput->fr_newestImageTime > $lastImgTime) ) { |
589 | | - wfProfileOut( __METHOD__ ); |
590 | | - return $err; |
| 590 | + if( !$noMatch ) { // template/files must all be specified |
| 591 | + if( !empty($err) |
| 592 | + || $stableOutput->fr_newestImageTime > $lastImgTime |
| 593 | + || $stableOutput->fr_newestTemplateID > $lastTempId ) |
| 594 | + { |
| 595 | + wfProfileOut( __METHOD__ ); |
| 596 | + return $err; // return templates/files with no version specified |
| 597 | + } |
591 | 598 | } |
592 | | - # Merge in template params from first phase of parsing... |
593 | | - $this->mergeTemplateParams( $stableOutput, $tmps, $tmpIDs, $maxID ); |
594 | 599 | # Clear our versioning params cache |
595 | 600 | FlaggedRevs::clearIncludeVersionCache( $rev->getId() ); |
596 | 601 | |
— | — | @@ -644,7 +649,9 @@ |
645 | 650 | # Try using the parser cache first since we didn't actually edit the current version. |
646 | 651 | $parserCache = ParserCache::singleton(); |
647 | 652 | $poutput = $parserCache->get( $article, $wgUser ); |
648 | | - if( !$poutput || !isset($poutput->fr_newestTemplateID) || !isset($poutput->fr_newestImageTime) ) { |
| 653 | + if( !$poutput || !isset($poutput->fr_newestTemplateID) |
| 654 | + || !isset($poutput->fr_newestImageTime) ) |
| 655 | + { |
649 | 656 | $text = $article->getContent(); |
650 | 657 | $options = FlaggedRevs::makeParserOptions(); |
651 | 658 | $poutput = $wgParser->parse( $text, $article->mTitle, $options ); |