66 bool $deleteTalk =
false
70 $status =
$file->deleteOldFile( $oldimage, $reason, $user, $suppress );
71 if ( $status->isOK() ) {
73 $logComment =
wfMessage(
'deletedrevision', $oldimage )->inContentLanguage()->text();
74 if ( trim( $reason ) !==
'' ) {
75 $logComment .=
wfMessage(
'colon-separator' )
76 ->inContentLanguage()->text() . $reason;
79 $logtype = $suppress ?
'suppress' :
'delete';
82 $logEntry->setPerformer( $user );
83 $logEntry->setTarget(
$title );
84 $logEntry->setComment( $logComment );
85 $logEntry->addTags( $tags );
86 $logid = $logEntry->insert();
87 $logEntry->publish( $logid );
89 $status->value = $logid;
92 $status = Status::newFatal(
'cannotdelete',
96 $page = $services->getWikiPageFactory()->newFromTitle(
$title );
97 '@phan-var \WikiFilePage $page';
98 $deleter = $services->getUserFactory()->newFromUserIdentity( $user );
99 $deletePage = $services->getDeletePageFactory()->newDeletePage( $page, $deleter );
101 $checkStatus = $deletePage->canProbablyDeleteAssociatedTalk();
102 if ( !$checkStatus->isGood() ) {
103 return Status::wrap( $checkStatus );
105 $deletePage->setDeleteAssociatedTalk(
true );
108 $dbw->startAtomic( __METHOD__, $dbw::ATOMIC_CANCELABLE );
110 $deleteStatus = $deletePage
111 ->setSuppress( $suppress )
112 ->setTags( $tags ?: [] )
113 ->deleteIfAllowed( $reason );
117 if ( $deleteStatus->isOK() ) {
118 $status =
$file->deleteFile( $reason, $user, $suppress );
119 if ( $status->isOK() ) {
121 $status->value =
false;
124 if ( $deletedID !==
null ) {
125 $status->value = $deletedID;
128 $logtype = $suppress ?
'suppress' :
'delete';
130 $logEntry->setPerformer( $user );
131 $logEntry->setTarget(
$title );
132 $logEntry->setComment( $reason );
133 $logEntry->addTags( $tags );
134 $logid = $logEntry->insert();
135 $dbw->onTransactionPreCommitOrIdle(
136 static function () use ( $logEntry, $logid ) {
137 $logEntry->publish( $logid );
141 $status->value = $logid;
144 $dbw->endAtomic( __METHOD__ );
147 $dbw->cancelAtomic( __METHOD__ );
150 $dbw->endAtomic( __METHOD__ );
154 if ( $status->isOK() ) {
157 ->newFromUserIdentity( $user );
158 Hooks::runner()->onFileDeleteComplete(
$file, $oldimage, $page, $legacyUser, $reason );