r34952 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r34951‎ | r34952 | r34953 >
Date:07:32, 17 May 2008
Author:aaron
Status:old
Tags:
Comment:
* Schema change: add fields for file info for image page revisions
* Improve behavoir for stable templates/images
* Clean up image params
* timestamp NOT NULL
* Add FlaggedRevision::selectFields() and some accessors
* Remove bogus CSS classing
* Tweak class visibility
Modified paths:
  • /trunk/extensions/FlaggedRevs/FlaggedArticle.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevision.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevs.sql (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevsPage.i18n.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/FlaggedRevsPage.php (modified) (history)
  • /trunk/extensions/FlaggedRevs/archives/patch-fr_img_name.sql (added) (history)

Diff [purge]

Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php
@@ -14,7 +14,7 @@
1515 $wgExtensionCredits['specialpage'][] = array(
1616 'name' => 'Flagged Revisions',
1717 'author' => array( 'Aaron Schulz', 'Joerg Baach' ),
18 - 'version' => '1.045',
 18+ 'version' => '1.05',
1919 'url' => 'http://www.mediawiki.org/wiki/Extension:FlaggedRevs',
2020 'descriptionmsg' => 'flaggedrevs-desc',
2121 );
@@ -461,7 +461,7 @@
462462 * @return ParserOutput
463463 */
464464 public static function parseStableText( $article, $text='', $id, $reparsed = true ) {
465 - global $wgParser;
 465+ global $wgParser, $wgUseStableTemplates;
466466 $title = $article->getTitle(); // avoid pass-by-reference error
467467 # Make our hooks to trigger
468468 $wgParser->fr_isStable = true;
@@ -478,24 +478,32 @@
479479 # Do we need to set the template uses via DB?
480480 if( $reparsed ) {
481481 $dbr = wfGetDB( DB_SLAVE );
482 - $res = $dbr->select( array('flaggedtemplates', 'revision'),
483 - array( 'ft_namespace', 'ft_title', 'ft_tmp_rev_id', 'rev_page' ),
484 - array( 'ft_rev_id' => $id, 'rev_id = ft_rev_id' ),
485 - __METHOD__ );
 482+ if( $wgUseStableTemplates ) {
 483+ $res = $dbr->select( array('flaggedtemplates','page','flaggedpages'),
 484+ array( 'ft_namespace', 'ft_title', 'fp_stable AS rev_id', 'page_id' ),
 485+ array( 'ft_rev_id' => $id, 'page_namespace = ft_namespace', 'page_title = ft_title',
 486+ 'fp_page_id = page_id' ),
 487+ __METHOD__ );
 488+ } else {
 489+ $res = $dbr->select( array('flaggedtemplates','revision'),
 490+ array( 'ft_namespace', 'ft_title', 'ft_tmp_rev_id AS rev_id', 'rev_page AS page_id' ),
 491+ array( 'ft_rev_id' => $id, 'rev_id = ft_rev_id' ),
 492+ __METHOD__ );
 493+ }
486494 # Add template metadata to output
487495 $maxTempID = 0;
488496 while( $row = $res->fetchObject() ) {
489497 if( !isset($parserOut->mTemplates[$row->ft_namespace]) ) {
490498 $parserOut->mTemplates[$row->ft_namespace] = array();
491499 }
492 - $parserOut->mTemplates[$row->ft_namespace][$row->ft_title] = $row->rev_page;
 500+ $parserOut->mTemplates[$row->ft_namespace][$row->ft_title] = $row->page_id;
493501
494502 if( !isset($parserOut->mTemplateIds[$row->ft_namespace]) ) {
495503 $parserOut->mTemplateIds[$row->ft_namespace] = array();
496504 }
497 - $parserOut->mTemplateIds[$row->ft_namespace][$row->ft_title] = $row->ft_tmp_rev_id;
498 - if( $row->ft_tmp_rev_id > $maxTempID ) {
499 - $maxTempID = $row->ft_tmp_rev_id;
 505+ $parserOut->mTemplateIds[$row->ft_namespace][$row->ft_title] = $row->rev_id;
 506+ if( $row->rev_id > $maxTempID ) {
 507+ $maxTempID = $row->rev_id;
500508 }
501509 }
502510 $parserOut->fr_newestTemplateID = $maxTempID;
@@ -666,7 +674,7 @@
667675 * Will not return a revision if deleted
668676 */
669677 public static function getFlaggedRev( $title, $rev_id, $getText=false, $forUpdate=false, $page_id=false ) {
670 - $columns = array('fr_rev_id','fr_page_id','fr_user','fr_timestamp','fr_comment','fr_quality','fr_tags');
 678+ $columns = FlaggedRevision::selectFields();
671679 if( $getText ) {
672680 $columns[] = 'fr_text';
673681 $columns[] = 'fr_flags';
@@ -778,7 +786,7 @@
779787 * @returns mixed FlaggedRevision (null on failure)
780788 */
781789 public static function getStablePageRev( $title, $getText=false, $forUpdate=false ) {
782 - $columns = array('fr_rev_id','fr_page_id','fr_user','fr_timestamp','fr_comment','fr_quality','fr_tags');
 790+ $columns = FlaggedRevision::selectFields();
783791 if( $getText ) {
784792 $columns[] = 'fr_text';
785793 $columns[] = 'fr_flags';
@@ -1250,8 +1258,8 @@
12511259 $parserCache->save( $poutput, $article, $user );
12521260 }
12531261 # NS:title -> rev ID mapping
1254 - foreach( $poutput->mTemplateIds as $namespace => $title ) {
1255 - foreach( $title as $dbkey => $id ) {
 1262+ foreach( $poutput->mTemplateIds as $namespace => $titleAndID ) {
 1263+ foreach( $titleAndID as $dbkey => $id ) {
12561264 $tmpset[] = array(
12571265 'ft_rev_id' => $rev->getId(),
12581266 'ft_namespace' => $namespace,
@@ -1313,17 +1321,28 @@
13141322 $textFlags .= 'external';
13151323 }
13161324
 1325+ # If this is an image page, store corresponding file info
 1326+ $fileData = array();
 1327+ if( $title->getNamespace() == NS_IMAGE && $file = wfFindFile($title) ) {
 1328+ $fileData['name'] = $title->getDBkey();
 1329+ $fileData['timestamp'] = $file->getTimestamp();
 1330+ $fileData['sha1'] = $file->getSha1();
 1331+ }
 1332+
13171333 # Our review entry
13181334 $revisionset = array(
1319 - 'fr_page_id' => $rev->getPage(),
1320 - 'fr_rev_id' => $rev->getId(),
1321 - 'fr_user' => $user->getId(),
1322 - 'fr_timestamp' => $dbw->timestamp( wfTimestampNow() ),
1323 - 'fr_comment' => "",
1324 - 'fr_quality' => $quality,
1325 - 'fr_tags' => self::flattenRevisionTags( $flags ),
1326 - 'fr_text' => $fulltext, # Store expanded text for speed
1327 - 'fr_flags' => $textFlags
 1335+ 'fr_page_id' => $rev->getPage(),
 1336+ 'fr_rev_id' => $rev->getId(),
 1337+ 'fr_user' => $user->getId(),
 1338+ 'fr_timestamp' => $dbw->timestamp( wfTimestampNow() ),
 1339+ 'fr_comment' => "",
 1340+ 'fr_quality' => $quality,
 1341+ 'fr_tags' => self::flattenRevisionTags( $flags ),
 1342+ 'fr_text' => $fulltext, # Store expanded text for speed
 1343+ 'fr_flags' => $textFlags,
 1344+ 'fr_img_name' => $fileData ? $fileData['name'] : null,
 1345+ 'fr_img_timestamp' => $fileData ? $fileData['timestamp'] : null,
 1346+ 'fr_img_sha1' => $fileData ? $fileData['sha1'] : null
13281347 );
13291348 # Update flagged revisions table
13301349 $dbw->replace( 'flaggedrevs',
@@ -1658,14 +1677,21 @@
16591678 $sha1 = "";
16601679 global $wgUseStableImages;
16611680 if( $wgUseStableImages && self::isPageReviewable( $nt ) ) {
1662 - $row = $dbw->selectRow( array('flaggedpages', 'flaggedimages'),
1663 - array( 'fi_img_timestamp', 'fi_img_sha1' ),
1664 - array( 'fp_page_id' => $nt->getArticleId(),
1665 - 'fp_stable = fi_rev_id',
1666 - 'fi_name' => $nt->getDBkey() ),
1667 - __METHOD__ );
1668 - $time = $row ? $row->fi_img_timestamp : $time;
1669 - $sha1 = $row ? $row->fi_img_sha1 : $sha1;
 1681+ $srev = self::getStablePageRev( $nt, false, true );
 1682+ if( $srev ) {
 1683+ $time = $srev->getFileTimestamp();
 1684+ $sha1 = $srev->getFileSha1();
 1685+ // B/C, may be stored in associated image version metadata table
 1686+ if( !$time || !$sha1 ) {
 1687+ $row = $dbw->selectRow( 'flaggedimages',
 1688+ array( 'fi_img_timestamp', 'fi_img_sha1' ),
 1689+ array( 'fi_rev_id' => $srev->getRevId(),
 1690+ 'fi_name' => $nt->getDBkey() ),
 1691+ __METHOD__ );
 1692+ $time = $row ? $row->fi_img_timestamp : $time;
 1693+ $sha1 = $row ? $row->fi_img_sha1 : $sha1;
 1694+ }
 1695+ }
16701696 }
16711697 # If there is no stable version (or that feature is not enabled), use
16721698 # the image revision during review time.
@@ -1720,14 +1746,21 @@
17211747 $sha1 = "";
17221748 global $wgUseStableImages;
17231749 if( $wgUseStableImages && self::isPageReviewable( $nt ) ) {
1724 - $row = $dbw->selectRow( array('flaggedpages', 'flaggedimages'),
1725 - array( 'fi_img_timestamp', 'fi_img_sha1' ),
1726 - array( 'fp_page_id' => $nt->getArticleId(),
1727 - 'fp_stable = fi_rev_id',
1728 - 'fi_name' => $nt->getDBkey() ),
1729 - __METHOD__ );
1730 - $time = $row ? $row->fi_img_timestamp : $time;
1731 - $sha1 = $row ? $row->fi_img_sha1 : $sha1;
 1750+ $srev = self::getStablePageRev( $nt, false, true );
 1751+ if( $srev ) {
 1752+ $time = $srev->getFileTimestamp();
 1753+ $sha1 = $srev->getFileSha1();
 1754+ // B/C, may be stored in associated image version metadata table
 1755+ if( !$time || !$sha1 ) {
 1756+ $row = $dbw->selectRow( 'flaggedimages',
 1757+ array( 'fi_img_timestamp', 'fi_img_sha1' ),
 1758+ array( 'fi_rev_id' => $srev->getRevId(),
 1759+ 'fi_name' => $nt->getDBkey() ),
 1760+ __METHOD__ );
 1761+ $time = $row ? $row->fi_img_timestamp : $time;
 1762+ $sha1 = $row ? $row->fi_img_sha1 : $sha1;
 1763+ }
 1764+ }
17321765 }
17331766 # If there is no stable version (or that feature is not enabled), use
17341767 # the image revision during review time.
@@ -2355,6 +2388,7 @@
23562389 $wgExtNewIndexes[] = array('flaggedpage_config', 'fpc_expiry', "$base/archives/patch-expiry-index.sql" );
23572390 $wgExtNewTables[] = array( 'flaggedrevs_promote', "$base/archives/patch-flaggedrevs_promote.sql" );
23582391 $wgExtNewTables[] = array( 'flaggedpages', "$base/archives/patch-flaggedpages.sql" );
 2392+ $wgExtNewFields[] = array( 'flaggedrevs', 'fr_img_name', "$base/archives/patch-fr_img_name.sql" );
23592393 } else if( $wgDBtype == 'postgres' ) {
23602394 $wgExtPGNewFields[] = array('flaggedpage_config', 'fpc_expiry', "TIMESTAMPTZ NULL" );
23612395 $wgExtNewIndexes[] = array('flaggedpage_config', 'fpc_expiry', "$base/postgres/patch-expiry-index.sql" );
Index: trunk/extensions/FlaggedRevs/FlaggedArticle.php
@@ -2,10 +2,11 @@
33
44 class FlaggedArticle extends Article {
55 public $isDiffFromStable = false;
6 - public $stableRev = null;
7 - public $pageconfig = null;
8 - public $flags = null;
 6+ protected $stableRev = null;
 7+ protected $pageconfig = null;
 8+ protected $flags = null;
99 protected $reviewNotice = '';
 10+ protected $file = NULL;
1011 /**
1112 * Does the config and current URL params allow
1213 * for overriding by stable revisions?
@@ -360,6 +361,10 @@
361362 * Set the image revision to display
362363 */
363364 public function setImageVersion() {
 365+ global $wgArticle;
 366+ if( !$wgArticle instanceof ImagePage ) {
 367+ return false;
 368+ }
364369 if( $this->getTitle()->getNamespace() == NS_IMAGE && $this->isReviewable() ) {
365370 global $wgRequest;
366371 # A reviewed version may have explicitly been requested...
@@ -370,14 +375,20 @@
371376 $frev = $this->getStableRev( true );
372377 }
373378 if( !is_null($frev) ) {
374 - $dbr = wfGetDB( DB_SLAVE );
375 - $time = $dbr->selectField( 'flaggedimages', 'fi_img_timestamp',
376 - array( 'fi_rev_id' => $frev->getRevId(),
377 - 'fi_name' => $this->getTitle()->getDBkey() ),
378 - __METHOD__ );
 379+ $timestamp = $frev->getFileTimestamp();
 380+ // B/C, may be stored in associated image version metadata table
 381+ if( !$timestamp ) {
 382+ $dbr = wfGetDB( DB_SLAVE );
 383+ $timestamp = $dbr->selectField( 'flaggedimages',
 384+ 'fi_img_timestamp',
 385+ array( 'fi_rev_id' => $frev->getRevId(),
 386+ 'fi_name' => $this->getTitle()->getDBkey() ),
 387+ __METHOD__ );
 388+ }
379389 # NOTE: if not found, this will use the current
380 - $article = new ImagePage( $this->getTitle(), $time );
 390+ $wgArticle = new ImagePage( $this->getTitle(), $timestamp );
381391 }
 392+ $this->file = $wgArticle->getFile();
382393 }
383394 return true;
384395 }
@@ -488,7 +499,7 @@
489500 return true;
490501 }
491502 # Add review form
492 - $this->addQuickReview( $out, $wgRequest->getVal('diff') );
 503+ $this->addQuickReview( $out, (bool)$wgRequest->getVal('diff') );
493504
494505 return true;
495506 }
@@ -667,12 +678,14 @@
668679 # Use same DB object
669680 $this->dbr = isset($this->dbr) ? $this->dbr : wfGetDB( DB_SLAVE );
670681 $skin = $wgUser->getSkin();
671 - # Get corresponding title
672 - $rev = Revision::loadFromTimestamp( $this->dbr, $this->getTitle(), $file->getTimestamp() );
673 - if( !$rev ) {
 682+ # See if this is reivewed
 683+ $quality = $this->dbr->selectField( 'flaggedrevs', 'fr_quality',
 684+ array( 'fr_img_sha1' => $file->getSha1(), 'fr_img_timestamp' => $file->getTimestamp() ),
 685+ __METHOD__ );
 686+ if( $quality === false ) {
674687 return true;
675688 }
676 - list($link,$css) = FlaggedRevs::makeStableVersionLink( $this->getTitle(), $rev->getId(), $skin, $this->dbr );
 689+ $css = FlaggedRevs::getQualityColor( $quality );
677690 return true;
678691 }
679692
@@ -709,45 +722,79 @@
710723 if( $frev && $frev->getRevId() == $OldRev->getID() ) {
711724 $changeList = array();
712725 $skin = $wgUser->getSkin();
 726+
713727 # Make a list of each changed template...
714728 $dbr = wfGetDB( DB_SLAVE );
715 - $ret = $dbr->select( array('flaggedtemplates','page'),
716 - array( 'ft_namespace', 'ft_title', 'ft_tmp_rev_id' ),
717 - array( 'ft_rev_id' => $frev->getRevId(),
718 - 'ft_namespace = page_namespace',
719 - 'ft_title = page_title',
720 - 'ft_tmp_rev_id != page_latest' ),
721 - __METHOD__ );
722 -
 729+ global $wgUseStableTemplates;
 730+ if( $wgUseStableTemplates ) {
 731+ $ret = $dbr->select( array('flaggedtemplates','page','flaggedpages'),
 732+ array( 'ft_namespace', 'ft_title', 'ft_tmp_rev_id' ),
 733+ array( 'ft_rev_id' => $frev->getRevId(),
 734+ 'page_namespace = ft_namespace',
 735+ 'page_title = ft_title',
 736+ 'fp_page_id = page_id',
 737+ 'fp_stable != page_latest' ),
 738+ __METHOD__ );
 739+ } else {
 740+ $ret = $dbr->select( array('flaggedtemplates','page'),
 741+ array( 'ft_namespace', 'ft_title', 'ft_tmp_rev_id' ),
 742+ array( 'ft_rev_id' => $frev->getRevId(),
 743+ 'page_namespace = ft_namespace',
 744+ 'page_title = ft_title',
 745+ 'ft_tmp_rev_id != page_latest' ),
 746+ __METHOD__ );
 747+ }
723748 while( $row = $dbr->fetchObject( $ret ) ) {
724749 $title = Title::makeTitle( $row->ft_namespace, $row->ft_title );
725750 $changeList[] = $skin->makeKnownLinkObj( $title, $title->GetPrefixedText(),
726751 "diff=cur&oldid=" . $row->ft_tmp_rev_id );
727752 }
 753+
728754 # And images...
729 - $ret = $dbr->select( array('flaggedimages','image'),
730 - array( 'fi_name' ),
731 - array( 'fi_rev_id' => $frev->getRevId(),
732 - 'fi_name = img_name',
733 - 'fi_img_sha1 != img_sha1' ),
734 - __METHOD__ );
735 -
 755+ global $wgUseStableImages;
 756+ if( $wgUseStableImages ) {
 757+ $ret = $dbr->select( array('flaggedimages','page','flaggedpages','flaggedrevs','image'),
 758+ array( 'fi_name' ),
 759+ array( 'fi_rev_id' => $frev->getRevId(),
 760+ 'page_namespace' => NS_IMAGE,
 761+ 'page_title = fi_name',
 762+ 'fp_page_id = page_id',
 763+ 'fr_page_id = page_id',
 764+ 'fr_rev_id = fp_stable',
 765+ 'img_name = fi_name',
 766+ 'fr_img_sha1 != img_sha1' ),
 767+ __METHOD__ );
 768+ } else {
 769+ $ret = $dbr->select( array('flaggedimages','image'),
 770+ array( 'fi_name' ),
 771+ array( 'fi_rev_id' => $frev->getRevId(),
 772+ 'fi_name = img_name',
 773+ 'fi_img_sha1 != img_sha1' ),
 774+ __METHOD__ );
 775+ }
736776 while( $row = $dbr->fetchObject( $ret ) ) {
737777 $title = Title::makeTitle( NS_IMAGE, $row->fi_name );
738778 $changeList[] = $skin->makeKnownLinkObj( $title );
739779 }
 780+
 781+ # Some important information...
 782+ if( ($wgUseStableTemplates || $wgUseStableImages) && !empty($changeList) ) {
 783+ $notice = '<br/>'.wfMsgExt('revreview-update-use', array('parseinline'));
 784+ } else {
 785+ $notice = "";
 786+ }
740787 # If the user is allowed to review, prompt them!
741788 if( empty($changeList) && $wgUser->isAllowed('review') ) {
742789 $wgOut->addHTML( "<div id='mw-difftostable' class='flaggedrevs_diffnotice plainlinks'>" .
743 - wfMsgExt('revreview-update-none', array('parseinline')).'</div>' );
 790+ wfMsgExt('revreview-update-none', array('parseinline')).$notice.'</div>' );
744791 } else if( !empty($changeList) && $wgUser->isAllowed('review') ) {
745792 $changeList = implode(', ',$changeList);
746793 $wgOut->addHTML( "<div id='mw-difftostable' class='flaggedrevs_diffnotice plainlinks'>" .
747 - wfMsgExt('revreview-update', array('parseinline')) . '&nbsp;' . $changeList . '</div>' );
 794+ wfMsgExt('revreview-update', array('parseinline')).'&nbsp;'.$changeList.$notice.'</div>' );
748795 } else if( !empty($changeList) ) {
749796 $changeList = implode(', ',$changeList);
750797 $wgOut->addHTML( "<div id='mw-difftostable' class='flaggedrevs_diffnotice plainlinks'>" .
751 - wfMsgExt('revreview-update-includes', array('parseinline')) . '&nbsp;' . $changeList . '</div>' );
 798+ wfMsgExt('revreview-update-includes', array('parseinline')).'&nbsp;'.$changeList.$notice.'</div>' );
752799 }
753800 # Set flag for review form to tell it to autoselect tag settings from the
754801 # old revision unless the current one is tagged to.
@@ -760,13 +807,15 @@
761808 $oldRevQ = $OldRev ? FlaggedRevs::getRevQuality( $NewRev->getTitle(), $OldRev->getId() ) : false;
762809 # Diff between two revisions
763810 if( $OldRev ) {
 811+ $wgOut->addHTML( "<table class='fr-diff-ratings' width='100%'><tr>" );
 812+
764813 $css = FlaggedRevs::getQualityColor( $oldRevQ );
765814 if( $oldRevQ !== false ) {
766815 $msg = $oldRevQ ? 'hist-quality' : 'hist-stable';
767816 } else {
768817 $msg = 'hist-draft';
769818 }
770 - $wgOut->addHTML( "<table class='fr-diff-ratings' width='100%'><tr><td class='fr-$msg' width='50%' align='center'>" );
 819+ $wgOut->addHTML( "<td width='50%' align='center'>" );
771820 $wgOut->addHTML( "<span class='$css'><b>[" . wfMsgHtml( $msg ) . "]</b></span>" );
772821
773822 $css = FlaggedRevs::getQualityColor( $newRevQ );
@@ -775,7 +824,7 @@
776825 } else {
777826 $msg = 'hist-draft';
778827 }
779 - $wgOut->addHTML( "</td><td class='fr-$msg' width='50%' align='center'>" );
 828+ $wgOut->addHTML( "</td><td width='50%' align='center'>" );
780829 $wgOut->addHTML( "<span class='$css'><b>[" . wfMsgHtml( $msg ) . "]</b></span>" );
781830
782831 $wgOut->addHTML( '</td></tr></table>' );
@@ -1110,11 +1159,8 @@
11111160 }
11121161 }
11131162 # For image pages, note the current image version
1114 - if( $this->getTitle()->getNamespace() == NS_IMAGE ) {
1115 - $file = wfFindFile( $this->getTitle() );
1116 - if( $file ) {
1117 - $imageParams .= $this->getTitle()->getDBkey() . "|" . $file->getTimestamp() . "|" . $file->getSha1() . "#";
1118 - }
 1163+ if( $this->getTitle()->getNamespace() == NS_IMAGE && $this->file ) {
 1164+ $imageParams .= $this->getTitle()->getDBkey() . "|" . $this->file->getTimestamp() . "|" . $this->file->getSha1() . "#";
11191165 }
11201166
11211167 # Hidden params
Index: trunk/extensions/FlaggedRevs/archives/patch-fr_img_name.sql
@@ -0,0 +1,9 @@
 2+-- Add file metadata for flaggedrevs of image pages
 3+ALTER TABLE /*$wgDBprefix*/flaggedrevs
 4+ -- Name of included image
 5+ ADD fr_img_name varchar(255) binary NULL default NULL,
 6+ -- Timestamp of file (when uploaded)
 7+ ADD fr_img_timestamp char(14) NULL default NULL,
 8+ -- Statistically unique SHA-1 key
 9+ ADD fr_img_sha1 varbinary(32) NULL default NULL,
 10+ ADD INDEX key_timestamp (fr_img_sha1,fr_img_timestamp);
Property changes on: trunk/extensions/FlaggedRevs/archives/patch-fr_img_name.sql
___________________________________________________________________
Name: svn:eol-style
111 + native
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.sql
@@ -19,8 +19,7 @@
2020 INDEX fp_quality_page (fp_quality,fp_page_id)
2121 ) TYPE=InnoDB;
2222
 23+-- This stores all of our rev reviews
2324 CREATE TABLE /*$wgDBprefix*/flaggedrevs (
2425 -- Foreign key to page.page_id
2526 fr_page_id integer NOT NULL,
@@ -43,8 +42,16 @@
4443 -- utf8: in UTF-8
4544 -- external: the fr_text column is a url to an external storage object
4645 fr_flags tinyblob NOT NULL,
 46+ -- Parameters for revisions of Image pages:
 47+ -- Name of included image (NULL if n/a)
 48+ fr_img_name varchar(255) binary NULL default NULL,
 49+ -- Timestamp of file (when uploaded) (NULL if n/a)
 50+ fr_img_timestamp char(14) NULL default NULL,
 51+ -- Statistically unique SHA-1 key (NULL if n/a)
 52+ fr_img_sha1 varbinary(32) NULL default NULL,
4753
4854 PRIMARY KEY (fr_page_id,fr_rev_id),
 55+ INDEX key_timestamp (fr_img_sha1,fr_img_timestamp),
4956 INDEX page_qal_rev (fr_page_id,fr_quality,fr_rev_id)
5057 ) TYPE=InnoDB;
5158
@@ -82,7 +89,7 @@
8390 -- Name of included image
8491 fi_name varchar(255) binary NOT NULL default '',
8592 -- Timestamp of image used when reviewed
86 - fi_img_timestamp char(14) NULL,
 93+ fi_img_timestamp char(14) NOT NULL,
8794 -- Statistically unique SHA-1 key
8895 fi_img_sha1 varbinary(32) NOT NULL default '',
8996
Index: trunk/extensions/FlaggedRevs/FlaggedRevsPage.i18n.php
@@ -96,6 +96,8 @@
9797 '''Some templates/images were updated:'''",
9898 'revreview-update-none' => "Please [[{{MediaWiki:Validationpage}}|review]] any changes ''(shown below)'' made since the stable revision was [{{fullurl:Special:Log|type=review&page={{FULLPAGENAMEE}}}} approved].",
9999 'revreview-update-includes' => "'''Some templates/images were updated:'''",
 100+ 'revreview-update-use' => "'''NOTE:''' If any of these templates/images have a stable version, then it is already used in the stable version of this page.",
 101+
100102 'revreview-auto' => '(automatic)',
101103 'revreview-auto-w' => "You are editing the stable revision; changes will '''automatically be reviewed'''.",
102104 'revreview-auto-w-old' => "You are editing a reviewed revision; changes will '''automatically be reviewed'''.",
Index: trunk/extensions/FlaggedRevs/FlaggedRevsPage.php
@@ -423,6 +423,8 @@
424424 # Our image version pointers
425425 $imgset = array();
426426 $imageMap = explode('#',trim($this->imageParams) );
 427+ # If this is an image page, store corresponding file info
 428+ $fileData = array();
427429 foreach( $imageMap as $image ) {
428430 if( !$image )
429431 continue;
@@ -437,6 +439,14 @@
438440 if( is_null($img_title) )
439441 continue; // Page must be valid!
440442
 443+ # Is this parameter for THIS image itself?
 444+ if( $title->equals($img_title) ) {
 445+ $fileData['name'] = $img_title->getDBkey();
 446+ $fileData['timestamp'] = $timestamp;
 447+ $fileData['sha1'] = $key;
 448+ continue;
 449+ }
 450+
441451 if( $timestamp > $lastImgTime )
442452 $lastImgTime = $timestamp;
443453
@@ -536,15 +546,18 @@
537547
538548 # Our review entry
539549 $revset = array(
540 - 'fr_rev_id' => $rev->getId(),
541 - 'fr_page_id' => $title->getArticleID(),
542 - 'fr_user' => $wgUser->getId(),
543 - 'fr_timestamp' => $dbw->timestamp( wfTimestampNow() ),
544 - 'fr_comment' => $this->notes,
545 - 'fr_quality' => $quality,
546 - 'fr_tags' => FlaggedRevs::flattenRevisionTags( $flags ),
547 - 'fr_text' => $fulltext, # Store expanded text for speed
548 - 'fr_flags' => $textFlags
 550+ 'fr_rev_id' => $rev->getId(),
 551+ 'fr_page_id' => $title->getArticleID(),
 552+ 'fr_user' => $wgUser->getId(),
 553+ 'fr_timestamp' => $dbw->timestamp( wfTimestampNow() ),
 554+ 'fr_comment' => $this->notes,
 555+ 'fr_quality' => $quality,
 556+ 'fr_tags' => FlaggedRevs::flattenRevisionTags( $flags ),
 557+ 'fr_text' => $fulltext, # Store expanded text for speed
 558+ 'fr_flags' => $textFlags,
 559+ 'fr_img_name' => $fileData ? $fileData['name'] : null,
 560+ 'fr_img_timestamp' => $fileData ? $fileData['timestamp'] : null,
 561+ 'fr_img_sha1' => $fileData ? $fileData['sha1'] : null
549562 );
550563
551564 # Update flagged revisions table
Index: trunk/extensions/FlaggedRevs/FlaggedRevision.php
@@ -13,6 +13,9 @@
1414 private $mUser;
1515 private $mTitle;
1616 private $mRevision;
 17+ private $mFileName;
 18+ private $mFileSha1;
 19+ private $mFileTimestamp;
1720
1821 /**
1922 * @param Title $title
@@ -27,6 +30,9 @@
2831 $this->mComment = $row->fr_comment;
2932 $this->mQuality = intval( $row->fr_quality );
3033 $this->mTags = FlaggedRevs::expandRevisionTags( strval($row->fr_tags) );
 34+ $this->mFileName = $row->fr_img_name ? $row->fr_img_name : null;
 35+ $this->mFileSha1 = $row->fr_img_sha1 ? $row->fr_img_sha1 : null;
 36+ $this->mFileTimestamp = $row->fr_img_timestamp ? $row->fr_img_timestamp : null;
3137 # Optional fields
3238 $this->mUser = isset($row->fr_user) ? $row->fr_user : 0;
3339 $this->mFlags = isset($row->fr_flags) ? explode(',',$row->fr_flags) : null;
@@ -34,6 +40,11 @@
3541 # Deal with as it comes
3642 $this->mText = null;
3743 }
 44+
 45+ public static function selectFields() {
 46+ return array('fr_rev_id','fr_page_id','fr_user','fr_timestamp','fr_comment','fr_quality','fr_tags',
 47+ 'fr_img_name', 'fr_img_sha1', 'fr_img_timestamp');
 48+ }
3849
3950 /**
4051 * @returns Integer revision ID
@@ -118,6 +129,30 @@
119130 }
120131
121132 /**
 133+ * @returns string, filename accosciated with this revision.
 134+ * This returns NULL for non-image page revisions.
 135+ */
 136+ public function getFileName() {
 137+ return $this->mFileName;
 138+ }
 139+
 140+ /**
 141+ * @returns string, sha1 key accosciated with this revision.
 142+ * This returns NULL for non-image page revisions.
 143+ */
 144+ public function getFileSha1() {
 145+ return $this->mFileSha1;
 146+ }
 147+
 148+ /**
 149+ * @returns string, timestamp accosciated with this revision.
 150+ * This returns NULL for non-image page revisions.
 151+ */
 152+ public function getFileTimestamp() {
 153+ return $this->mFileTimestamp;
 154+ }
 155+
 156+ /**
122157 * @returns bool
123158 */
124159 public function userCanSetFlags() {

Status & tagging log