if ( $oldimage ) {
$page = null;
- $status = $file->deleteOld( $oldimage, $reason, $suppress );
+ $status = $file->deleteOld( $oldimage, $reason, $suppress, $user );
if ( $status->ok ) {
// Need to do a log item
$logComment = wfMessage( 'deletedrevision', $oldimage )->inContentLanguage()->text();
// doDeleteArticleReal() returns a non-fatal error status if the page
// or revision is missing, so check for isOK() rather than isGood()
if ( $deleteStatus->isOK() ) {
- $status = $file->delete( $reason, $suppress );
+ $status = $file->delete( $reason, $suppress, $user );
if ( $status->isOK() ) {
$dbw->commit( __METHOD__ );
} else {
*
* @param string $reason
* @param bool $suppress
+ * @param User|null $user
* @return FileRepoStatus
*/
- function delete( $reason, $suppress = false ) {
+ function delete( $reason, $suppress = false, $user = null ) {
if ( $this->getRepo()->getReadOnlyReason() !== false ) {
return $this->readOnlyFatalStatus();
}
- $batch = new LocalFileDeleteBatch( $this, $reason, $suppress );
+ $batch = new LocalFileDeleteBatch( $this, $reason, $suppress, $user );
$this->lock(); // begin
$batch->addCurrent();
* @param string $archiveName
* @param string $reason
* @param bool $suppress
+ * @param User|null $user
* @throws MWException Exception on database or file store failure
* @return FileRepoStatus
*/
- function deleteOld( $archiveName, $reason, $suppress = false ) {
+ function deleteOld( $archiveName, $reason, $suppress = false, $user = null ) {
global $wgUseSquid;
if ( $this->getRepo()->getReadOnlyReason() !== false ) {
return $this->readOnlyFatalStatus();
}
- $batch = new LocalFileDeleteBatch( $this, $reason, $suppress );
+ $batch = new LocalFileDeleteBatch( $this, $reason, $suppress, $user );
$this->lock(); // begin
$batch->addOld( $archiveName );
/** @var FileRepoStatus */
private $status;
+ /** @var User */
+ private $user;
+
/**
* @param File $file
* @param string $reason
* @param bool $suppress
+ * @param User|null $user
*/
- function __construct( File $file, $reason = '', $suppress = false ) {
+ function __construct( File $file, $reason = '', $suppress = false, $user = null ) {
$this->file = $file;
$this->reason = $reason;
$this->suppress = $suppress;
+ if ( $user ) {
+ $this->user = $user;
+ } else {
+ global $wgUser;
+ $this->user = $wgUser;
+ }
$this->status = $file->repo->newGood();
}
}
function doDBInserts() {
- global $wgUser;
-
$dbw = $this->file->repo->getMasterDB();
$encTimestamp = $dbw->addQuotes( $dbw->timestamp() );
- $encUserId = $dbw->addQuotes( $wgUser->getId() );
+ $encUserId = $dbw->addQuotes( $this->user->getId() );
$encReason = $dbw->addQuotes( $this->reason );
$encGroup = $dbw->addQuotes( 'deleted' );
$ext = $this->file->getExtension();