Merge "DeleteAction: Avoid displaying the form unconditionally"

This commit is contained in:
jenkins-bot 2023-07-04 09:33:12 +00:00 committed by Gerrit Code Review
commit b2841034b3
2 changed files with 8 additions and 3 deletions

View file

@ -122,6 +122,10 @@ class DeleteAction extends FormAction {
return $this->msg( 'delete-confirm', $title->getPrefixedText() );
}
public function getRestriction() {
return 'delete';
}
protected function alterForm( HTMLForm $form ) {
$title = $this->getTitle();
$form

View file

@ -33,6 +33,7 @@ use MediaWiki\Permissions\PermissionStatus;
use MediaWiki\Title\Title;
use OldLocalFile;
use PermissionsError;
use User;
/**
* Handle file deletion
@ -208,12 +209,12 @@ class FileDeleteAction extends DeleteAction {
return $this->getTitle()->getLocalURL( $q );
}
public function getRestriction() {
protected function checkCanExecute( User $user ) {
parent::checkCanExecute( $user );
if ( $this->getContext()->getConfig()->get( MainConfigNames::UploadMaintenance ) ) {
throw new ErrorPageError( 'filedelete-maintenance-title', 'filedelete-maintenance' );
}
return null;
}
/**