/**
* Abstract base class for a list of deletable items. The list class
* needs to be able to make a query from a set of identifiers to pull
- * relevant rows, to return RevDel_Item subclasses wrapping them, and
+ * relevant rows, to return RevDelItem subclasses wrapping them, and
* to wrap bulk update operations.
*/
-abstract class RevDel_List extends RevisionListBase {
+abstract class RevDelList extends RevisionListBase {
function __construct( IContextSource $context, Title $title, array $ids ) {
parent::__construct( $context, $title );
$this->ids = $ids;
* 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 );
$idsForLog = array();
$authorIds = $authorIPs = array();
+ if ( $perItemStatus ) {
+ $status->itemStatuses = array();
+ }
+
+ // @codingStandardsIgnoreStart Generic.CodeAnalysis.ForLoopWithTestFunctionCall.NotAllowed
for ( $this->reset(); $this->current(); $this->next() ) {
+ // @codingStandardsIgnoreEnd
$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 ) {
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;
}
// 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;
}
$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;
}
/**
* Abstract base class for deletable items
*/
-abstract class RevDel_Item extends RevisionItemBase {
+abstract class RevDelItem extends RevisionItemBase {
/**
* Returns true if the item is "current", and the operation to set the given
* bits can't be executed for that reason
* 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 );
}