DeleteAction: Avoid displaying the form unconditionally

Also, turned to override checkCanExecute() in FileDeleteAction instead,
to preserve the behaviour before the commit 3e43d318.

Bug: T341002
Change-Id: I8faa2ae97373d332d8c126d02d4969565489bf90
This commit is contained in:
Func 2023-07-04 03:50:47 +08:00
parent a74eaea765
commit 3cdf06b03e
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;
}
/**