$main = new ApiMain( $req );
$pageSet = new ApiPageSet( $main );
$pageSet->execute();
+ $redirValues = $pageSet->getRedirectTitlesAsResult( $this->getResult() );
$to = $page;
foreach ( $pageSet->getRedirectTitles() as $title ) {
$result_array['modules'] = array_values( array_unique( $p_result->getModules() ) );
$result_array['modulescripts'] = array_values( array_unique( $p_result->getModuleScripts() ) );
$result_array['modulestyles'] = array_values( array_unique( $p_result->getModuleStyles() ) );
- $result_array['modulemessages'] = array_values( array_unique( $p_result->getModuleMessages() ) );
+ // To be removed in 1.27
+ $result_array['modulemessages'] = array();
+ $this->setWarning( 'modulemessages is deprecated since MediaWiki 1.26' );
+ }
+
+ if ( isset( $prop['jsconfigvars'] ) ) {
+ $result_array['jsconfigvars'] = $this->formatJsConfigVars( $p_result->getJsConfigVars() );
+ }
+
+ if ( isset( $prop['encodedjsconfigvars'] ) ) {
+ $result_array['encodedjsconfigvars'] = FormatJson::encode(
+ $p_result->getJsConfigVars(), false, FormatJson::ALL_OK
+ );
+ $result_array[ApiResult::META_SUBELEMENTS][] = 'encodedjsconfigvars';
}
if ( isset( $prop['indicators'] ) ) {
return $result;
}
+ private function formatJsConfigVars( $vars, $forceHash = true ) {
+ // Process subarrays and determine if this is a JS [] or {}
+ $hash = $forceHash;
+ $maxKey = -1;
+ $bools = array();
+ foreach ( $vars as $k => $v ) {
+ if ( is_array( $v ) || is_object( $v ) ) {
+ $vars[$k] = $this->formatJsConfigVars( (array)$v, false );
+ } elseif ( is_bool( $v ) ) {
+ // Better here to use real bools even in BC formats
+ $bools[] = $k;
+ }
+ if ( is_string( $k ) ) {
+ $hash = true;
+ } elseif ( $k > $maxKey ) {
+ $maxKey = $k;
+ }
+ }
+ if ( !$hash && $maxKey !== count( $vars ) - 1 ) {
+ $hash = true;
+ }
+
+ // Get the list of keys we actually care about. Unfortunately, we can't support
+ // certain keys that conflict with ApiResult metadata.
+ $keys = array_diff( array_keys( $vars ), array(
+ ApiResult::META_TYPE, ApiResult::META_PRESERVE_KEYS, ApiResult::META_KVP_KEY_NAME,
+ ApiResult::META_INDEXED_TAG_NAME, ApiResult::META_BC_BOOLS
+ ) );
+
+ // Set metadata appropriately
+ if ( $hash ) {
+ return array(
+ ApiResult::META_TYPE => 'kvp',
+ ApiResult::META_KVP_KEY_NAME => 'key',
+ ApiResult::META_PRESERVE_KEYS => $keys,
+ ApiResult::META_BC_BOOLS => $bools,
+ ApiResult::META_INDEXED_TAG_NAME => 'var',
+ ) + $vars;
+ } else {
+ return array(
+ ApiResult::META_TYPE => 'array',
+ ApiResult::META_BC_BOOLS => $bools,
+ ApiResult::META_INDEXED_TAG_NAME => 'value',
+ ) + $vars;
+ }
+ }
+
private function setIndexedTagNames( &$array, $mapping ) {
foreach ( $mapping as $key => $name ) {
if ( isset( $array[$key] ) ) {
'headitems',
'headhtml',
'modules',
+ 'jsconfigvars',
+ 'encodedjsconfigvars',
'indicators',
'iwlinks',
'wikitext',
'properties',
'limitreportdata',
'limitreporthtml',
- )
+ ),
+ ApiBase::PARAM_HELP_MSG_PER_VALUE => array(),
),
'pst' => false,
'onlypst' => false,