Merge "Add checks of $wgEnableBotPasswords in more places"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Thu, 21 Jan 2016 20:15:03 +0000 (20:15 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Thu, 21 Jan 2016 20:15:03 +0000 (20:15 +0000)
includes/api/ApiBase.php
includes/api/ApiHelp.php
includes/api/ApiParamInfo.php
includes/rcfeed/IRCColourfulRCFeedFormatter.php

index 5f67a22..13d13a6 100644 (file)
@@ -637,6 +637,17 @@ abstract class ApiBase extends ContextSource {
         * @{
         */
 
+       /**
+        * Indicate if the module supports dynamically-determined parameters that
+        * cannot be included in self::getAllowedParams().
+        * @return string|array|Message|null Return null if the module does not
+        *  support additional dynamic parameters, otherwise return a message
+        *  describing them.
+        */
+       public function dynamicParameterDocumentation() {
+               return null;
+       }
+
        /**
         * This method mangles parameter name based on the prefix supplied to the constructor.
         * Override this method to change parameter name during runtime
index 9bbb0b0..bbea20b 100644 (file)
@@ -392,8 +392,9 @@ class ApiHelp extends ApiBase {
                        }
 
                        $params = $module->getFinalParams( ApiBase::GET_VALUES_FOR_HELP );
+                       $dynamicParams = $module->dynamicParameterDocumentation();
                        $groups = array();
-                       if ( $params ) {
+                       if ( $params || $dynamicParams !== null ) {
                                $help['parameters'] .= Html::openElement( 'div',
                                        array( 'class' => 'apihelp-block apihelp-parameters' )
                                );
@@ -654,6 +655,17 @@ class ApiHelp extends ApiBase {
                                        }
                                }
 
+                               if ( $dynamicParams !== null ) {
+                                       $dynamicParams = ApiBase::makeMessage( $dynamicParams, $context, array(
+                                               $module->getModulePrefix(),
+                                               $module->getModuleName(),
+                                               $module->getModulePath()
+                                       ) );
+                                       $help['parameters'] .= Html::element( 'dt', null, '*' );
+                                       $help['parameters'] .= Html::rawElement( 'dd',
+                                               array( 'class' => 'description' ), $dynamicParams->parse() );
+                               }
+
                                $help['parameters'] .= Html::closeElement( 'dl' );
                                $help['parameters'] .= Html::closeElement( 'div' );
                        }
index a808ac0..18ca0ab 100644 (file)
@@ -387,6 +387,20 @@ class ApiParamInfo extends ApiBase {
                }
                ApiResult::setIndexedTagName( $ret['parameters'], 'param' );
 
+               $dynamicParams = $module->dynamicParameterDocumentation();
+               if ( $dynamicParams !== null ) {
+                       if ( $this->helpFormat === 'none' ) {
+                               $ret['dynamicparameters'] = true;
+                       } else {
+                               $dynamicParams = ApiBase::makeMessage( $dynamicParams, $this->context, array(
+                                       $module->getModulePrefix(),
+                                       $module->getModuleName(),
+                                       $module->getModulePath()
+                               ) );
+                               $this->formatHelpMessages( $ret, 'dynamicparameters', array( $dynamicParams ) );
+                       }
+               }
+
                return $ret;
        }
 
index 30be343..0efcebf 100644 (file)
@@ -123,10 +123,10 @@ class IRCColourfulRCFeedFormatter implements RCFeedFormatter {
         * @return string
         */
        public static function cleanupForIRC( $text ) {
-               return Sanitizer::decodeCharReferences( str_replace(
+               return str_replace(
                        array( "\n", "\r" ),
                        array( " ", "" ),
-                       $text
-               ) );
+                       Sanitizer::decodeCharReferences( $text )
+               );
        }
 }