Cenarium has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/312324

Change subject: Deprecate ChangeTags::canAddTagsAccompanyingChange
......................................................................

Deprecate ChangeTags::canAddTagsAccompanyingChange

This deprecates ChangeTags::canAddTagsAccompanyingChange in favor of its
ChangeTagsContext equivalent.

Change-Id: I3615f19790e8db0a125ebc0b4cbcc932e974fa5a
---
M includes/EditPage.php
M includes/api/ApiBase.php
M includes/api/ApiDelete.php
M includes/api/ApiEditPage.php
M includes/api/ApiPatrol.php
M includes/api/ApiProtect.php
M includes/api/ApiRollback.php
M includes/api/ApiUnblock.php
M includes/api/ApiUndelete.php
M includes/api/ApiUpload.php
M includes/changetags/ChangeTags.php
M includes/page/WikiPage.php
M includes/specials/SpecialUpload.php
13 files changed, 54 insertions(+), 18 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/24/312324/1

diff --git a/includes/EditPage.php b/includes/EditPage.php
index 606b4cd..d9b4054 100644
--- a/includes/EditPage.php
+++ b/includes/EditPage.php
@@ -1853,8 +1853,9 @@
                }
 
                if ( $this->changeTags ) {
-                       $changeTagsStatus = 
ChangeTags::canAddTagsAccompanyingChange(
-                               $this->changeTags, $wgUser );
+                       $changeTagsContext = new ChangeTagsContext( 
$this->context->getConfig() );
+                       $changeTagsStatus = 
$changeTagsContext->canAddTagsAccompanyingChange(
+                               $this->changeTags, $wgUser, 
$this->context->getLanguage() );
                        if ( !$changeTagsStatus->isOK() ) {
                                $changeTagsStatus->value = 
self::AS_CHANGE_TAG_ERROR;
                                return $changeTagsStatus;
diff --git a/includes/api/ApiBase.php b/includes/api/ApiBase.php
index 866c9cc..f5b8778 100644
--- a/includes/api/ApiBase.php
+++ b/includes/api/ApiBase.php
@@ -1135,7 +1135,9 @@
                                                if ( !is_array( $value ) && 
!$multi ) {
                                                        $value = [ $value ];
                                                }
-                                               $tagsStatus = 
ChangeTags::canAddTagsAccompanyingChange( $value );
+                                               $tagsStatus = 
$this->getChangeTagsContext()->canAddTagsAccompanyingChange(
+                                                       $value, null, 
$this->getContext()->getLanguage()
+                                               );
                                                if ( !$tagsStatus->isGood() ) {
                                                        $this->dieStatus( 
$tagsStatus );
                                                }
diff --git a/includes/api/ApiDelete.php b/includes/api/ApiDelete.php
index 77911b0..3f78a20 100644
--- a/includes/api/ApiDelete.php
+++ b/includes/api/ApiDelete.php
@@ -61,7 +61,11 @@
                // If change tagging was requested, check that the user is 
allowed to tag,
                // and the tags are valid
                if ( count( $params['tags'] ) ) {
-                       $tagStatus = ChangeTags::canAddTagsAccompanyingChange( 
$params['tags'], $user );
+                       $tagStatus = 
$this->getChangeTagsContext()->canAddTagsAccompanyingChange(
+                               $params['tags'],
+                               $user,
+                               $this->getContext()->getLanguage()
+                       );
                        if ( !$tagStatus->isOK() ) {
                                $this->dieStatus( $tagStatus );
                        }
diff --git a/includes/api/ApiEditPage.php b/includes/api/ApiEditPage.php
index d6de834..94da18d 100644
--- a/includes/api/ApiEditPage.php
+++ b/includes/api/ApiEditPage.php
@@ -376,7 +376,11 @@
 
                // Apply change tags
                if ( count( $params['tags'] ) ) {
-                       $tagStatus = ChangeTags::canAddTagsAccompanyingChange( 
$params['tags'], $user );
+                       $tagStatus = 
$this->getChangeTagsContext()->canAddTagsAccompanyingChange(
+                               $params['tags'],
+                               $user,
+                               $this->getContext()->getLanguage()
+                       );
                        if ( $tagStatus->isOK() ) {
                                $requestArray['wpChangeTags'] = implode( ',', 
$params['tags'] );
                        } else {
diff --git a/includes/api/ApiPatrol.php b/includes/api/ApiPatrol.php
index 6252882..5f71d35 100644
--- a/includes/api/ApiPatrol.php
+++ b/includes/api/ApiPatrol.php
@@ -61,7 +61,11 @@
 
                // Check if user can add tags
                if ( !is_null( $tags ) ) {
-                       $ableToTag = ChangeTags::canAddTagsAccompanyingChange( 
$tags, $user );
+                       $ableToTag = 
$this->getChangeTagsContext()->canAddTagsAccompanyingChange(
+                               $tags,
+                               $user,
+                               $this->getContext()->getLanguage()
+                       );
                        if ( !$ableToTag->isOK() ) {
                                $this->dieStatus( $ableToTag );
                        }
diff --git a/includes/api/ApiProtect.php b/includes/api/ApiProtect.php
index d289060..3ce7f1e 100644
--- a/includes/api/ApiProtect.php
+++ b/includes/api/ApiProtect.php
@@ -47,7 +47,11 @@
 
                // Check if user can add tags
                if ( !is_null( $tags ) ) {
-                       $ableToTag = ChangeTags::canAddTagsAccompanyingChange( 
$tags, $user );
+                       $ableToTag = 
$this->getChangeTagsContext()->canAddTagsAccompanyingChange(
+                               $tags,
+                               $user,
+                               $this->getContext()->getLanguage()
+                       );
                        if ( !$ableToTag->isOK() ) {
                                $this->dieStatus( $ableToTag );
                        }
diff --git a/includes/api/ApiRollback.php b/includes/api/ApiRollback.php
index b9911da..6f1acaf 100644
--- a/includes/api/ApiRollback.php
+++ b/includes/api/ApiRollback.php
@@ -53,7 +53,11 @@
                // If change tagging was requested, check that the user is 
allowed to tag,
                // and the tags are valid
                if ( count( $params['tags'] ) ) {
-                       $tagStatus = ChangeTags::canAddTagsAccompanyingChange( 
$params['tags'], $user );
+                       $tagStatus = 
$this->getChangeTagsContext()->canAddTagsAccompanyingChange(
+                               $params['tags'],
+                               $user,
+                               $this->getContext()->getLanguage()
+                       );
                        if ( !$tagStatus->isOK() ) {
                                $this->dieStatus( $tagStatus );
                        }
diff --git a/includes/api/ApiUnblock.php b/includes/api/ApiUnblock.php
index ace41a4..48595f6 100644
--- a/includes/api/ApiUnblock.php
+++ b/includes/api/ApiUnblock.php
@@ -65,7 +65,11 @@
 
                // Check if user can add tags
                if ( !is_null( $params['tags'] ) ) {
-                       $ableToTag = ChangeTags::canAddTagsAccompanyingChange( 
$params['tags'], $user );
+                       $ableToTag = 
$this->getChangeTagsContext()->canAddTagsAccompanyingChange(
+                               $params['tags'],
+                               $user,
+                               $this->getContext()->getLanguage()
+                       );
                        if ( !$ableToTag->isOK() ) {
                                $this->dieStatus( $ableToTag );
                        }
diff --git a/includes/api/ApiUndelete.php b/includes/api/ApiUndelete.php
index e24f2ce..9126274 100644
--- a/includes/api/ApiUndelete.php
+++ b/includes/api/ApiUndelete.php
@@ -49,7 +49,11 @@
 
                // Check if user can add tags
                if ( !is_null( $params['tags'] ) ) {
-                       $ableToTag = ChangeTags::canAddTagsAccompanyingChange( 
$params['tags'], $user );
+                       $ableToTag = 
$this->getChangeTagsContext()->canAddTagsAccompanyingChange(
+                               $params['tags'],
+                               $user,
+                               $this->getContext()->getLanguage()
+                       );
                        if ( !$ableToTag->isOK() ) {
                                $this->dieStatus( $ableToTag );
                        }
diff --git a/includes/api/ApiUpload.php b/includes/api/ApiUpload.php
index 7b44f40..c7caaf3 100644
--- a/includes/api/ApiUpload.php
+++ b/includes/api/ApiUpload.php
@@ -811,7 +811,11 @@
                }
 
                if ( $this->mParams['tags'] ) {
-                       $status = ChangeTags::canAddTagsAccompanyingChange( 
$this->mParams['tags'], $this->getUser() );
+                       $status = 
$this->getChangeTagsContext()->canAddTagsAccompanyingChange(
+                               $this->mParams['tags'],
+                               $this->getUser(),
+                               $this->getContext()->getLanguage()
+                       );
                        if ( !$status->isOK() ) {
                                $this->dieStatus( $status );
                        }
diff --git a/includes/changetags/ChangeTags.php 
b/includes/changetags/ChangeTags.php
index 68d761a..2bf1b1f 100644
--- a/includes/changetags/ChangeTags.php
+++ b/includes/changetags/ChangeTags.php
@@ -611,12 +611,12 @@
        }
 
        /**
-        * @see ChangeTagsContext::canAddTagsAccompanyingChange
+        * @deprecated since 1.28, use 
ChangeTagsContext::canAddTagsAccompanyingChange
         * @since 1.25
-        * @todo deprecate
         */
        public static function canAddTagsAccompanyingChange( array $tags,
                User $user = null ) {
+               wfDeprecated( __METHOD__, '1.28' );
                $changeTagsContext = new ChangeTagsContext( 
RequestContext::getMain()->getConfig() );
                $lang = RequestContext::getMain()->getLanguage();
                return $changeTagsContext->canAddTagsAccompanyingChange( $tags, 
$user, $lang );
diff --git a/includes/page/WikiPage.php b/includes/page/WikiPage.php
index fe0fffc..c8f008c 100644
--- a/includes/page/WikiPage.php
+++ b/includes/page/WikiPage.php
@@ -1621,7 +1621,7 @@
         *   database.
         * @param array|null $tags Change tags to apply to this edit
         * Callers are responsible for permission checks
-        * (with ChangeTags::canAddTagsAccompanyingChange)
+        * (with ChangeTagsContext::canAddTagsAccompanyingChange)
         *
         * @throws MWException
         * @return Status Possible errors:
@@ -3147,7 +3147,7 @@
         * @param User $user The user performing the rollback
         * @param array|null $tags Change tags to apply to the rollback
         * Callers are responsible for permission checks
-        * (with ChangeTags::canAddTagsAccompanyingChange)
+        * (with ChangeTagsContext::canAddTagsAccompanyingChange)
         *
         * @return array Array of errors, each error formatted as
         *   array(messagekey, param1, param2, ...).
@@ -3196,7 +3196,7 @@
         * @param User $guser The user performing the rollback
         * @param array|null $tags Change tags to apply to the rollback
         * Callers are responsible for permission checks
-        * (with ChangeTags::canAddTagsAccompanyingChange)
+        * (with ChangeTagsContext::canAddTagsAccompanyingChange)
         *
         * @return array
         */
diff --git a/includes/specials/SpecialUpload.php 
b/includes/specials/SpecialUpload.php
index 4583305..1dc0d4b 100644
--- a/includes/specials/SpecialUpload.php
+++ b/includes/specials/SpecialUpload.php
@@ -545,8 +545,9 @@
                }
 
                if ( $changeTags ) {
-                       $changeTagsStatus = 
ChangeTags::canAddTagsAccompanyingChange(
-                               $changeTags, $this->getUser() );
+                       $changeTagsContext = new ChangeTagsContext( 
$this->getConfig() );
+                       $changeTagsStatus = 
$changeTagsContext->canAddTagsAccompanyingChange(
+                               $changeTags, $this->getUser(), 
$this->getLanguage() );
                        if ( !$changeTagsStatus->isOK() ) {
                                $this->showUploadError( 
$this->getOutput()->parse( $changeTagsStatus->getWikiText() ) );
 

-- 
To view, visit https://gerrit.wikimedia.org/r/312324
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3615f19790e8db0a125ebc0b4cbcc932e974fa5a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Cenarium <cenarium.sy...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to