From: umherirrender Date: Mon, 18 Feb 2013 18:55:08 +0000 (+0100) Subject: Pass user to File::recordUpload to avoid $wgUser X-Git-Tag: 1.31.0-rc.0~20591 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/comptes/ajouter.php?a=commitdiff_plain;h=678f2da99dad9ff5e1cceea851480d20d0323233;p=lhc%2Fweb%2Fwiklou.git 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 --- 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; }