X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fspecials%2FSpecialRevisiondelete.php;h=fcd4ab513335a305571a6c1ec80b961c4563c17f;hb=c5fdf8476545c46dbd726187b4cfe93e392984ac;hp=7c27ac418c5c82cee4cfd98e7763b4abc217c4b1;hpb=acbc16b623a5fd50226d3119f2c101b1165578b9;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/SpecialRevisiondelete.php b/includes/specials/SpecialRevisiondelete.php index 7c27ac418c..fcd4ab5133 100644 --- a/includes/specials/SpecialRevisiondelete.php +++ b/includes/specials/SpecialRevisiondelete.php @@ -67,48 +67,52 @@ class SpecialRevisionDelete extends UnlistedSpecialPage { /** * UI labels for each type. */ - private static $UILabels = array( - 'revision' => array( + private static $UILabels = [ + 'revision' => [ 'check-label' => 'revdelete-hide-text', 'success' => 'revdelete-success', 'failure' => 'revdelete-failure', 'text' => 'revdelete-text-text', 'selected'=> 'revdelete-selected-text', - ), - 'archive' => array( + ], + 'archive' => [ 'check-label' => 'revdelete-hide-text', 'success' => 'revdelete-success', 'failure' => 'revdelete-failure', 'text' => 'revdelete-text-text', 'selected'=> 'revdelete-selected-text', - ), - 'oldimage' => array( + ], + 'oldimage' => [ 'check-label' => 'revdelete-hide-image', 'success' => 'revdelete-success', 'failure' => 'revdelete-failure', 'text' => 'revdelete-text-file', 'selected'=> 'revdelete-selected-file', - ), - 'filearchive' => array( + ], + 'filearchive' => [ 'check-label' => 'revdelete-hide-image', 'success' => 'revdelete-success', 'failure' => 'revdelete-failure', 'text' => 'revdelete-text-file', 'selected'=> 'revdelete-selected-file', - ), - 'logging' => array( + ], + 'logging' => [ 'check-label' => 'revdelete-hide-name', 'success' => 'logdelete-success', 'failure' => 'logdelete-failure', 'text' => 'logdelete-text', 'selected' => 'logdelete-selected', - ), - ); + ], + ]; public function __construct() { parent::__construct( 'Revisiondelete', 'deletedhistory' ); } + public function doesWrites() { + return true; + } + public function execute( $par ) { $this->useTransactionalTimeLimit(); @@ -118,6 +122,11 @@ class SpecialRevisionDelete extends UnlistedSpecialPage { $output = $this->getOutput(); $user = $this->getUser(); + // Check blocks + if ( $user->isBlocked() ) { + throw new UserBlockedError( $user->getBlock() ); + } + $this->setHeaders(); $this->outputHeader(); $request = $this->getRequest(); @@ -129,7 +138,7 @@ class SpecialRevisionDelete extends UnlistedSpecialPage { $this->ids = explode( ',', $ids ); } else { # Array input - $this->ids = array_keys( $request->getArray( 'ids', array() ) ); + $this->ids = array_keys( $request->getArray( 'ids', [] ) ); } // $this->ids = array_map( 'intval', $this->ids ); $this->ids = array_unique( array_filter( $this->ids ) ); @@ -170,11 +179,10 @@ class SpecialRevisionDelete extends UnlistedSpecialPage { $this->typeLabels = self::$UILabels[$this->typeName]; $list = $this->getList(); $list->reset(); - $bitfield = $list->current()->getBits(); $this->mIsAllowed = $user->isAllowed( RevisionDeleter::getRestriction( $this->typeName ) ); $canViewSuppressedOnly = $this->getUser()->isAllowed( 'viewsuppressed' ) && !$this->getUser()->isAllowed( 'suppressrevision' ); - $pageIsSuppressed = $bitfield & Revision::DELETED_RESTRICTED; + $pageIsSuppressed = $list->areAnySuppressed(); $this->mIsAllowed = $this->mIsAllowed && !( $canViewSuppressedOnly && $pageIsSuppressed ); $this->otherReason = $request->getVal( 'wpReason' ); @@ -182,17 +190,17 @@ class SpecialRevisionDelete extends UnlistedSpecialPage { $this->showConvenienceLinks(); # Initialise checkboxes - $this->checks = array( + $this->checks = [ # Messages: revdelete-hide-text, revdelete-hide-image, revdelete-hide-name - array( $this->typeLabels['check-label'], 'wpHidePrimary', + [ $this->typeLabels['check-label'], 'wpHidePrimary', RevisionDeleter::getRevdelConstant( $this->typeName ) - ), - array( 'revdelete-hide-comment', 'wpHideComment', Revision::DELETED_COMMENT ), - array( 'revdelete-hide-user', 'wpHideUser', Revision::DELETED_USER ) - ); + ], + [ 'revdelete-hide-comment', 'wpHideComment', Revision::DELETED_COMMENT ], + [ 'revdelete-hide-user', 'wpHideUser', Revision::DELETED_USER ] + ]; if ( $user->isAllowed( 'suppressrevision' ) ) { - $this->checks[] = array( 'revdelete-hide-restricted', - 'wpHideRestricted', Revision::DELETED_RESTRICTED ); + $this->checks[] = [ 'revdelete-hide-restricted', + 'wpHideRestricted', Revision::DELETED_RESTRICTED ]; } # Either submit or create our form @@ -211,7 +219,7 @@ class SpecialRevisionDelete extends UnlistedSpecialPage { 'delete', $this->targetObj, '', /* user */ - array( 'lim' => 25, 'conds' => $qc, 'useMaster' => $this->wasSaved ) + [ 'lim' => 25, 'conds' => $qc, 'useMaster' => $this->wasSaved ] ); # Show relevant lines from the suppression log if ( $user->isAllowed( 'suppressionlog' ) ) { @@ -222,7 +230,7 @@ class SpecialRevisionDelete extends UnlistedSpecialPage { 'suppress', $this->targetObj, '', - array( 'lim' => 25, 'conds' => $qc, 'useMaster' => $this->wasSaved ) + [ 'lim' => 25, 'conds' => $qc, 'useMaster' => $this->wasSaved ] ); } } @@ -236,20 +244,20 @@ class SpecialRevisionDelete extends UnlistedSpecialPage { // Also set header tabs to be for the target. $this->getSkin()->setRelevantTitle( $this->targetObj ); - $links = array(); + $links = []; $links[] = Linker::linkKnown( SpecialPage::getTitleFor( 'Log' ), $this->msg( 'viewpagelogs' )->escaped(), - array(), - array( 'page' => $this->targetObj->getPrefixedText() ) + [], + [ 'page' => $this->targetObj->getPrefixedText() ] ); if ( !$this->targetObj->isSpecialPage() ) { # Give a link to the page history $links[] = Linker::linkKnown( $this->targetObj, $this->msg( 'pagehist' )->escaped(), - array(), - array( 'action' => 'history' ) + [], + [ 'action' => 'history' ] ); # Link to deleted edits if ( $this->getUser()->isAllowed( 'undelete' ) ) { @@ -257,8 +265,8 @@ class SpecialRevisionDelete extends UnlistedSpecialPage { $links[] = Linker::linkKnown( $undelete, $this->msg( 'deletedhist' )->escaped(), - array(), - array( 'target' => $this->targetObj->getPrefixedDBkey() ) + [], + [ 'target' => $this->targetObj->getPrefixedDBkey() ] ); } } @@ -272,9 +280,9 @@ class SpecialRevisionDelete extends UnlistedSpecialPage { * @return array */ protected function getLogQueryCond() { - $conds = array(); + $conds = []; // Revision delete logs for these item - $conds['log_type'] = array( 'delete', 'suppress' ); + $conds['log_type'] = [ 'delete', 'suppress' ]; $conds['log_action'] = $this->getList()->getLogAction(); $conds['ls_field'] = RevisionDeleter::getRelationType( $this->typeName ); $conds['ls_value'] = $this->ids; @@ -314,14 +322,14 @@ class SpecialRevisionDelete extends UnlistedSpecialPage { $lang->userDate( $oimage->getTimestamp(), $user ), $lang->userTime( $oimage->getTimestamp(), $user ) ); $this->getOutput()->addHTML( - Xml::openElement( 'form', array( + Xml::openElement( 'form', [ 'method' => 'POST', - 'action' => $this->getPageTitle()->getLocalURL( array( + 'action' => $this->getPageTitle()->getLocalURL( [ 'target' => $this->targetObj->getPrefixedDBkey(), 'file' => $archiveName, 'token' => $user->getEditToken( $archiveName ), - ) ) - ) + ] ) + ] ) . Xml::submitButton( $this->msg( 'revdelete-show-file-submit' )->text() ) . '' @@ -330,10 +338,10 @@ class SpecialRevisionDelete extends UnlistedSpecialPage { return; } $this->getOutput()->disable(); - # We mustn't allow the output to be Squid cached, otherwise + # We mustn't allow the output to be CDN cached, otherwise # if an admin previews a deleted image, and it's cached, then # a user without appropriate permissions can toddle off and - # nab the image, and Squid will serve it + # nab the image, and CDN will serve it $this->getRequest()->response()->header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', 0 ) . ' GMT' ); $this->getRequest()->response()->header( 'Cache-Control: no-cache, no-store, max-age=0, must-revalidate' @@ -368,8 +376,8 @@ class SpecialRevisionDelete extends UnlistedSpecialPage { // Messages: revdelete-selected-text, revdelete-selected-file, logdelete-selected $out = $this->getOutput(); - $out->wrapWikiMsg( "$1", array( $this->typeLabels['selected'], - $this->getLanguage()->formatNum( count( $this->ids ) ), $this->targetObj->getPrefixedText() ) ); + $out->wrapWikiMsg( "$1", [ $this->typeLabels['selected'], + $this->getLanguage()->formatNum( count( $this->ids ) ), $this->targetObj->getPrefixedText() ] ); $this->addHelpLink( 'Help:RevisionDelete' ); $out->addHTML( "