Merge "Fix and make some types in PHPDoc and JSDoc tags more specific"
[lhc/web/wiklou.git] / includes / api / ApiParamInfo.php
index 67983e7..4ce0e9f 100644 (file)
@@ -401,6 +401,25 @@ class ApiParamInfo extends ApiBase {
                                        if ( isset( $settings[ApiBase::PARAM_SUBMODULE_PARAM_PREFIX] ) ) {
                                                $item['submoduleparamprefix'] = $settings[ApiBase::PARAM_SUBMODULE_PARAM_PREFIX];
                                        }
+
+                                       $deprecatedSubmodules = [];
+                                       foreach ( $item['submodules'] as $v => $submodulePath ) {
+                                               try {
+                                                       $submod = $this->getModuleFromPath( $submodulePath );
+                                                       if ( $submod && $submod->isDeprecated() ) {
+                                                               $deprecatedSubmodules[] = $v;
+                                                       }
+                                               } catch ( ApiUsageException $ex ) {
+                                                       // Ignore
+                                               }
+                                       }
+                                       if ( $deprecatedSubmodules ) {
+                                               $item['type'] = array_merge(
+                                                       array_diff( $item['type'], $deprecatedSubmodules ),
+                                                       $deprecatedSubmodules
+                                               );
+                                               $item['deprecatedvalues'] = $deprecatedSubmodules;
+                                       }
                                } elseif ( $settings[ApiBase::PARAM_TYPE] === 'tags' ) {
                                        $item['type'] = ChangeTags::listExplicitlyDefinedTags();
                                } else {
@@ -448,6 +467,16 @@ class ApiParamInfo extends ApiBase {
                        if ( !empty( $settings[ApiBase::PARAM_RANGE_ENFORCE] ) ) {
                                $item['enforcerange'] = true;
                        }
+                       if ( !empty( $settings[ApiBase::PARAM_DEPRECATED_VALUES] ) ) {
+                               $deprecatedValues = array_keys( $settings[ApiBase::PARAM_DEPRECATED_VALUES] );
+                               if ( is_array( $item['type'] ) ) {
+                                       $deprecatedValues = array_intersect( $deprecatedValues, $item['type'] );
+                               }
+                               if ( $deprecatedValues ) {
+                                       $item['deprecatedvalues'] = array_values( $deprecatedValues );
+                                       ApiResult::setIndexedTagName( $item['deprecatedvalues'], 'v' );
+                               }
+                       }
 
                        if ( !empty( $settings[ApiBase::PARAM_HELP_MSG_INFO] ) ) {
                                $item['info'] = [];
@@ -543,6 +572,6 @@ class ApiParamInfo extends ApiBase {
        }
 
        public function getHelpUrls() {
-               return 'https://www.mediawiki.org/wiki/API:Parameter_information';
+               return 'https://www.mediawiki.org/wiki/Special:MyLanguage/API:Parameter_information';
        }
 }