r68106 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r68105‎ | r68106 | r68107 >
Date:21:14, 15 June 2010
Author:aaron
Status:ok
Tags:
Comment:
Fix for reviewing upload versions (instanceof check always false since ImagePage's aren't passed there anymore)
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedArticle.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.class.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/api/ApiReview.php (modified) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedArticle.php
@@ -9,7 +9,7 @@
1010 protected $stableRev = null;
1111 protected $pendingRevs = null;
1212 protected $pageConfig = null;
13 - protected $file = null;
 13+ protected $imagePage = null; // for file pages
1414
1515 /**
1616 * Get a FlaggedArticle for a given title
@@ -52,15 +52,29 @@
5353 */
5454 public function getFile() {
5555 if ( $this->getTitle()->getNamespace() != NS_FILE ) {
56 - return false; // not an file page
 56+ return false; // not a file page
5757 }
58 - if ( is_null( $this->file ) ) {
59 - $imagePage = new ImagePage( $this->getTitle() );
60 - $this->file = $imagePage->getFile();
 58+ if ( is_null( $this->imagePage ) ) {
 59+ $this->imagePage = new ImagePage( $this->getTitle() );
6160 }
62 - return $this->file;
 61+ return $this->imagePage->getFile();
6362 }
6463
 64+ /**
 65+ * Get the displayed file version of this file page
 66+ * @TODO: kind of hacky
 67+ * @return mixed (File/false)
 68+ */
 69+ public function getDisplayedFile() {
 70+ if ( $this->getTitle()->getNamespace() != NS_FILE ) {
 71+ return false; // not a file page
 72+ }
 73+ if ( is_null( $this->imagePage ) ) {
 74+ $this->imagePage = new ImagePage( $this->getTitle() );
 75+ }
 76+ return $this->imagePage->getDisplayedFile();
 77+ }
 78+
6579 /**
6680 * Is the stable version shown by default for this page?
6781 * @param int $flags, FR_MASTER
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.class.php
@@ -147,7 +147,7 @@
148148 global $wgUser, $wgSimpleFlaggedRevsUI;
149149 return $wgUser->getOption( 'flaggedrevssimpleui', intval( $wgSimpleFlaggedRevsUI ) );
150150 }
151 -
 151+
152152 /**
153153 * Allow auto-review edits directly to the stable version by reviewers?
154154 * (1 to allow auto-sighting; 2 for auto-quality; 3 for auto-pristine)
@@ -1621,13 +1621,13 @@
16221622
16231623 /**
16241624 * Get template and image parameters from parser output
1625 - * @param Article $article
 1625+ * @param FlaggedArticle $article
16261626 * @param array $templateIDs (from ParserOutput/OutputPage->mTemplateIds)
16271627 * @param array $imageSHA1Keys (from ParserOutput/OutputPage->fr_ImageSHA1Keys)
16281628 * @returns array( templateParams, imageParams, fileVersion )
16291629 */
16301630 public static function getIncludeParams(
1631 - Article $article, array $templateIDs, array $imageSHA1Keys
 1631+ FlaggedArticle $article, array $templateIDs, array $imageSHA1Keys
16321632 ) {
16331633 $templateParams = $imageParams = $fileVersion = '';
16341634 # NS -> title -> rev ID mapping
@@ -1644,9 +1644,11 @@
16451645 }
16461646 }
16471647 # For image pages, note the displayed image version
1648 - if ( $article instanceof ImagePage ) {
1649 - $file = $article->getDisplayedFile();
1650 - $fileVersion = $file->getTimestamp() . "#" . $file->getSha1();
 1648+ if ( $article->getTitle()->getNamespace() == NS_FILE ) {
 1649+ $file = $article->getDisplayedFile(); // File obj
 1650+ if ( $file ) {
 1651+ $fileVersion = $file->getTimestamp() . "#" . $file->getSha1();
 1652+ }
16511653 }
16521654 return array( $templateParams, $imageParams, $fileVersion );
16531655 }
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php
@@ -891,6 +891,7 @@
892892 * (d) The user can 'review' and the "review pending edits" checkbox was checked
893893 *
894894 * Note: RC items not inserted yet, RecentChange_save hook does rc_patrolled bit...
 895+ * Note: $article one of Article, ImagePage, Category page as appropriate.
895896 */
896897 public static function maybeMakeEditReviewed(
897898 Article $article, $rev, $baseRevId = false, $user = null
Index: trunk/extensions/FlaggedRevs/api/ApiReview.php
@@ -68,7 +68,7 @@
6969 if ( $form->isApproval() ) {
7070 // Now get the template and image parameters needed
7171 // If it is the current revision, try the parser cache first
72 - $article = new Article( $title, $revid );
 72+ $article = new FlaggedArticle( $title, $revid );
7373 if ( $rev->isCurrent() ) {
7474 $parserCache = ParserCache::singleton();
7575 $parserOutput = $parserCache->get( $article, $wgUser );

Follow-up revisions

RevisionCommit summaryAuthorDate
r68107MFT r68058-r68106aaron21:22, 15 June 2010

Status & tagging log