Merge "Remove incorrect timezone conversion from date parameters"
[lhc/web/wiklou.git] / includes / api / ApiPageSet.php
index 515ebc5..3786e8d 100644 (file)
@@ -460,7 +460,7 @@ class ApiPageSet extends ApiBase {
        /**
         * Get a list of redirect resolutions - maps a title to its redirect
         * target. Includes generator data for redirect source when available.
-        * @param ApiResult $result
+        * @param ApiResult|null $result
         * @return array Array of prefixed_title (string) => Title object
         * @since 1.21
         */
@@ -507,16 +507,15 @@ class ApiPageSet extends ApiBase {
        /**
         * Get a list of title normalizations - maps a title to its normalized
         * version in the form of result array.
-        * @param ApiResult $result
+        * @param ApiResult|null $result
         * @return array Array of raw_prefixed_title (string) => prefixed_title (string)
         * @since 1.21
         */
        public function getNormalizedTitlesAsResult( $result = null ) {
-               global $wgContLang;
-
                $values = [];
+               $contLang = MediaWikiServices::getInstance()->getContentLanguage();
                foreach ( $this->getNormalizedTitles() as $rawTitleStr => $titleStr ) {
-                       $encode = ( $wgContLang->normalize( $rawTitleStr ) !== $rawTitleStr );
+                       $encode = $contLang->normalize( $rawTitleStr ) !== $rawTitleStr;
                        $values[] = [
                                'fromencoded' => $encode,
                                'from' => $encode ? rawurlencode( $rawTitleStr ) : $rawTitleStr,
@@ -542,7 +541,7 @@ class ApiPageSet extends ApiBase {
        /**
         * Get a list of title conversions - maps a title to its converted
         * version as a result array.
-        * @param ApiResult $result
+        * @param ApiResult|null $result
         * @return array Array of (from, to) strings
         * @since 1.21
         */
@@ -573,7 +572,7 @@ class ApiPageSet extends ApiBase {
        /**
         * Get a list of interwiki titles - maps a title to its interwiki
         * prefix as result.
-        * @param ApiResult $result
+        * @param ApiResult|null $result
         * @param bool $iwUrl
         * @return array Array of raw_prefixed_title (string) => interwiki_prefix (string)
         * @since 1.21
@@ -692,7 +691,7 @@ class ApiPageSet extends ApiBase {
 
        /**
         * Revision IDs that were not found in the database as result array.
-        * @param ApiResult $result
+        * @param ApiResult|null $result
         * @return array Array of revision IDs
         * @since 1.21
         */
@@ -1198,15 +1197,14 @@ class ApiPageSet extends ApiBase {
                                $this->mInterwikiTitles[$unconvertedTitle] = $titleObj->getInterwiki();
                        } else {
                                // Variants checking
-                               global $wgContLang;
-                               if ( $this->mConvertTitles &&
-                                       count( $wgContLang->getVariants() ) > 1 &&
-                                       !$titleObj->exists()
+                               $contLang = MediaWikiServices::getInstance()->getContentLanguage();
+                               if (
+                                       $this->mConvertTitles && $contLang->hasVariants() && !$titleObj->exists()
                                ) {
                                        // Language::findVariantLink will modify titleText and titleObj into
                                        // the canonical variant if possible
                                        $titleText = is_string( $title ) ? $title : $titleObj->getPrefixedText();
-                                       $wgContLang->findVariantLink( $titleText, $titleObj );
+                                       $contLang->findVariantLink( $titleText, $titleObj );
                                        $titleWasConverted = $unconvertedTitle !== $titleObj->getPrefixedText();
                                }
 
@@ -1402,7 +1400,7 @@ class ApiPageSet extends ApiBase {
                                if ( isset( $data[$toPageId] ) &&
                                        isset( $this->mGeneratorData[$fromNs][$fromDBkey] )
                                ) {
-                                       // It is necesary to set both $data and add to $result, if an ApiResult,
+                                       // It is necessary to set both $data and add to $result, if an ApiResult,
                                        // to ensure multiple redirects to the same destination are all merged.
                                        $data[$toPageId] = call_user_func(
                                                $this->mRedirectMergePolicy,