ChangeTags: Rename "extension" to "software"
authorKunal Mehta <legoktm@member.fsf.org>
Tue, 13 Sep 2016 10:44:08 +0000 (03:44 -0700)
committerLegoktm <legoktm.wikipedia@gmail.com>
Tue, 13 Sep 2016 12:16:08 +0000 (12:16 +0000)
Most end users don't care about whether a tag comes from MediaWiki core
or an extension. Since we now have tags that are added by core, let's
rename all of the "extension" terminology to the more generic
"software".

Not renamed in this patch is the i18n message "tags-source-extension",
which will be done in a separate patch to coordinate with TWN, and the
"source" output of the API, to avoid a breaking change.

Change-Id: Ic7b32b3e4bef0c0153a7cf302eef4aa07c52c9f2

includes/api/ApiQueryTags.php
includes/changetags/ChangeTags.php
includes/specials/SpecialTags.php

index bd2f080..7a14aac 100644 (file)
@@ -50,11 +50,11 @@ class ApiQueryTags extends ApiQueryBase {
                $limit = $params['limit'];
                $result = $this->getResult();
 
-               $extensionDefinedTags = array_fill_keys( ChangeTags::listExtensionDefinedTags(), 0 );
+               $softwareDefinedTags = array_fill_keys( ChangeTags::listSoftwareDefinedTags(), 0 );
                $explicitlyDefinedTags = array_fill_keys( ChangeTags::listExplicitlyDefinedTags(), 0 );
-               $extensionActivatedTags = array_fill_keys( ChangeTags::listExtensionActivatedTags(), 0 );
+               $softwareActivatedTags = array_fill_keys( ChangeTags::listSoftwareActivatedTags(), 0 );
 
-               $definedTags = array_merge( $extensionDefinedTags, $explicitlyDefinedTags );
+               $definedTags = array_merge( $softwareDefinedTags, $explicitlyDefinedTags );
 
                # Fetch defined tags that aren't past the continuation
                if ( $params['continue'] !== null ) {
@@ -105,16 +105,17 @@ class ApiQueryTags extends ApiQueryBase {
                                $tag['hitcount'] = $hitcount;
                        }
 
-                       $isExtension = isset( $extensionDefinedTags[$tagName] );
+                       $isSoftware = isset( $softwareDefinedTags[$tagName] );
                        $isExplicit = isset( $explicitlyDefinedTags[$tagName] );
 
                        if ( $fld_defined ) {
-                               $tag['defined'] = $isExtension || $isExplicit;
+                               $tag['defined'] = $isSoftware || $isExplicit;
                        }
 
                        if ( $fld_source ) {
                                $tag['source'] = [];
-                               if ( $isExtension ) {
+                               if ( $isSoftware ) {
+                                       // TODO: Can we change this to 'software'?
                                        $tag['source'][] = 'extension';
                                }
                                if ( $isExplicit ) {
@@ -123,7 +124,7 @@ class ApiQueryTags extends ApiQueryBase {
                        }
 
                        if ( $fld_active ) {
-                               $tag['active'] = $isExplicit || isset( $extensionActivatedTags[$tagName] );
+                               $tag['active'] = $isExplicit || isset( $softwareActivatedTags[$tagName] );
                        }
 
                        $fit = $result->addValue( [ 'query', $this->getModuleName() ], null, $tag );
index 2b4e96e..3ef9641 100644 (file)
@@ -477,8 +477,8 @@ class ChangeTags {
                        // to be removed, a tag must not be defined by an extension, or equivalently it
                        // has to be either explicitly defined or not defined at all
                        // (assuming no edge case of a tag both explicitly-defined and extension-defined)
-                       $extensionDefinedTags = self::listExtensionDefinedTags();
-                       $intersect = array_intersect( $tagsToRemove, $extensionDefinedTags );
+                       $softwareDefinedTags = self::listSoftwareDefinedTags();
+                       $intersect = array_intersect( $tagsToRemove, $softwareDefinedTags );
                        if ( $intersect ) {
                                return self::restrictedTagError( 'tags-update-remove-not-allowed-one',
                                        'tags-update-remove-not-allowed-multi', $intersect );
@@ -1075,8 +1075,8 @@ class ChangeTags {
                        return Status::newFatal( 'tags-delete-too-many-uses', $tag, self::MAX_DELETE_USES );
                }
 
-               $extensionDefined = self::listExtensionDefinedTags();
-               if ( in_array( $tag, $extensionDefined ) ) {
+               $softwareDefined = self::listSoftwareDefinedTags();
+               if ( in_array( $tag, $softwareDefined ) ) {
                        // extension-defined tags can't be deleted unless the extension
                        // specifically allows it
                        $status = Status::newFatal( 'tags-delete-not-allowed' );
@@ -1136,7 +1136,7 @@ class ChangeTags {
         * @return array
         * @since 1.25
         */
-       public static function listExtensionActivatedTags() {
+       public static function listSoftwareActivatedTags() {
                // core active tags
                $tags = self::$coreTags;
                if ( !Hooks::isRegistered( 'ChangeTagsListActive' ) ) {
@@ -1160,6 +1160,16 @@ class ChangeTags {
                );
        }
 
+       /**
+        * @see listSoftwareActivatedTags
+        * @deprecated since 1.28 call listSoftwareActivatedTags directly
+        * @return array
+        */
+       public static function listExtensionActivatedTags() {
+               wfDeprecated( __METHOD__, '1.28' );
+               return self::listSoftwareActivatedTags();
+       }
+
        /**
         * Basically lists defined tags which count even if they aren't applied to anything.
         * It returns a union of the results of listExplicitlyDefinedTags() and
@@ -1169,7 +1179,7 @@ class ChangeTags {
         */
        public static function listDefinedTags() {
                $tags1 = self::listExplicitlyDefinedTags();
-               $tags2 = self::listExtensionDefinedTags();
+               $tags2 = self::listSoftwareDefinedTags();
                return array_values( array_unique( array_merge( $tags1, $tags2 ) ) );
        }
 
@@ -1215,7 +1225,7 @@ class ChangeTags {
         * @return string[] Array of strings: tags
         * @since 1.25
         */
-       public static function listExtensionDefinedTags() {
+       public static function listSoftwareDefinedTags() {
                // core defined tags
                $tags = self::$coreTags;
                if ( !Hooks::isRegistered( 'ListDefinedTags' ) ) {
@@ -1238,6 +1248,17 @@ class ChangeTags {
                );
        }
 
+       /**
+        * Call listSoftwareDefinedTags directly
+        *
+        * @see listSoftwareDefinedTags
+        * @deprecated since 1.28
+        */
+       public static function listExtensionDefinedTags() {
+               wfDeprecated( __METHOD__, '1.28' );
+               return self::listSoftwareDefinedTags();
+       }
+
        /**
         * Invalidates the short-term cache of defined tags used by the
         * list*DefinedTags functions, as well as the tag statistics cache.
index 5e5ed25..898d170 100644 (file)
@@ -34,14 +34,14 @@ class SpecialTags extends SpecialPage {
        protected $explicitlyDefinedTags;
 
        /**
-        * @var array List of extension defined tags
+        * @var array List of software defined tags
         */
-       protected $extensionDefinedTags;
+       protected $softwareDefinedTags;
 
        /**
-        * @var array List of extension activated tags
+        * @var array List of software activated tags
         */
-       protected $extensionActivatedTags;
+       protected $softwareActivatedTags;
 
        function __construct() {
                parent::__construct( 'Tags' );
@@ -124,11 +124,11 @@ class SpecialTags extends SpecialPage {
                // Used in #doTagRow()
                $this->explicitlyDefinedTags = array_fill_keys(
                        ChangeTags::listExplicitlyDefinedTags(), true );
-               $this->extensionDefinedTags = array_fill_keys(
-                       ChangeTags::listExtensionDefinedTags(), true );
+               $this->softwareDefinedTags = array_fill_keys(
+                       ChangeTags::listSoftwareDefinedTags(), true );
 
                // List all defined tags, even if they were never applied
-               $definedTags = array_keys( $this->explicitlyDefinedTags + $this->extensionDefinedTags );
+               $definedTags = array_keys( $this->explicitlyDefinedTags + $this->softwareDefinedTags );
 
                // Show header only if there exists atleast one tag
                if ( !$tagStats && !$definedTags ) {
@@ -149,8 +149,8 @@ class SpecialTags extends SpecialPage {
                );
 
                // Used in #doTagRow()
-               $this->extensionActivatedTags = array_fill_keys(
-                       ChangeTags::listExtensionActivatedTags(), true );
+               $this->softwareActivatedTags = array_fill_keys(
+                       ChangeTags::listSoftwareActivatedTags(), true );
 
                // Insert tags that have been applied at least once
                foreach ( $tagStats as $tag => $hitcount ) {
@@ -200,9 +200,10 @@ class SpecialTags extends SpecialPage {
                $newRow .= Xml::tags( 'td', null, $desc );
 
                $sourceMsgs = [];
-               $isExtension = isset( $this->extensionDefinedTags[$tag] );
+               $isSoftware = isset( $this->softwareDefinedTags[$tag] );
                $isExplicit = isset( $this->explicitlyDefinedTags[$tag] );
-               if ( $isExtension ) {
+               if ( $isSoftware ) {
+                       // TODO: Rename this message
                        $sourceMsgs[] = $this->msg( 'tags-source-extension' )->escaped();
                }
                if ( $isExplicit ) {
@@ -213,7 +214,7 @@ class SpecialTags extends SpecialPage {
                }
                $newRow .= Xml::tags( 'td', null, implode( Xml::element( 'br' ), $sourceMsgs ) );
 
-               $isActive = $isExplicit || isset( $this->extensionActivatedTags[$tag] );
+               $isActive = $isExplicit || isset( $this->softwareActivatedTags[$tag] );
                $activeMsg = ( $isActive ? 'tags-active-yes' : 'tags-active-no' );
                $newRow .= Xml::tags( 'td', null, $this->msg( $activeMsg )->escaped() );
 
@@ -357,9 +358,9 @@ class SpecialTags extends SpecialPage {
                $preText .= $this->msg( 'tags-delete-explanation-warning', $tag )->parseAsBlock();
 
                // see if the tag is in use
-               $this->extensionActivatedTags = array_fill_keys(
-                       ChangeTags::listExtensionActivatedTags(), true );
-               if ( isset( $this->extensionActivatedTags[$tag] ) ) {
+               $this->softwareActivatedTags = array_fill_keys(
+                       ChangeTags::listSoftwareActivatedTags(), true );
+               if ( isset( $this->softwareActivatedTags[$tag] ) ) {
                        $preText .= $this->msg( 'tags-delete-explanation-active', $tag )->parseAsBlock();
                }