*/
class RevisionDeleter {
/** List of known revdel types, with their corresponding list classes */
- private static $allowedTypes = array(
+ private static $allowedTypes = [
'revision' => 'RevDelRevisionList',
'archive' => 'RevDelArchiveList',
'oldimage' => 'RevDelFileList',
'filearchive' => 'RevDelArchivedFileList',
'logging' => 'RevDelLogList',
- );
+ ];
/** Type map to support old log entries */
- private static $deprecatedTypeMap = array(
+ private static $deprecatedTypeMap = [
'oldid' => 'revision',
'artimestamp' => 'archive',
'oldimage' => 'oldimage',
'fileid' => 'filearchive',
'logid' => 'logging',
- );
+ ];
/**
* Lists the valid possible types for revision deletion.
* @param int $field The bitmask describing the single option.
* @param int $diff The xor of the old and new bitfields.
* @param int $new The new bitfield
- * @param array $arr The array to update.
+ * @param array &$arr The array to update.
*/
protected static function checkItem( $desc, $field, $diff, $new, &$arr ) {
if ( $diff & $field ) {
*/
public static function getChanges( $n, $o ) {
$diff = $n ^ $o;
- $ret = array( 0 => array(), 1 => array(), 2 => array() );
+ $ret = [ 0 => [], 1 => [], 2 => [] ];
// Build bitfield changes in language
self::checkItem( 'revdelete-content',
Revision::DELETED_TEXT, $diff, $n, $ret );
if ( !$typeName ) {
return null;
}
- return call_user_func( array( self::$allowedTypes[$typeName], 'getRelationType' ) );
+ return call_user_func( [ self::$allowedTypes[$typeName], 'getRelationType' ] );
}
/**
if ( !$typeName ) {
return null;
}
- return call_user_func( array( self::$allowedTypes[$typeName], 'getRestriction' ) );
+ return call_user_func( [ self::$allowedTypes[$typeName], 'getRestriction' ] );
}
/**
if ( !$typeName ) {
return null;
}
- return call_user_func( array( self::$allowedTypes[$typeName], 'getRevdelConstant' ) );
+ return call_user_func( [ self::$allowedTypes[$typeName], 'getRevdelConstant' ] );
}
/**
if ( !$typeName ) {
return $target;
}
- return call_user_func( array( self::$allowedTypes[$typeName], 'suggestTarget' ), $target, $ids );
+ return call_user_func( [ self::$allowedTypes[$typeName], 'suggestTarget' ], $target, $ids );
}
/**
* @return bool|mixed
*/
public static function checkRevisionExistence( $title, $revid ) {
- $dbr = wfGetDB( DB_SLAVE );
+ $dbr = wfGetDB( DB_REPLICA );
$exists = $dbr->selectField( 'revision', '1',
- array( 'rev_id' => $revid ), __METHOD__ );
+ [ 'rev_id' => $revid ], __METHOD__ );
if ( $exists ) {
return true;
}
$timestamp = $dbr->selectField( 'archive', 'ar_timestamp',
- array( 'ar_namespace' => $title->getNamespace(),
+ [ 'ar_namespace' => $title->getNamespace(),
'ar_title' => $title->getDBkey(),
- 'ar_rev_id' => $revid ), __METHOD__ );
+ 'ar_rev_id' => $revid ], __METHOD__ );
return $timestamp;
}