diff options
Diffstat (limited to 'includes/revisiondelete')
-rw-r--r-- | includes/revisiondelete/RevDelItem.php | 2 | ||||
-rw-r--r-- | includes/revisiondelete/RevDelList.php | 24 | ||||
-rw-r--r-- | includes/revisiondelete/RevDelLogItem.php | 27 | ||||
-rw-r--r-- | includes/revisiondelete/RevDelRevisionItem.php | 2 | ||||
-rw-r--r-- | includes/revisiondelete/RevisionDeleter.php | 4 |
5 files changed, 39 insertions, 20 deletions
diff --git a/includes/revisiondelete/RevDelItem.php b/includes/revisiondelete/RevDelItem.php index ebdbf3a8..dba368d8 100644 --- a/includes/revisiondelete/RevDelItem.php +++ b/includes/revisiondelete/RevDelItem.php @@ -36,6 +36,8 @@ abstract class RevDelItem extends RevisionItemBase { /** * Get the current deletion bitfield value + * + * @return integer */ abstract public function getBits(); diff --git a/includes/revisiondelete/RevDelList.php b/includes/revisiondelete/RevDelList.php index c31c42b3..7ffb4279 100644 --- a/includes/revisiondelete/RevDelList.php +++ b/includes/revisiondelete/RevDelList.php @@ -97,7 +97,7 @@ abstract class RevDelList extends RevisionListBase { * transactions are done here. * * @param array $params Associative array of parameters. Members are: - * value: The integer value to set the visibility to + * value: ExtractBitParams() bitfield array * comment: The log comment. * perItemStatus: Set if you want per-item status reports * @return Status @@ -108,10 +108,13 @@ abstract class RevDelList extends RevisionListBase { $comment = $params['comment']; $perItemStatus = isset( $params['perItemStatus'] ) ? $params['perItemStatus'] : false; - $this->res = false; + // CAS-style checks are done on the _deleted fields so the select + // does not need to use FOR UPDATE nor be in the atomic section $dbw = wfGetDB( DB_MASTER ); - $this->doQuery( $dbw ); - $dbw->begin( __METHOD__ ); + $this->res = $this->doQuery( $dbw ); + + $dbw->startAtomic( __METHOD__ ); + $status = Status::newGood(); $missing = array_flip( $this->ids ); $this->clearFileOps(); @@ -125,6 +128,7 @@ abstract class RevDelList extends RevisionListBase { // @codingStandardsIgnoreStart Generic.CodeAnalysis.ForLoopWithTestFunctionCall.NotAllowed for ( $this->reset(); $this->current(); $this->next() ) { // @codingStandardsIgnoreEnd + /** @var $item RevDelItem */ $item = $this->current(); unset( $missing[$item->getId()] ); @@ -216,6 +220,7 @@ abstract class RevDelList extends RevisionListBase { } // Log it + // @FIXME: $newBits/$oldBits set in for loop, makes IDE warnings too $this->updateLog( array( 'title' => $this->title, 'count' => $successCount, @@ -226,10 +231,15 @@ abstract class RevDelList extends RevisionListBase { 'authorIds' => $authorIds, 'authorIPs' => $authorIPs ) ); - $dbw->commit( __METHOD__ ); // Clear caches - $status->merge( $this->doPostCommitUpdates() ); + $that = $this; + $dbw->onTransactionIdle( function() use ( $that ) { + $that->doPostCommitUpdates(); + } ); + + $dbw->endAtomic( __METHOD__ ); + return $status; } @@ -260,7 +270,7 @@ abstract class RevDelList extends RevisionListBase { if ( !$field ) { throw new MWException( "Bad log URL param type!" ); } - // Put things hidden from sysops in the oversight log + // Put things hidden from sysops in the suppression log if ( ( $params['newBits'] | $params['oldBits'] ) & $this->getSuppressBit() ) { $logType = 'suppress'; } else { diff --git a/includes/revisiondelete/RevDelLogItem.php b/includes/revisiondelete/RevDelLogItem.php index 49adf204..65b03097 100644 --- a/includes/revisiondelete/RevDelLogItem.php +++ b/includes/revisiondelete/RevDelLogItem.php @@ -48,11 +48,26 @@ class RevDelLogItem extends RevDelItem { } public function getBits() { - return $this->row->log_deleted; + return (int)$this->row->log_deleted; } public function setBits( $bits ) { $dbw = wfGetDB( DB_MASTER ); + + $dbw->update( 'logging', + array( 'log_deleted' => $bits ), + array( + 'log_id' => $this->row->log_id, + 'log_deleted' => $this->getBits() // cas + ), + __METHOD__ + ); + + if ( !$dbw->affectedRows() ) { + // Concurrent fail! + return false; + } + $dbw->update( 'recentchanges', array( 'rc_deleted' => $bits, @@ -64,16 +79,8 @@ class RevDelLogItem extends RevDelItem { ), __METHOD__ ); - $dbw->update( 'logging', - array( 'log_deleted' => $bits ), - array( - 'log_id' => $this->row->log_id, - 'log_deleted' => $this->getBits() - ), - __METHOD__ - ); - return (bool)$dbw->affectedRows(); + return true; } public function getHTML() { diff --git a/includes/revisiondelete/RevDelRevisionItem.php b/includes/revisiondelete/RevDelRevisionItem.php index 300ce6ad..17e1fd18 100644 --- a/includes/revisiondelete/RevDelRevisionItem.php +++ b/includes/revisiondelete/RevDelRevisionItem.php @@ -67,7 +67,7 @@ class RevDelRevisionItem extends RevDelItem { array( 'rev_id' => $this->revision->getId(), 'rev_page' => $this->revision->getPage(), - 'rev_deleted' => $this->getBits() + 'rev_deleted' => $this->getBits() // cas ), __METHOD__ ); diff --git a/includes/revisiondelete/RevisionDeleter.php b/includes/revisiondelete/RevisionDeleter.php index ba1f0f69..db2bc6a4 100644 --- a/includes/revisiondelete/RevisionDeleter.php +++ b/includes/revisiondelete/RevisionDeleter.php @@ -233,9 +233,9 @@ class RevisionDeleter { * @since 1.22 * @param array $bitPars ExtractBitParams() params * @param int $oldfield Current bitfield - * @return array + * @return integer */ - public static function extractBitfield( $bitPars, $oldfield ) { + public static function extractBitfield( array $bitPars, $oldfield ) { // Build the actual new rev_deleted bitfield $newBits = 0; foreach ( $bitPars as $const => $val ) { |