aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--RELEASE-NOTES-1.352
-rw-r--r--includes/api/ApiUpload.php4
-rw-r--r--includes/jobqueue/jobs/AssembleUploadChunksJob.php4
-rw-r--r--includes/specials/SpecialUpload.php11
-rw-r--r--includes/upload/UploadBase.php16
5 files changed, 26 insertions, 11 deletions
diff --git a/RELEASE-NOTES-1.35 b/RELEASE-NOTES-1.35
index 54144c2d9233..3c2b843e9c90 100644
--- a/RELEASE-NOTES-1.35
+++ b/RELEASE-NOTES-1.35
@@ -749,6 +749,8 @@ because of Phabricator reports.
- WikiPage::getCreator
- WikiPage::getUser
- WikiPage::getUserText
+* UploadBase::checkWarnings now accepts a User parameter; not providing a
+ user is soft deprecated.
* Article::insertProtectNullRevision and WikiPage::insertProtectNullRevision
were hard deprecated. Instead, use WikiPage::insertNullProtectionRevision.
* Article::doDeleteArticle, Article::doDeleteArticleReal, and
diff --git a/includes/api/ApiUpload.php b/includes/api/ApiUpload.php
index 5b46c2bbc16f..47b114e296e2 100644
--- a/includes/api/ApiUpload.php
+++ b/includes/api/ApiUpload.php
@@ -661,7 +661,9 @@ class ApiUpload extends ApiBase {
* @return array
*/
protected function getApiWarnings() {
- $warnings = UploadBase::makeWarningsSerializable( $this->mUpload->checkWarnings() );
+ $warnings = UploadBase::makeWarningsSerializable(
+ $this->mUpload->checkWarnings( $this->getUser() )
+ );
return $this->transformWarnings( $warnings );
}
diff --git a/includes/jobqueue/jobs/AssembleUploadChunksJob.php b/includes/jobqueue/jobs/AssembleUploadChunksJob.php
index 9519b7ffd33c..83ff6a861d25 100644
--- a/includes/jobqueue/jobs/AssembleUploadChunksJob.php
+++ b/includes/jobqueue/jobs/AssembleUploadChunksJob.php
@@ -77,7 +77,9 @@ class AssembleUploadChunksJob extends Job {
// We can only get warnings like 'duplicate' after concatenating the chunks
$status = Status::newGood();
$status->value = [
- 'warnings' => UploadBase::makeWarningsSerializable( $upload->checkWarnings() )
+ 'warnings' => UploadBase::makeWarningsSerializable(
+ $upload->checkWarnings( $user )
+ )
];
// We have a new filekey for the fully concatenated file
diff --git a/includes/specials/SpecialUpload.php b/includes/specials/SpecialUpload.php
index ccaf12ad9fca..4f09d4a3e987 100644
--- a/includes/specials/SpecialUpload.php
+++ b/includes/specials/SpecialUpload.php
@@ -525,7 +525,8 @@ class SpecialUpload extends SpecialPage {
}
// Verify permissions for this title
- $permErrors = $this->mUpload->verifyTitlePermissions( $this->getUser() );
+ $user = $this->getUser();
+ $permErrors = $this->mUpload->verifyTitlePermissions( $user );
if ( $permErrors !== true ) {
$code = array_shift( $permErrors[0] );
$this->showRecoverableUploadError( $this->msg( $code, $permErrors[0] )->parse() );
@@ -537,14 +538,14 @@ class SpecialUpload extends SpecialPage {
// Check warnings if necessary
if ( !$this->mIgnoreWarning ) {
- $warnings = $this->mUpload->checkWarnings();
+ $warnings = $this->mUpload->checkWarnings( $user );
if ( $this->showUploadWarning( $warnings ) ) {
return;
}
}
// This is as late as we can throttle, after expected issues have been handled
- if ( UploadBase::isThrottled( $this->getUser() ) ) {
+ if ( UploadBase::isThrottled( $user ) ) {
$this->showRecoverableUploadError(
$this->msg( 'actionthrottledtext' )->escaped()
);
@@ -568,7 +569,7 @@ class SpecialUpload extends SpecialPage {
if ( $changeTags ) {
$changeTagsStatus = ChangeTags::canAddTagsAccompanyingChange(
- $changeTags, $this->getUser() );
+ $changeTags, $user );
if ( !$changeTagsStatus->isOK() ) {
$this->showUploadError( $this->getOutput()->parseAsInterface(
$changeTagsStatus->getWikiText( false, false, $this->getLanguage() )
@@ -582,7 +583,7 @@ class SpecialUpload extends SpecialPage {
$this->mComment,
$pageText,
$this->mWatchthis,
- $this->getUser(),
+ $user,
$changeTags
);
diff --git a/includes/upload/UploadBase.php b/includes/upload/UploadBase.php
index 76b4336b62aa..c806af19c470 100644
--- a/includes/upload/UploadBase.php
+++ b/includes/upload/UploadBase.php
@@ -665,9 +665,16 @@ abstract class UploadBase {
*
* This should not assume that mTempPath is set.
*
+ * @param User|null $user Accepted since 1.35
+ *
* @return mixed[] Array of warnings
*/
- public function checkWarnings() {
+ public function checkWarnings( $user = null ) {
+ if ( $user === null ) {
+ // TODO check uses and hard deprecate
+ $user = RequestContext::getMain()->getUser();
+ }
+
$warnings = [];
$localFile = $this->getLocalFile();
@@ -707,7 +714,7 @@ abstract class UploadBase {
$warnings['duplicate'] = $dupes;
}
- $archivedDupes = $this->checkAgainstArchiveDupes( $hash );
+ $archivedDupes = $this->checkAgainstArchiveDupes( $hash, $user );
if ( $archivedDupes !== null ) {
$warnings['duplicate-archive'] = $archivedDupes;
}
@@ -866,14 +873,15 @@ abstract class UploadBase {
/**
* @param string $hash sha1 hash of the file to check
+ * @param User $user
*
* @return string|null Name of the dupe or empty string if discovered (depending on visibility)
* null if the check discovered no dupes.
*/
- private function checkAgainstArchiveDupes( $hash ) {
+ private function checkAgainstArchiveDupes( $hash, User $user ) {
$archivedFile = new ArchivedFile( null, 0, '', $hash );
if ( $archivedFile->getID() > 0 ) {
- if ( $archivedFile->userCan( File::DELETED_FILE ) ) {
+ if ( $archivedFile->userCan( File::DELETED_FILE, $user ) ) {
return $archivedFile->getName();
} else {
return '';