102 if ( $this->readOnlyMode->isReadOnly() ) {
106 if ( $this->context->getConfig()->get(
'UploadMaintenance' ) ) {
107 throw new ErrorPageError(
'filedelete-maintenance-title',
'filedelete-maintenance' );
112 $request = $this->context->getRequest();
113 $this->oldimage = $request->getText(
'oldimage',
'' );
114 $token = $request->getText(
'wpEditToken' );
115 # Flag to hide all contents of the archived revisions
116 $suppress = $request->getCheck(
'wpSuppress' ) &&
117 $this->context->getAuthority()->isAllowed(
'suppressrevision' );
119 if ( $this->oldimage ) {
120 $this->oldfile = $this->repoGroup->getLocalRepo()->newFromArchiveName(
126 if ( !self::haveDeletableFile( $this->file, $this->oldfile, $this->oldimage ) ) {
127 $this->context->getOutput()->addHTML( $this->
prepareMessage(
'filedelete-nofile' ) );
128 $this->context->getOutput()->addReturnTo( $this->title );
133 if ( $request->wasPosted() && $this->context->getUser()->matchEditToken( $token, $this->oldimage ) ) {
134 $permissionStatus = PermissionStatus::newEmpty();
135 if ( !$this->context->getAuthority()->authorizeWrite(
136 'delete', $this->title, $permissionStatus
141 $deleteReasonList = $request->getText(
'wpDeleteReasonList' );
142 $deleteReason = $request->getText(
'wpReason' );
144 if ( $deleteReasonList ==
'other' ) {
145 $reason = $deleteReason;
146 } elseif ( $deleteReason !=
'' ) {
148 $reason = $deleteReasonList . $this->context->msg(
'colon-separator' )
149 ->inContentLanguage()->text() . $deleteReason;
151 $reason = $deleteReasonList;
160 $this->context->getUser()
163 $out = $this->context->getOutput();
165 if ( !$status->isGood() ) {
167 '<h2>' . $this->
prepareMessage(
'filedeleteerror-short' ) .
"</h2>\n"
169 $out->wrapWikiTextAsInterface(
171 $status->getWikiText(
'filedeleteerror-short',
'filedeleteerror-long' )
174 if ( $status->isOK() ) {
175 $out->setPageTitle( $this->context->msg(
'actioncomplete' ) );
179 $out->addReturnTo( $this->oldimage ? $this->title : Title::newMainPage() );
181 $this->watchlistManager->setWatch(
182 $request->getCheck(
'wpWatch' ),
183 $this->context->getAuthority(),
213 if ( $status->isOK() ) {
216 if ( trim( $reason ) !=
'' ) {
217 $logComment .=
wfMessage(
'colon-separator' )
218 ->inContentLanguage()->text() . $reason;
221 $logtype = $suppress ?
'suppress' :
'delete';
224 $logEntry->setPerformer( $user );
225 $logEntry->setTarget(
$title );
226 $logEntry->setComment( $logComment );
227 $logEntry->addTags( $tags );
228 $logid = $logEntry->insert();
229 $logEntry->publish( $logid );
231 $status->value = $logid;
234 $status = Status::newFatal(
'cannotdelete',
237 $page = MediaWikiServices::getInstance()->getWikiPageFactory()->newFromTitle(
$title );
238 '@phan-var WikiFilePage $page';
240 $dbw->startAtomic( __METHOD__ );
243 $deleteStatus = $page->doDeleteArticleReal(
254 if ( $deleteStatus->isOK() ) {
256 if ( $status->isOK() ) {
257 if ( $deleteStatus->value ===
null ) {
261 $logtype = $suppress ?
'suppress' :
'delete';
263 $logEntry->setPerformer( $user );
264 $logEntry->setTarget( clone
$title );
265 $logEntry->setComment( $reason );
266 $logEntry->addTags( $tags );
267 $logid = $logEntry->insert();
268 $dbw->onTransactionPreCommitOrIdle(
269 static function () use ( $logEntry, $logid ) {
270 $logEntry->publish( $logid );
274 $status->value = $logid;
276 $status->value = $deleteStatus->value;
278 $dbw->endAtomic( __METHOD__ );
281 $lbFactory = MediaWikiServices::getInstance()->getDBLoadBalancerFactory();
282 $lbFactory->rollbackPrimaryChanges( __METHOD__ );
285 $dbw->endAtomic( __METHOD__ );
289 if ( $status->isOK() ) {
290 $legacyUser = MediaWikiServices::getInstance()
292 ->newFromUserIdentity( $user );
303 $permissionStatus = PermissionStatus::newEmpty();
304 if ( !$this->context->getAuthority()->definitelyCan(
305 'delete', $this->title, $permissionStatus
310 $this->context->getOutput()->addModules(
'mediawiki.action.delete' );
311 $this->context->getOutput()->addModuleStyles(
'mediawiki.action.styles' );
314 $this->userOptionsLookup->getBoolOption( $this->context->getUser(),
'watchdeletion' ) ||
315 $this->watchlistManager->isWatched( $this->context->getUser(), $this->title );
317 $this->context->getOutput()->enableOOUI();
321 $fields[] =
new OOUI\LabelWidget( [
'label' =>
new OOUI\HtmlSnippet(
322 $this->prepareMessage(
'filedelete-intro' ) ) ]
325 $suppressAllowed = $this->context->getAuthority()->isAllowed(
'suppressrevision' );
326 $dropDownReason = $this->context->msg(
'filedelete-reason-dropdown' )->inContentLanguage()->text();
328 if ( $suppressAllowed ) {
329 $dropDownReason .=
"\n" . $this->context->msg(
'filedelete-reason-dropdown-suppress' )
330 ->inContentLanguage()->text();
333 $options = Xml::listDropDownOptions(
335 [
'other' => $this->context->msg(
'filedelete-reason-otherlist' )->inContentLanguage()->text() ]
337 $options = Xml::listDropDownOptionsOoui( $options );
339 $fields[] =
new OOUI\FieldLayout(
340 new OOUI\DropdownInputWidget( [
341 'name' =>
'wpDeleteReasonList',
342 'inputId' =>
'wpDeleteReasonList',
346 'options' => $options,
349 'label' => $this->context->msg(
'filedelete-comment' )->text(),
357 $fields[] =
new OOUI\FieldLayout(
358 new OOUI\TextInputWidget( [
359 'name' =>
'wpReason',
360 'inputId' =>
'wpReason',
362 'maxLength' => CommentStore::COMMENT_CHARACTER_LIMIT,
364 'value' => $this->context->getRequest()->getText(
'wpReason' ),
368 'label' => $this->context->msg(
'filedelete-otherreason' )->text(),
373 if ( $suppressAllowed ) {
374 $fields[] =
new OOUI\FieldLayout(
375 new OOUI\CheckboxInputWidget( [
376 'name' =>
'wpSuppress',
377 'inputId' =>
'wpSuppress',
382 'label' => $this->context->msg(
'revdelete-suppress' )->text(),
389 if ( $this->context->getUser()->isRegistered() ) {
390 $fields[] =
new OOUI\FieldLayout(
391 new OOUI\CheckboxInputWidget( [
393 'inputId' =>
'wpWatch',
395 'selected' => $checkWatch,
398 'label' => $this->context->msg(
'watchthis' )->text(),
405 $fields[] =
new OOUI\FieldLayout(
406 new OOUI\ButtonInputWidget( [
407 'name' =>
'mw-filedelete-submit',
408 'inputId' =>
'mw-filedelete-submit',
410 'value' => $this->context->msg(
'filedelete-submit' )->text(),
411 'label' => $this->context->msg(
'filedelete-submit' )->text(),
412 'flags' => [
'primary',
'destructive' ],
420 $fieldset =
new OOUI\FieldsetLayout( [
421 'label' => $this->context->msg(
'filedelete-legend' )->text(),
425 $form =
new OOUI\FormLayout( [
427 'action' => $this->getAction(),
428 'id' =>
'mw-img-deleteconfirm',
430 $form->appendContent(
432 new OOUI\HtmlSnippet(
435 $this->context->getUser()->getEditToken( $this->oldimage )
440 $this->context->getOutput()->addHTML(
441 new OOUI\PanelLayout( [
442 'classes' => [
'deletepage-wrapper' ],
450 if ( $this->context->getAuthority()->isAllowed(
'editinterface' ) ) {
452 if ( $suppressAllowed ) {
453 $link .= $this->linkRenderer->makeKnownLink(
454 $this->context->msg(
'filedelete-reason-dropdown-suppress' )->inContentLanguage()->getTitle(),
455 $this->context->msg(
'filedelete-edit-reasonlist-suppress' )->text(),
457 [
'action' =>
'edit' ]
459 $link .= $this->context->msg(
'pipe-separator' )->escaped();
461 $link .= $this->linkRenderer->makeKnownLink(
462 $this->context->msg(
'filedelete-reason-dropdown' )->inContentLanguage()->getTitle(),
463 $this->context->msg(
'filedelete-edit-reasonlist' )->text(),
465 [
'action' =>
'edit' ]
467 $this->context->getOutput()->addHTML(
'<p class="mw-filedelete-editreasons">' . $link .
'</p>' );
475 $deleteLogPage =
new LogPage(
'delete' );
476 $this->context->getOutput()->addHTML(
'<h2>' . $deleteLogPage->getName()->escaped() .
"</h2>\n" );
478 $out = $this->context->getOutput();
479 LogEventsList::showLogExtract( $out,
'delete', $this->title );
491 if ( $this->oldimage ) {
492 $lang = $this->context->getLanguage();
494 # 'filedelete-intro-old', 'filedelete-nofile-old', 'filedelete-success-old'
495 return $this->context->msg(
498 $lang->date( $this->getTimestamp(),
true ),
499 $lang->time( $this->getTimestamp(),
true ),
503 return $this->context->msg(
514 $this->context->getOutput()->setPageTitle( $this->context->msg(
'filedelete', $this->title->getText() ) );
515 $this->context->getOutput()->setRobotPolicy(
'noindex,nofollow' );
516 $this->context->getOutput()->addBacklinkSubtitle( $this->title );
526 return strlen( $oldimage ) >= 16
527 && strpos( $oldimage,
'/' ) ===
false
528 && strpos( $oldimage,
'\\' ) ===
false;
543 ? $oldfile && $oldfile->exists() && $oldfile->isLocal()
554 $q[
'action'] =
'delete';
556 if ( $this->oldimage ) {
557 $q[
'oldimage'] = $this->oldimage;
560 return $this->title->getLocalURL( $q );
569 return $this->oldfile->getTimestamp();
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
wfExpandUrl( $url, $defaultProto=PROTO_CURRENT)
Expand a potentially local URL to a fully-qualified URL.
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
wfEscapeWikiText( $text)
Escapes the given text so that it may be output using addWikiText() without any linking,...
if(ini_get('mbstring.func_overload')) if(!defined('MW_ENTRY_POINT'))
Pre-config setup: Before loading LocalSettings.php.
An error page which can definitely be safely rendered using the OutputPage.
getTitle()
Return the associated title object.
static runner()
Get a HookRunner instance for calling hooks using the new interfaces.
Class to represent a local file in the wiki's own database.
deleteOldFile( $archiveName, $reason, UserIdentity $user, $suppress=false)
Delete an old version of the file.
deleteFile( $reason, UserIdentity $user, $suppress=false)
Delete all versions of the file.
Class to simplify the use of log pages.
Class for creating new log entries and inserting them into the database.
Show an error when a user tries to do something they do not have the necessary permissions for.
Show an error when the wiki is locked/read-only and the user tries to do something that requires writ...
A service class for fetching the wiki's current read-only mode.
Prioritized list of file repositories.
Generic operation result class Has warning/error list, boolean status and arbitrary value.
Represents a title within MediaWiki.
getPrefixedText()
Get the prefixed title with spaces.
Interface for objects which can provide a MediaWiki context on request.
if(PHP_SAPI !='cli-server') if(!isset( $_SERVER['SCRIPT_FILENAME'])) $file
Item class for a filearchive table row.
if(!isset( $args[0])) $lang