r77289 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r77288‎ | r77289 | r77290 >
Date:14:59, 25 November 2010
Author:catrope
Status:ok
Tags:
Comment:
Revert r77193: this seems to have intended to fix bug 26042, but r77288 handles this already by simply doing INSERT IGNORE.
Modified paths:
  • /trunk/extensions/CodeReview/backend/CodeRevision.php (modified) (history)
  • /trunk/extensions/CodeReview/ui/CodeRevisionCommitter.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CodeReview/backend/CodeRevision.php
@@ -629,33 +629,14 @@
630630 return $refs;
631631 }
632632
633 - public function getSignoffsForUser( $user, $from = DB_SLAVE ) {
634 - return $this->fetchSignoffs( array( 'user' => $user ), $from );
635 - }
636 -
637 - public function getSignoffs( $from = DB_SLAVE) {
638 - return $this->fetchSignoffs( array(), $from );
639 - }
640 -
641 - /**
642 - * @param $options Array: array of filtering options
643 - * @param $from DB_SLAVE|DB_MASTER
644 - */
645 - private function fetchSignoffs( $options, $from = DB_SLAVE ) {
646 - # Default conditions for DB query.
647 - $fetchConditions = array(
648 - 'cs_repo_id' => $this->mRepoId,
649 - 'cs_rev_id' => $this->mId,
650 - );
651 - # Add a filter on user id (see getSignoffsForUser())
652 - if( isset($options['user']) ) {
653 - $fetchConditions['cs_user'] = $options['user']->getID() ;
654 - }
655 -
 633+ public function getSignoffs( $from = DB_SLAVE ) {
656634 $db = wfGetDB( $from );
657635 $result = $db->select( 'code_signoffs',
658636 array( 'cs_user', 'cs_user_text', 'cs_flag', 'cs_timestamp' ),
659 - $fetchConditions,
 637+ array(
 638+ 'cs_repo_id' => $this->mRepoId,
 639+ 'cs_rev_id' => $this->mId,
 640+ ),
660641 __METHOD__,
661642 array( 'ORDER BY' => 'cs_timestamp' )
662643 );
@@ -688,27 +669,6 @@
689670 $dbw->insert( 'code_signoffs', $rows, __METHOD__, array( 'IGNORE' ) );
690671 }
691672
692 - /**
693 - * Skip already existing signoffs.
694 - */
695 - public function mergeSignoff( $user, $postedFlags, $from = DB_SLAVE ) {
696 - $existingFlags = array();
697 - $userSignoffs = $this->getSignoffsForUser( $user, $from );
698 -
699 - # get user existing signoffs flags
700 - foreach( $userSignoffs as $signoff ) {
701 - $existingFlags[] = $signoff->flag;
702 - }
703 -
704 - # compare with posted ones and only keep non existant
705 - $addFlags = array_diff( $postedFlags, $existingFlags );
706 - if( count( $addFlags ) ) {
707 - $this->addSignoff( $user, $addFlags );
708 - } else {
709 - # We skipped insertion / replacement
710 - }
711 - }
712 -
713673 public function getTags( $from = DB_SLAVE ) {
714674 $db = wfGetDB( $from );
715675 $result = $db->select( 'code_tags',
Index: trunk/extensions/CodeReview/ui/CodeRevisionCommitter.php
@@ -86,7 +86,7 @@
8787 }
8888 // Add any signoffs
8989 if ( count( $signoffFlags ) && $this->validPost( 'codereview-signoff' ) ) {
90 - $this->mRev->mergeSignoff( $wgUser, $signoffFlags );
 90+ $this->mRev->addSignoff( $wgUser, $signoffFlags );
9191 }
9292 // Add any comments
9393 $commentAdded = false;

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r77193Merge non existing signoff flags, ignore existing oneshashar22:23, 23 November 2010
r77288(bug 26042) Database error when submitting duplicate sign-offcatrope14:50, 25 November 2010

Status & tagging log