Mass conversion of $wgContLang to service
[lhc/web/wiklou.git] / includes / deferred / LinksUpdate.php
index 39e8bd9..ae3c660 100644 (file)
@@ -141,14 +141,9 @@ class LinksUpdate extends DataUpdate implements EnqueueableDataUpdate {
                }
 
                foreach ( $this->mCategories as &$sortkey ) {
-                       # If the sortkey is longer then 255 bytes,
-                       # it truncated by DB, and then doesn't get
-                       # matched when comparing existing vs current
-                       # categories, causing T27254.
-                       # Also. substr behaves weird when given "".
-                       if ( $sortkey !== '' ) {
-                               $sortkey = substr( $sortkey, 0, 255 );
-                       }
+                       # If the sortkey is longer then 255 bytes, it is truncated by DB, and then doesn't match
+                       # when comparing existing vs current categories, causing T27254.
+                       $sortkey = mb_strcut( $sortkey, 0, 255 );
                }
 
                $this->mRecursive = $recursive;
@@ -586,12 +581,13 @@ class LinksUpdate extends DataUpdate implements EnqueueableDataUpdate {
         * @return array
         */
        private function getCategoryInsertions( $existing = [] ) {
-               global $wgContLang, $wgCategoryCollation;
+               global $wgCategoryCollation;
                $diffs = array_diff_assoc( $this->mCategories, $existing );
                $arr = [];
                foreach ( $diffs as $name => $prefix ) {
                        $nt = Title::makeTitleSafe( NS_CATEGORY, $name );
-                       $wgContLang->findVariantLink( $name, $nt, true );
+                       MediaWikiServices::getInstance()->getContentLanguage()->
+                               findVariantLink( $name, $nt, true );
 
                        $type = MWNamespace::getCategoryLinkType( $this->mTitle->getNamespace() );