X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Frevisiondelete%2FRevisionDeleter.php;h=b834c153676e65c96595c893397e734bb461b8cc;hb=a2c8c2969420a0f150c03f76e3a0bf9028fcda43;hp=db2bc6a4dbf99f98a51cc73cbf9d859d1687cc8a;hpb=faab8d66d948d42d4a1d3b6a372b214a96bf5d31;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/revisiondelete/RevisionDeleter.php b/includes/revisiondelete/RevisionDeleter.php index db2bc6a4db..7b2147a5e5 100644 --- a/includes/revisiondelete/RevisionDeleter.php +++ b/includes/revisiondelete/RevisionDeleter.php @@ -28,22 +28,22 @@ */ class RevisionDeleter { /** List of known revdel types, with their corresponding list classes */ - private static $allowedTypes = array( - 'revision' => 'RevDelRevisionList', - 'archive' => 'RevDelArchiveList', - 'oldimage' => 'RevDelFileList', - 'filearchive' => 'RevDelArchivedFileList', - 'logging' => 'RevDelLogList', - ); + private static $allowedTypes = [ + 'revision' => RevDelRevisionList::class, + 'archive' => RevDelArchiveList::class, + 'oldimage' => RevDelFileList::class, + 'filearchive' => RevDelArchivedFileList::class, + 'logging' => RevDelLogList::class, + ]; /** 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. @@ -85,7 +85,8 @@ class RevisionDeleter { if ( !$typeName ) { throw new MWException( __METHOD__ . ": Unknown RevDel type '$typeName'" ); } - return new self::$allowedTypes[$typeName]( $context, $title, $ids ); + $class = self::$allowedTypes[$typeName]; + return new $class( $context, $title, $ids ); } /** @@ -97,7 +98,7 @@ class RevisionDeleter { * @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 ) { @@ -125,7 +126,7 @@ class RevisionDeleter { */ 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 ); @@ -155,7 +156,7 @@ class RevisionDeleter { if ( !$typeName ) { return null; } - return call_user_func( array( self::$allowedTypes[$typeName], 'getRelationType' ) ); + return call_user_func( [ self::$allowedTypes[$typeName], 'getRelationType' ] ); } /** @@ -169,7 +170,7 @@ class RevisionDeleter { if ( !$typeName ) { return null; } - return call_user_func( array( self::$allowedTypes[$typeName], 'getRestriction' ) ); + return call_user_func( [ self::$allowedTypes[$typeName], 'getRestriction' ] ); } /** @@ -183,7 +184,7 @@ class RevisionDeleter { if ( !$typeName ) { return null; } - return call_user_func( array( self::$allowedTypes[$typeName], 'getRevdelConstant' ) ); + return call_user_func( [ self::$allowedTypes[$typeName], 'getRevdelConstant' ] ); } /** @@ -199,7 +200,7 @@ class RevisionDeleter { 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 ); } /** @@ -212,18 +213,18 @@ class RevisionDeleter { * @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; } @@ -233,7 +234,7 @@ class RevisionDeleter { * @since 1.22 * @param array $bitPars ExtractBitParams() params * @param int $oldfield Current bitfield - * @return integer + * @return int */ public static function extractBitfield( array $bitPars, $oldfield ) { // Build the actual new rev_deleted bitfield