Index: trunk/phase3/docs/hooks.txt |
— | — | @@ -741,6 +741,14 @@ |
742 | 742 | |
743 | 743 | 'LoadExtensionSchemaUpdates': called by maintenance/updaters.inc when upgrading database schema |
744 | 744 | |
| 745 | +'LocalFile::getHistory': called before file history query performed |
| 746 | +$file: the file |
| 747 | +$tables: tables |
| 748 | +$fields: select fields |
| 749 | +$conds: conditions |
| 750 | +$opts: query options |
| 751 | +$join_conds: JOIN conditions |
| 752 | + |
745 | 753 | 'LoginAuthenticateAudit': a login attempt for a valid user account either succeeded or failed. |
746 | 754 | No return data is accepted; this hook is for auditing only. |
747 | 755 | $user: the User object being authenticated against |
Index: trunk/phase3/includes/filerepo/OldLocalFile.php |
— | — | @@ -44,6 +44,29 @@ |
45 | 45 | return false; |
46 | 46 | } |
47 | 47 | } |
| 48 | + |
| 49 | + /** |
| 50 | + * Fields in the oldimage table |
| 51 | + */ |
| 52 | + static function selectFields() { |
| 53 | + return array( |
| 54 | + 'oi_name', |
| 55 | + 'oi_archive_name', |
| 56 | + 'oi_size', |
| 57 | + 'oi_width', |
| 58 | + 'oi_height', |
| 59 | + 'oi_metadata', |
| 60 | + 'oi_bits', |
| 61 | + 'oi_media_type', |
| 62 | + 'oi_major_mime', |
| 63 | + 'oi_minor_mime', |
| 64 | + 'oi_description', |
| 65 | + 'oi_user', |
| 66 | + 'oi_user_text', |
| 67 | + 'oi_timestamp', |
| 68 | + 'oi_sha1', |
| 69 | + ); |
| 70 | + } |
48 | 71 | |
49 | 72 | /** |
50 | 73 | * @param Title $title |
Index: trunk/phase3/includes/filerepo/LocalFile.php |
— | — | @@ -621,6 +621,9 @@ |
622 | 622 | |
623 | 623 | function getHistory($limit = null, $start = null, $end = null) { |
624 | 624 | $dbr = $this->repo->getSlaveDB(); |
| 625 | + $tables = array('oldimage'); |
| 626 | + $join_conds = array(); |
| 627 | + $fields = OldLocalFile::selectFields(); |
625 | 628 | $conds = $opts = array(); |
626 | 629 | $conds[] = "oi_name = " . $dbr->addQuotes( $this->title->getDBKey() ); |
627 | 630 | if( $start !== null ) { |
— | — | @@ -633,7 +636,10 @@ |
634 | 637 | $opts['LIMIT'] = $limit; |
635 | 638 | } |
636 | 639 | $opts['ORDER BY'] = 'oi_timestamp DESC'; |
637 | | - $res = $dbr->select('oldimage', '*', $conds, __METHOD__, $opts); |
| 640 | + |
| 641 | + wfRunHooks( 'LocalFile::getHistory', array( &$this, &$tables, &$fields, &$conds, &$opts, &$join_conds ) ); |
| 642 | + |
| 643 | + $res = $dbr->select( $tables, $fields, $conds, __METHOD__, $opts, $join_conds ); |
638 | 644 | $r = array(); |
639 | 645 | while( $row = $dbr->fetchObject($res) ) { |
640 | 646 | $r[] = OldLocalFile::newFromRow($row, $this->repo); |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -331,6 +331,7 @@ |
332 | 332 | # Mark of items in page history |
333 | 333 | $wgHooks['PageHistoryPager::getQueryInfo'][] = 'FlaggedRevs::addToHistQuery'; |
334 | 334 | $wgHooks['PageHistoryLineEnding'][] = 'FlaggedRevs::addToHistLine'; |
| 335 | +$wgHooks['LocalFile::getHistory'][] = 'FlaggedRevs::addToFileHistQuery'; |
335 | 336 | $wgHooks['ImagePageFileHistoryLine'][] = 'FlaggedRevs::addToFileHistLine'; |
336 | 337 | # Page review on edit |
337 | 338 | $wgHooks['ArticleUpdateBeforeRedirect'][] = 'FlaggedRevs::injectReviewDiffURLParams'; |
Index: trunk/extensions/FlaggedRevs/FlaggedArticle.php |
— | — | @@ -39,7 +39,7 @@ |
40 | 40 | } |
41 | 41 | # For titles, attach instance to the title and give the instance an article parent |
42 | 42 | if( $object instanceof Title ) { |
43 | | - $article = new Article( $object ); |
| 43 | + $article = MediaWiki::articleFromTitle( $object ); |
44 | 44 | $article->flaggedRevsArticle = new FlaggedArticle( $article ); |
45 | 45 | $object->flaggedRevsArticle =& $article->flaggedRevsArticle; |
46 | 46 | } else if( $object instanceof Article ) { |
— | — | @@ -794,20 +794,21 @@ |
795 | 795 | * Add link to stable version of reviewed revisions |
796 | 796 | */ |
797 | 797 | public function addToFileHistLine( $historyList, $file, &$s, &$css ) { |
798 | | - global $wgUser; |
799 | 798 | # Non-content pages cannot be validated. Stable version must exist. |
800 | 799 | if( !$this->isReviewable() || !$this->getStableRev() ) |
801 | 800 | return true; |
802 | | - # See if this is reviewed |
803 | | - # fixme: O(N) DB queries |
804 | | - $quality = wfGetDB(DB_SLAVE)->selectField( 'flaggedrevs', 'fr_quality', |
805 | | - array( 'fr_img_sha1' => $file->getSha1(), 'fr_img_timestamp' => $file->getTimestamp() ), |
806 | | - __METHOD__ ); |
807 | | - if( $quality === false ) { |
808 | | - return true; |
| 801 | + # Quality level for old versions selected all at once. |
| 802 | + if( !$file->isOld() ) { |
| 803 | + $quality = wfGetDB(DB_SLAVE)->selectField( 'flaggedrevs', 'fr_quality', |
| 804 | + array( 'fr_img_sha1' => $file->getSha1(), 'fr_img_timestamp' => $file->getTimestamp() ), |
| 805 | + __METHOD__ ); |
| 806 | + } else { |
| 807 | + $quality = is_null($file->quality) ? false : $file->quality; |
809 | 808 | } |
810 | | - $css = FlaggedRevsXML::getQualityColor( $quality ); |
811 | | - |
| 809 | + # If reviewed, class the line |
| 810 | + if( $quality !== false ) { |
| 811 | + $css = FlaggedRevsXML::getQualityColor( $quality ); |
| 812 | + } |
812 | 813 | return true; |
813 | 814 | } |
814 | 815 | |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.class.php |
— | — | @@ -2061,6 +2061,13 @@ |
2062 | 2062 | return true; |
2063 | 2063 | } |
2064 | 2064 | |
| 2065 | + static function addToFileHistQuery( $file, &$tables, &$fields, &$conds, &$opts, &$join_conds ) { |
| 2066 | + $tables[] = 'flaggedrevs'; |
| 2067 | + $fields[] = 'fr_quality'; |
| 2068 | + $join_conds['flaggedrevs'] = array( 'LEFT JOIN', 'oi_sha1 = fr_img_sha1 AND oi_timestamp = fr_img_timestamp' ); |
| 2069 | + return true; |
| 2070 | + } |
| 2071 | + |
2065 | 2072 | static function addToHistLine( $history, $row, &$s ) { |
2066 | 2073 | return FlaggedArticle::getInstance( $history->getArticle(), true )->addToHistLine( $history, $row, $s ); |
2067 | 2074 | } |