From 678f2da99dad9ff5e1cceea851480d20d0323233 Mon Sep 17 00:00:00 2001 From: umherirrender Date: Mon, 18 Feb 2013 19:55:08 +0100 Subject: [PATCH] Pass user to File::recordUpload to avoid $wgUser Moves the giving of a user one level up, because File::recordUpload2 already needs this (and fallback to $wgUser). Can also use the user for the watching of the file, which was using $wgUser before. Change-Id: I697ae0df65b07ea59ab11b62804853cdc03cb172 --- includes/filerepo/file/File.php | 6 +++++- includes/filerepo/file/ForeignDBFile.php | 3 ++- includes/filerepo/file/LocalFile.php | 13 +++++++++---- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/includes/filerepo/file/File.php b/includes/filerepo/file/File.php index f3711150b2..bf2749fad4 100644 --- a/includes/filerepo/file/File.php +++ b/includes/filerepo/file/File.php @@ -1414,8 +1414,12 @@ abstract class File { * @param $copyStatus string * @param $source string * @param $watch bool + * @param $timestamp string|bool + * @param $user User object or null to use $wgUser + * @return bool + * @throws MWException */ - function recordUpload( $oldver, $desc, $license = '', $copyStatus = '', $source = '', $watch = false ) { + function recordUpload( $oldver, $desc, $license = '', $copyStatus = '', $source = '', $watch = false, $timestamp = false, User $user = null ) { $this->readOnlyError(); } diff --git a/includes/filerepo/file/ForeignDBFile.php b/includes/filerepo/file/ForeignDBFile.php index b0a1ebfcc6..610f556be3 100644 --- a/includes/filerepo/file/ForeignDBFile.php +++ b/includes/filerepo/file/ForeignDBFile.php @@ -73,11 +73,12 @@ class ForeignDBFile extends LocalFile { * @param $source string * @param $watch bool * @param $timestamp bool|string + * @param $user User object or null to use $wgUser * @return bool * @throws MWException */ function recordUpload( $oldver, $desc, $license = '', $copyStatus = '', $source = '', - $watch = false, $timestamp = false ) { + $watch = false, $timestamp = false, User $user = null ) { $this->readOnlyError(); } diff --git a/includes/filerepo/file/LocalFile.php b/includes/filerepo/file/LocalFile.php index 27386b4af6..11eab1e482 100644 --- a/includes/filerepo/file/LocalFile.php +++ b/includes/filerepo/file/LocalFile.php @@ -1120,20 +1120,25 @@ class LocalFile extends File { * @param $source string * @param $watch bool * @param $timestamp string|bool + * @param $user User object or null to use $wgUser * @return bool */ function recordUpload( $oldver, $desc, $license = '', $copyStatus = '', $source = '', - $watch = false, $timestamp = false ) + $watch = false, $timestamp = false, User $user = null ) { + if ( !$user ) { + global $wgUser; + $user = $wgUser; + } + $pageText = SpecialUpload::getInitialPageText( $desc, $license, $copyStatus, $source ); - if ( !$this->recordUpload2( $oldver, $desc, $pageText, false, $timestamp ) ) { + if ( !$this->recordUpload2( $oldver, $desc, $pageText, false, $timestamp, $user ) ) { return false; } if ( $watch ) { - global $wgUser; - $wgUser->addWatch( $this->getTitle() ); + $user->addWatch( $this->getTitle() ); } return true; } -- 2.20.1