X-Git-Url: https://git.cyclocoop.org/%242?a=blobdiff_plain;f=includes%2Frevisiondelete%2FRevDelList.php;h=48604e1a010d5159222d6a3645d452c542615e81;hb=d7a9ccee2dc835d2b662c7bc8b7ff655d762c093;hp=fc04c6984819e01a77bc56067a89c71b5fb5355c;hpb=e657b4bac8cbe0e6ac99eb037243d4668cf08881;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/revisiondelete/RevDelList.php b/includes/revisiondelete/RevDelList.php index fc04c69848..48604e1a01 100644 --- a/includes/revisiondelete/RevDelList.php +++ b/includes/revisiondelete/RevDelList.php @@ -81,14 +81,13 @@ abstract class RevDelList extends RevisionListBase { public function areAnySuppressed() { $bit = $this->getSuppressBit(); - // @codingStandardsIgnoreStart Generic.CodeAnalysis.ForLoopWithTestFunctionCall.NotAllowed - for ( $this->reset(); $this->current(); $this->next() ) { - // @codingStandardsIgnoreEnd - $item = $this->current(); + /** @var $item RevDelItem */ + foreach ( $this as $item ) { if ( $item->getBits() & $bit ) { return true; } } + return false; } @@ -104,6 +103,8 @@ abstract class RevDelList extends RevisionListBase { * @since 1.23 Added 'perItemStatus' param */ public function setVisibility( array $params ) { + $status = Status::newGood(); + $bitPars = $params['value']; $comment = $params['comment']; $perItemStatus = isset( $params['perItemStatus'] ) ? $params['perItemStatus'] : false; @@ -113,9 +114,17 @@ abstract class RevDelList extends RevisionListBase { $dbw = wfGetDB( DB_MASTER ); $this->res = $this->doQuery( $dbw ); + $status->merge( $this->acquireItemLocks() ); + if ( !$status->isGood() ) { + return $status; + } + $dbw->startAtomic( __METHOD__ ); + $dbw->onTransactionResolution( function () { + // Release locks on commit or error + $this->releaseItemLocks(); + } ); - $status = Status::newGood(); $missing = array_flip( $this->ids ); $this->clearFileOps(); $idsForLog = []; @@ -136,11 +145,8 @@ abstract class RevDelList extends RevisionListBase { // passed to doPostCommitUpdates(). $visibilityChangeMap = []; - // @codingStandardsIgnoreStart Generic.CodeAnalysis.ForLoopWithTestFunctionCall.NotAllowed - for ( $this->reset(); $this->current(); $this->next() ) { - // @codingStandardsIgnoreEnd - /** @var $item RevDelItem */ - $item = $this->current(); + /** @var $item RevDelItem */ + foreach ( $this as $item ) { unset( $missing[$item->getId()] ); if ( $perItemStatus ) { @@ -269,7 +275,8 @@ abstract class RevDelList extends RevisionListBase { function () use ( $visibilityChangeMap ) { $this->doPostCommitUpdates( $visibilityChangeMap ); }, - DeferredUpdates::PRESEND + DeferredUpdates::PRESEND, + $dbw ); $dbw->endAtomic( __METHOD__ ); @@ -277,6 +284,26 @@ abstract class RevDelList extends RevisionListBase { return $status; } + final protected function acquireItemLocks() { + $status = Status::newGood(); + /** @var $item RevDelItem */ + foreach ( $this as $item ) { + $status->merge( $item->lock() ); + } + + return $status; + } + + final protected function releaseItemLocks() { + $status = Status::newGood(); + /** @var $item RevDelItem */ + foreach ( $this as $item ) { + $status->merge( $item->unlock() ); + } + + return $status; + } + /** * Reload the list data from the master DB. This can be done after setVisibility() * to allow $item->getHTML() to show the new data.