r92317 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r92316‎ | r92317 | r92318 >
Date:21:53, 15 July 2011
Author:reedy
Status:deferred
Tags:
Comment:
Modified paths:
  • /branches/REL1_18/extensions/FlaggedRevs (modified) (history)
  • /branches/REL1_18/extensions/FlaggedRevs/api/FlaggedRevsApi.hooks.php (modified) (history)
  • /branches/REL1_18/extensions/FlaggedRevs/business/RevisionReviewForm.php (modified) (history)
  • /branches/REL1_18/extensions/FlaggedRevs/dataclasses/FlaggedRevision.php (modified) (history)
  • /branches/REL1_18/extensions/FlaggedRevs/presentation/FlaggedPageView.php (modified) (history)
  • /branches/REL1_18/extensions/FlaggedRevs/presentation/FlaggedRevsUI.hooks.php (modified) (history)
  • /branches/REL1_18/extensions/FlaggedRevs/presentation/modules/flaggedrevs.css (modified) (history)
  • /branches/REL1_18/extensions/FlaggedRevs/presentation/specialpages/reports/ReviewedVersions_body.php (modified) (history)
  • /branches/REL1_18/extensions/FlaggedRevs/schema/FlaggedRevsUpdater.hooks.php (modified) (history)
  • /branches/REL1_18/extensions/FlaggedRevs/tests/FRUserCountersTest.php (modified) (history)

Diff [purge]

Index: branches/REL1_18/extensions/FlaggedRevs/schema/FlaggedRevsUpdater.hooks.php
@@ -33,8 +33,8 @@
3434 'flaggedrevs_stats', "$base/patch-flaggedrevs_stats.sql", true ) );
3535 $du->addExtensionUpdate( array( 'FlaggedRevsUpdaterHooks::doFlaggedImagesTimestampNULL',
3636 "$base/patch-fi_img_timestamp.sql" ) );
37 - $du->addExtensionUpdate( array( 'addIndex',
38 - 'flaggedrevs', 'page_rev', "$base/patch-fr_page_rev-index.sql", true ) );
 37+ $du->addExtensionUpdate( array( 'FlaggedRevsUpdaterHooks::doFlaggedRevsRevTimestamp',
 38+ "$base/patch-fr_page_rev-index.sql" ) );
3939 } elseif ( $wgDBtype == 'postgres' ) {
4040 $base = dirname( __FILE__ ) . '/postgres';
4141 // Initial install tables (current schema)
@@ -62,8 +62,8 @@
6363 // @TODO: PG stats table???
6464 $du->addExtensionUpdate( array( 'FlaggedRevsUpdaterHooks::doFlaggedImagesTimestampNULL',
6565 "$base/patch-fi_img_timestamp.sql" ) );
66 - $du->addExtensionUpdate( array( 'addIndex',
67 - 'flaggedrevs', 'page_rev', "$base/patch-fr_page_rev-index.sql", true ) );
 66+ $du->addExtensionUpdate( array( 'FlaggedRevsUpdaterHooks::doFlaggedRevsRevTimestamp',
 67+ "$base/patch-fr_page_rev-index.sql" ) );
6868 } elseif ( $wgDBtype == 'sqlite' ) {
6969 $base = dirname( __FILE__ ) . '/mysql';
7070 $du->addExtensionUpdate( array( 'addTable',
@@ -82,4 +82,21 @@
8383 $du->getDB()->sourceFile( $patch );
8484 $du->output( "done.\n" );
8585 }
 86+
 87+ public static function doFlaggedRevsRevTimestamp( $du, $patch ) {
 88+ $exists = $du->getDB()->fieldInfo( 'flaggedrevs', 'fr_rev_timestamp' );
 89+ if ( $exists ) {
 90+ $du->output( "...fr_rev_timestamp already exists.\n" );
 91+ return;
 92+ }
 93+ include_once( dirname( __FILE__ ) . "/../maintenance/populateRevTimestamp.inc" );
 94+ if ( !function_exists( 'populate_fr_rev_timestamp' ) ) {
 95+ $du->output( "...populateRevTimestamp.inc missing! Aborting fr_rev_timestamp update.\n" );
 96+ return; // sanity
 97+ }
 98+ $du->output( "Adding fr_rev_timestamp and redoing flaggedrevs table indexes... " );
 99+ $du->getDB()->sourceFile( $patch );
 100+ populate_fr_rev_timestamp( 0 );
 101+ $du->output( "done.\n" );
 102+ }
86103 }
Index: branches/REL1_18/extensions/FlaggedRevs/tests/FRUserCountersTest.php
@@ -69,6 +69,7 @@
7070 FRUserCounters::updateUserParams( $copyP, $article, "edit summary" );
7171 $this->assertEquals( $p['totalContentEdits']+1, $copyP['totalContentEdits'],
7272 "Content edit count on content edit" );
 73+
7374 $expected = $p['uniqueContentPages'];
7475 $expected[] = 0;
7576 $this->assertEquals( $expected, $copyP['uniqueContentPages'],
@@ -85,6 +86,9 @@
8687 $copyP = $p;
8788 FRUserCounters::updateUserParams( $copyP, $article, "/* section */" );
8889 $this->assertEquals( $p['editComments'], $copyP['editComments'], "Auto summary" );
 90+
 91+ $title = Title::makeTitleSafe( 4, 'helloworld' );
 92+ $article = new Article( $title );
8993
9094 $copyP = $p;
9195 FRUserCounters::updateUserParams( $copyP, $article, "edit summary" );
Index: branches/REL1_18/extensions/FlaggedRevs/dataclasses/FlaggedRevision.php
@@ -297,7 +297,7 @@
298298 $revRow = array(
299299 'fr_page_id' => $this->getPage(),
300300 'fr_rev_id' => $this->getRevId(),
301 - 'fr_rev_timestamp' => $this->getRevTimestamp(),
 301+ 'fr_rev_timestamp' => $dbw->timestamp( $this->getRevTimestamp() ),
302302 'fr_user' => $this->mUser,
303303 'fr_timestamp' => $dbw->timestamp( $this->mTimestamp ),
304304 'fr_quality' => $this->mQuality,
@@ -307,19 +307,15 @@
308308 'fr_img_timestamp' => $dbw->timestampOrNull( $this->mFileTimestamp ),
309309 'fr_img_sha1' => $this->mFileSha1
310310 );
311 - # Update flagged revisions table
312 - $dbw->replace( 'flaggedrevs',
313 - array( array( 'fr_page_id', 'fr_rev_id' ) ), $revRow, __METHOD__ );
314 - # Clear out any previous garbage...
315 - $dbw->delete( 'flaggedtemplates',
316 - array( 'ft_rev_id' => $this->getRevId() ), __METHOD__ );
 311+ # Update the main flagged revisions table...
 312+ $dbw->insert( 'flaggedrevs', $revRow, __METHOD__, 'IGNORE' );
 313+ if ( !$dbw->affectedRows() ) {
 314+ return false; // duplicate review
 315+ }
317316 # ...and insert template version data
318317 if ( $tmpInsertRows ) {
319318 $dbw->insert( 'flaggedtemplates', $tmpInsertRows, __METHOD__, 'IGNORE' );
320319 }
321 - # Clear out any previous garbage...
322 - $dbw->delete( 'flaggedimages',
323 - array( 'fi_rev_id' => $this->getRevId() ), __METHOD__ );
324320 # ...and insert file version data
325321 if ( $fileInsertRows ) {
326322 $dbw->insert( 'flaggedimages', $fileInsertRows, __METHOD__, 'IGNORE' );
@@ -336,8 +332,12 @@
337333 $dbw = wfGetDB( DB_MASTER );
338334 # Delete from flaggedrevs table
339335 $dbw->delete( 'flaggedrevs',
 336+<<<<<<< .working
340337 array( 'fr_page_id' => $this->getPage(), 'fr_rev_id' => $this->getRevId() ),
341338 __METHOD__ );
 339+=======
 340+ array( 'fr_rev_id' => $this->getRevId() ), __METHOD__ );
 341+>>>>>>> .merge-right.r87690
342342 # Wipe versioning params...
343343 $dbw->delete( 'flaggedtemplates',
344344 array( 'ft_rev_id' => $this->getRevId() ), __METHOD__ );
Index: branches/REL1_18/extensions/FlaggedRevs/api/FlaggedRevsApi.hooks.php
@@ -62,7 +62,7 @@
6363 'fr_rev_id' => array_keys( $revids ) ), LIST_AND );
6464 }
6565 $module->addWhere( $db->makeList( $where, LIST_OR ) );
66 - $module->addOption( 'USE INDEX', array( 'flaggedrevs' => 'PRIMARY' ) );
 66+ //$module->addOption( 'USE INDEX', array( 'flaggedrevs' => 'page_rev' ) );
6767
6868 $res = $module->select( __METHOD__ );
6969
Index: branches/REL1_18/extensions/FlaggedRevs/business/RevisionReviewForm.php
@@ -305,9 +305,17 @@
306306 return 'review_cannot_undo';
307307 }
308308 $baseRevId = $newRev->isCurrent() ? $oldRev->getId() : 0;
309 - $article->doEdit( $new_text, $this->getComment(), 0, $baseRevId, $this->user );
 309+
 310+ # Actually make the edit...
 311+ $editStatus = $article->doEdit(
 312+ $new_text, $this->getComment(), 0, $baseRevId, $this->user );
 313+
 314+ $status = $editStatus->isOK() ? true : 'review_cannot_undo';
310315 # If this undid one edit by another logged-in user, update user tallies
311 - if ( $newRev->getParentId() == $oldRev->getId() && $newRev->getRawUser() ) {
 316+ if ( $status === true
 317+ && $newRev->getParentId() == $oldRev->getId()
 318+ && $newRev->getRawUser() )
 319+ {
312320 if ( $newRev->getRawUser() != $this->user->getId() ) { // no self-reverts
313321 FRUserCounters::incCount( $newRev->getRawUser(), 'revertedEdits' );
314322 }
@@ -367,7 +375,7 @@
368376 return true; // don't record if the same
369377 }
370378
371 - # Insert the review entry...
 379+ # The new review entry...
372380 $flaggedRevision = new FlaggedRevision( array(
373381 'rev' => $rev,
374382 'user_id' => $this->user->getId(),
@@ -381,6 +389,11 @@
382390 'fileVersions' => $fileVersions,
383391 'flags' => ''
384392 ) );
 393+ # Delete the old review entry if it exists...
 394+ if ( $oldFrev ) {
 395+ $oldFrev->delete();
 396+ }
 397+ # Insert the new review entry...
385398 $flaggedRevision->insert();
386399 # Update recent changes...
387400 $rcId = $rev->isUnpatrolled(); // int
Index: branches/REL1_18/extensions/FlaggedRevs/presentation/FlaggedRevsUI.hooks.php
@@ -288,6 +288,7 @@
289289 }
290290 # Environment (e.g. $wgTitle) will change in MediaWiki::initializeArticle
291291 if ( $clearEnvironment ) $view->clear();
 292+
292293 return true;
293294 }
294295
Index: branches/REL1_18/extensions/FlaggedRevs/presentation/specialpages/reports/ReviewedVersions_body.php
@@ -93,15 +93,15 @@
9494 if ( !in_array( $this->namespace, $namespaces ) ) {
9595 $conds[] = "1 = 0";
9696 }
97 - $conds["fr_page_id"] = $this->pageID;
98 - $conds[] = "fr_rev_id = rev_id";
99 - $conds[] = "fr_user = user_id";
 97+ $conds['fr_page_id'] = $this->pageID;
 98+ $conds[] = 'fr_rev_id = rev_id';
10099 $conds[] = 'rev_deleted & ' . Revision::DELETED_TEXT . ' = 0';
 100+ $conds[] = 'fr_user = user_id';
101101 return array(
102102 'tables' => array( 'flaggedrevs', 'revision', 'user' ),
103103 'fields' => 'fr_rev_id,fr_timestamp,rev_timestamp,fr_quality,fr_user,user_name',
104104 'conds' => $conds,
105 - 'options' => array( 'USE INDEX' => array( 'flaggedrevs' => 'PRIMARY' ) )
 105+ //'options' => array( 'USE INDEX' => array( 'flaggedrevs' => 'page_rev' ) )
106106 );
107107 }
108108
Index: branches/REL1_18/extensions/FlaggedRevs/presentation/FlaggedPageView.php
@@ -59,9 +59,9 @@
6060 * or false if there isn't such a title
6161 */
6262 public static function globalArticleInstance() {
63 - global $wgTitle;
64 - if ( !empty( $wgTitle ) ) {
65 - return FlaggedPage::getTitleInstance( $wgTitle );
 63+ $title = RequestContext::getMain()->getTitle();
 64+ if ( $title ) {
 65+ return FlaggedPage::getTitleInstance( $title );
6666 }
6767 return null;
6868 }
@@ -594,18 +594,21 @@
595595 }
596596 }
597597
598 - # Check if this is a redirect...
599598 $text = $frev->getRevText();
600 - $redirHtml = $this->getRedirectHtml( $text );
 599+ # Get the new stable parser output...
 600+ $pOpts = $this->article->makeParserOptions( $wgUser );
 601+ $parserOut = FlaggedRevs::parseStableText(
 602+ $this->article->getTitle(), $text, $frev->getRevId(), $pOpts );
601603
602604 # Parse and output HTML
603 - if ( $redirHtml == '' ) {
604 - $parserOptions = $this->article->makeParserOptions( $wgUser );
605 - $parserOut = FlaggedRevs::parseStableText(
606 - $this->article->getTitle(), $text, $frev->getRevId(), $parserOptions );
 605+ $redirHtml = $this->getRedirectHtml( $text );
 606+ if ( $redirHtml == '' ) { // page is not a redirect...
 607+ # Add the stable output to the page view
607608 $this->addParserOutput( $parserOut );
608 - } else {
 609+ } else { // page is a redirect...
609610 $this->out->addHtml( $redirHtml );
 611+ # Add output to set categories, displaytitle, etc.
 612+ $this->out->addParserOutputNoText( $parserOut );
610613 }
611614 }
612615
@@ -673,30 +676,31 @@
674677 }
675678
676679 # Get parsed stable version and output HTML
677 - $parserOptions = $this->article->makeParserOptions( $wgUser );
 680+ $pOpts = $this->article->makeParserOptions( $wgUser );
678681 $parserCache = FRParserCacheStable::singleton();
679 - $parserOut = $parserCache->get( $this->article, $parserOptions );
 682+ $parserOut = $parserCache->get( $this->article, $pOpts );
680683 if ( $parserOut ) {
 684+ # Cache hit. Note that redirects are not cached.
681685 $this->addParserOutput( $parserOut );
682686 } else {
683687 $text = $srev->getRevText();
684 - # Check if this is a redirect...
 688+ # Get the new stable parser output...
 689+ $parserOut = FlaggedRevs::parseStableText(
 690+ $this->article->getTitle(), $text, $srev->getRevId(), $pOpts );
 691+
685692 $redirHtml = $this->getRedirectHtml( $text );
686 - # Don't parse redirects, use separate handling...
687 - if ( $redirHtml == '' ) {
688 - # Get the new stable output
689 - $parserOut = FlaggedRevs::parseStableText(
690 - $this->article->getTitle(), $text, $srev->getRevId(), $parserOptions );
 693+ if ( $redirHtml == '' ) { // page is not a redirect...
691694 # Update the stable version cache
692 - $parserCache->save( $parserOut, $this->article, $parserOptions );
 695+ $parserCache->save( $parserOut, $this->article, $pOpts );
693696 # Add the stable output to the page view
694697 $this->addParserOutput( $parserOut );
695 -
696 - # Update the stable version dependancies
697 - FlaggedRevs::updateStableOnlyDeps( $this->article, $parserOut );
698 - } else {
 698+ } else { // page is a redirect...
699699 $this->out->addHtml( $redirHtml );
 700+ # Add output to set categories, displaytitle, etc.
 701+ $this->out->addParserOutputNoText( $parserOut );
700702 }
 703+ # Update the stable version dependancies
 704+ FlaggedRevs::updateStableOnlyDeps( $this->article, $parserOut );
701705 }
702706
703707 # Update page sync status for tracking purposes.
@@ -723,7 +727,8 @@
724728 protected function getRedirectHtml( $text ) {
725729 $rTargets = Title::newFromRedirectArray( $text );
726730 if ( $rTargets ) {
727 - return $this->article->viewRedirect( $rTargets );
 731+ $article = new Article( $this->article->getTitle() );
 732+ return $article->viewRedirect( $rTargets );
728733 }
729734 return '';
730735 }
@@ -904,7 +909,7 @@
905910 * Adds stable version tags to page when editing
906911 */
907912 public function addToEditView( EditPage $editPage ) {
908 - global $wgUser;
 913+ global $wgUser, $wgParser;
909914 $this->load();
910915 # Must be reviewable. UI may be limited to unobtrusive patrolling system.
911916 if ( !$this->article->isReviewable() ) {
@@ -956,7 +961,7 @@
957962 $section = ( $editPage->section == "" ) ?
958963 false : intval( $editPage->section );
959964 if ( $section !== false ) {
960 - $text = $this->article->getSection( $text, $section );
 965+ $text = $wgParser->getSection( $text, $section );
961966 }
962967 if ( $text !== false && strcmp( $text, $editPage->textbox1 ) !== 0 ) {
963968 $diffEngine = new DifferenceEngine( $this->article->getTitle() );
@@ -1641,11 +1646,22 @@
16421647 array( ':' , '.' ), array( '%3A', '%' ), // hack: reverse encoding
16431648 substr( $sectionAnchor, 1 ) // remove the '#'
16441649 );
 1650+<<<<<<< .working
16451651 $extraQuery .= '&fromsection=' . $section;
 1652+=======
 1653+ $params += array( 'fromsection' => $section );
 1654+>>>>>>> .merge-right.r90388
16461655 $sectionAnchor = ''; // go to the top of the page to see notice
16471656 }
16481657 }
16491658 }
 1659+<<<<<<< .working
 1660+=======
 1661+ if ( $extraQuery !== '' ) {
 1662+ $extraQuery .= '&';
 1663+ }
 1664+ $extraQuery .= wfArrayToCGI( $params ); // note: EditPage will add initial "&"
 1665+>>>>>>> .merge-right.r90388
16501666 return true;
16511667 }
16521668
Index: branches/REL1_18/extensions/FlaggedRevs/presentation/modules/flaggedrevs.css
@@ -23,10 +23,10 @@
2424 background-color: #f0f8ff;
2525 }
2626 div.flaggedrevs_quality {
27 - background-color: #f0fff0;
 27+ background-color: #e1ffe1;
2828 }
2929 div.flaggedrevs_pristine {
30 - background-color: #fffff0;
 30+ background-color: #ffffe3;
3131 }
3232 div.flaggedrevs_notice {
3333 background-color: #f9f9f9;
@@ -198,10 +198,10 @@
199199 background-color: #f0f8ff;
200200 }
201201 .flaggedrevs-color-2 {
202 - background-color: #f0fff0;
 202+ background-color: #e1ffe1;
203203 }
204204 .flaggedrevs-color-3 {
205 - background-color: #fffff0;
 205+ background-color: #ffffe3;
206206 }
207207
208208 .flaggedrevs-pending {
@@ -316,13 +316,13 @@
317317 background-color: #f0f8ff;
318318 }
319319 .fr-rating-option-2 {
320 - background-color: #f0fff0;
 320+ background-color: #e1ffe1;
321321 }
322322 .fr-rating-option-3 {
323323 background-color: #fef0db;
324324 }
325325 .fr-rating-option-4 {
326 - background-color: #fffff0;
 326+ background-color: #ffffe3;
327327 }
328328
329329 .fr-diff-patrollink {
Property changes on: branches/REL1_18/extensions/FlaggedRevs
___________________________________________________________________
Modified: svn:mergeinfo
330330 Merged /trunk/extensions/FlaggedRevs:r87606,87617,87669,87690,87700,90388,90419,90741,90789,90793,91363,91365,91584

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r87606Follow-up r86179: Updated and commented out two USE INDEX statements. This *h...aaron23:44, 6 May 2011
r87617Made "pristine" color a bit more visibleaaron01:01, 7 May 2011
r87669Run populate_fr_rev_timestamp() via updateraaron00:58, 8 May 2011
r87690Added missing $dbw->timestamp() format call for new fr_rev_timestamp fieldaaron18:49, 8 May 2011
r87700Tweak for bug 28598. Made insert() do strict insertions only and have the cal...aaron22:36, 8 May 2011
r90388Fixed injectPostEditURLParams() query generation (& is already there)aaron08:50, 19 June 2011
r90419Made "quality" color a bit more distinctaaron20:52, 19 June 2011
r90741Fixed silly test bugaaron22:08, 24 June 2011
r90789Fixed fatal due to removal of Article::getSection()aaron19:29, 25 June 2011
r90793*sigh*...added bit left off of r90789aaron19:39, 25 June 2011
r91363Fixed bogus reference to $status var (causes a msg exception later down)aaron18:32, 2 July 2011
r91365Follow-up r91363: we need a msg key on failureaaron18:42, 2 July 2011
r91584* Call viewRedirect() on Article (WikiPage doesn't inherit this anymore)...aaron19:13, 6 July 2011

Status & tagging log