64 bool $deleteTalk =
false
69 $status = $file->
deleteOldFile( $oldimage, $reason, $user, $suppress );
70 if ( $status->isOK() ) {
72 $logComment =
wfMessage(
'deletedrevision', $oldimage )->inContentLanguage()->text();
73 if ( trim( $reason ) !==
'' ) {
74 $logComment .=
wfMessage(
'colon-separator' )
75 ->inContentLanguage()->text() . $reason;
78 $logtype = $suppress ?
'suppress' :
'delete';
81 $logEntry->setPerformer( $user );
82 $logEntry->setTarget( $title );
83 $logEntry->setComment( $logComment );
84 $logEntry->addTags( $tags );
85 $logid = $logEntry->insert();
86 $logEntry->publish( $logid );
88 $status->value = $logid;
91 $status = Status::newFatal(
'cannotdelete',
94 $page = $services->getWikiPageFactory()->newFromTitle( $title );
95 '@phan-var \WikiFilePage $page';
96 $deleter = $services->getUserFactory()->newFromUserIdentity( $user );
97 $deletePage = $services->getDeletePageFactory()->newDeletePage( $page, $deleter );
99 $checkStatus = $deletePage->canProbablyDeleteAssociatedTalk();
100 if ( !$checkStatus->isGood() ) {
101 return Status::wrap( $checkStatus );
103 $deletePage->setDeleteAssociatedTalk(
true );
105 $dbw = $services->getConnectionProvider()->getPrimaryDatabase();
106 $dbw->startAtomic( __METHOD__, $dbw::ATOMIC_CANCELABLE );
108 $deleteStatus = $deletePage
109 ->setSuppress( $suppress )
110 ->setTags( $tags ?: [] )
111 ->deleteIfAllowed( $reason );
115 if ( $deleteStatus->isOK() ) {
116 $status = $file->
deleteFile( $reason, $user, $suppress );
117 if ( $status->isOK() ) {
119 $status->value =
false;
122 if ( $deletedID !==
null ) {
123 $status->value = $deletedID;
126 $logtype = $suppress ?
'suppress' :
'delete';
128 $logEntry->setPerformer( $user );
129 $logEntry->setTarget( $title );
130 $logEntry->setComment( $reason );
131 $logEntry->addTags( $tags );
132 $logid = $logEntry->insert();
133 $dbw->onTransactionPreCommitOrIdle(
134 static function () use ( $logEntry, $logid ) {
135 $logEntry->publish( $logid );
139 $status->value = $logid;
142 $dbw->endAtomic( __METHOD__ );
145 $dbw->cancelAtomic( __METHOD__ );
148 $dbw->endAtomic( __METHOD__ );
152 if ( $status->isOK() ) {
153 $legacyUser = $services->getUserFactory()
154 ->newFromUserIdentity( $user );
155 (
new HookRunner( $services->getHookContainer() ) )
156 ->onFileDeleteComplete( $file, $oldimage, $page, $legacyUser, $reason );