X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Frevisiondelete%2FRevisionDeleteAbstracts.php;h=e326dcedf703211d3f8e5b1646c2162bc26c9aa6;hb=ca895b7072b9d98a5b3abf8f2a46474095c16210;hp=d822d0913be3c27ab6fd3f42540e5661fce7a8fc;hpb=2a2e9e65754e47f2d331b877b5c4e35ac3103c90;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/revisiondelete/RevisionDeleteAbstracts.php b/includes/revisiondelete/RevisionDeleteAbstracts.php index d822d0913b..e326dcedf7 100644 --- a/includes/revisiondelete/RevisionDeleteAbstracts.php +++ b/includes/revisiondelete/RevisionDeleteAbstracts.php @@ -37,24 +37,59 @@ abstract class RevDel_List extends RevisionListBase { * Get the DB field name associated with the ID list. * This used to populate the log_search table for finding log entries. * Override this function. - * @return null + * @return string|null */ public static function getRelationType() { return null; } + /** + * Get the user right required for this list type + * Override this function. + * @since 1.22 + * @return string|null + */ + public static function getRestriction() { + return null; + } + + /** + * Get the revision deletion constant for this list type + * Override this function. + * @since 1.22 + * @return int|null + */ + public static function getRevdelConstant() { + return null; + } + + /** + * Suggest a target for the revision deletion + * Optionally override this function. + * @since 1.22 + * @param Title|null $target User-supplied target + * @param array $ids + * @return Title|null + */ + public static function suggestTarget( $target, array $ids ) { + return $target; + } + /** * Set the visibility for the revisions in this list. Logging and * transactions are done here. * * @param array $params Associative array of parameters. Members are: - * value: The integer value to set the visibility to - * comment: The log comment. + * value: The integer value to set the visibility to + * comment: The log comment. + * perItemStatus: Set if you want per-item status reports * @return Status + * @since 1.23 Added 'perItemStatus' param */ public function setVisibility( $params ) { $bitPars = $params['value']; $comment = $params['comment']; + $perItemStatus = isset( $params['perItemStatus'] ) ? $params['perItemStatus'] : false; $this->res = false; $dbw = wfGetDB( DB_MASTER ); @@ -66,16 +101,27 @@ abstract class RevDel_List extends RevisionListBase { $idsForLog = array(); $authorIds = $authorIPs = array(); + if ( $perItemStatus ) { + $status->itemStatuses = array(); + } + for ( $this->reset(); $this->current(); $this->next() ) { $item = $this->current(); unset( $missing[$item->getId()] ); + if ( $perItemStatus ) { + $itemStatus = Status::newGood(); + $status->itemStatuses[$item->getId()] = $itemStatus; + } else { + $itemStatus = $status; + } + $oldBits = $item->getBits(); // Build the actual new rev_deleted bitfield - $newBits = SpecialRevisionDelete::extractBitfield( $bitPars, $oldBits ); + $newBits = RevisionDeleter::extractBitfield( $bitPars, $oldBits ); if ( $oldBits == $newBits ) { - $status->warning( 'revdelete-no-change', $item->formatDate(), $item->formatTime() ); + $itemStatus->warning( 'revdelete-no-change', $item->formatDate(), $item->formatTime() ); $status->failCount++; continue; } elseif ( $oldBits == 0 && $newBits != 0 ) { @@ -88,7 +134,7 @@ abstract class RevDel_List extends RevisionListBase { if ( $item->isHideCurrentOp( $newBits ) ) { // Cannot hide current version text - $status->error( 'revdelete-hide-current', $item->formatDate(), $item->formatTime() ); + $itemStatus->error( 'revdelete-hide-current', $item->formatDate(), $item->formatTime() ); $status->failCount++; continue; } @@ -96,13 +142,13 @@ abstract class RevDel_List extends RevisionListBase { // Cannot access this revision $msg = ( $opType == 'show' ) ? 'revdelete-show-no-access' : 'revdelete-modify-no-access'; - $status->error( $msg, $item->formatDate(), $item->formatTime() ); + $itemStatus->error( $msg, $item->formatDate(), $item->formatTime() ); $status->failCount++; continue; } // Cannot just "hide from Sysops" without hiding any fields if ( $newBits == Revision::DELETED_RESTRICTED ) { - $status->warning( 'revdelete-only-restricted', $item->formatDate(), $item->formatTime() ); + $itemStatus->warning( 'revdelete-only-restricted', $item->formatDate(), $item->formatTime() ); $status->failCount++; continue; } @@ -119,19 +165,22 @@ abstract class RevDel_List extends RevisionListBase { $authorIPs[] = $item->getAuthorName(); } } else { - $status->error( 'revdelete-concurrent-change', $item->formatDate(), $item->formatTime() ); + $itemStatus->error( 'revdelete-concurrent-change', $item->formatDate(), $item->formatTime() ); $status->failCount++; } } // Handle missing revisions foreach ( $missing as $id => $unused ) { - $status->error( 'revdelete-modify-missing', $id ); + if ( $perItemStatus ) { + $status->itemStatuses[$id] = Status::newFatal( 'revdelete-modify-missing', $id ); + } else { + $status->error( 'revdelete-modify-missing', $id ); + } $status->failCount++; } if ( $status->successCount == 0 ) { - $status->ok = false; $dbw->rollback( __METHOD__ ); return $status; } @@ -290,7 +339,15 @@ abstract class RevDel_Item extends RevisionItemBase { * If the update fails because it did not match, the function should return * false. This prevents concurrency problems. * - * @return boolean success + * @return bool Success */ abstract public function setBits( $newBits ); + + /** + * Get the return information about the revision for the API + * @since 1.23 + * @param ApiResult $result API result object + * @return array Data for the API result + */ + abstract public function getApiData( ApiResult $result ); }