Merge "Print chained exceptions when maintenance script fails."
[lhc/web/wiklou.git] / languages / Language.php
index 539bdf4..6c8b19e 100644 (file)
@@ -27,6 +27,7 @@
  */
 
 use CLDRPluralRuleParser\Evaluator;
+use MediaWiki\MediaWikiServices;
 use Wikimedia\Assert\Assert;
 
 /**
@@ -506,7 +507,8 @@ class Language {
                if ( is_null( $this->namespaceNames ) ) {
                        global $wgMetaNamespace, $wgMetaNamespaceTalk, $wgExtraNamespaces;
 
-                       $validNamespaces = MWNamespace::getCanonicalNamespaces();
+                       $validNamespaces = MediaWikiServices::getInstance()->getNamespaceInfo()->
+                               getCanonicalNamespaces();
 
                        $this->namespaceNames = $wgExtraNamespaces +
                                self::$dataCache->getItem( $this->mCode, 'namespaceNames' );
@@ -744,7 +746,8 @@ class Language {
         */
        public function getNsIndex( $text ) {
                $lctext = $this->lc( $text );
-               $ns = MWNamespace::getCanonicalIndex( $lctext );
+               $ns = MediaWikiServices::getInstance()->getNamespaceInfo()->
+                       getCanonicalIndex( $lctext );
                if ( $ns !== null ) {
                        return $ns;
                }
@@ -811,7 +814,8 @@ class Language {
         * @return array
         */
        public function getExtraUserToggles() {
-               return (array)self::$dataCache->getItem( $this->mCode, 'extraUserToggles' );
+               wfDeprecated( __METHOD__, '1.34' );
+               return [];
        }
 
        /**
@@ -3030,34 +3034,6 @@ class Language {
                }
        }
 
-       /**
-        * @deprecated No-op since 1.28
-        */
-       function initEncoding() {
-               wfDeprecated( __METHOD__, '1.28' );
-               // No-op.
-       }
-
-       /**
-        * @param string $s
-        * @return string
-        * @deprecated No-op since 1.28
-        */
-       function recodeForEdit( $s ) {
-               wfDeprecated( __METHOD__, '1.28' );
-               return $s;
-       }
-
-       /**
-        * @param string $s
-        * @return string
-        * @deprecated No-op since 1.28
-        */
-       function recodeInput( $s ) {
-               wfDeprecated( __METHOD__, '1.28' );
-               return $s;
-       }
-
        /**
         * Convert a UTF-8 string to normal form C. In Malayalam and Arabic, this
         * also cleans up certain backwards-compatible sequences, converting them
@@ -4683,6 +4659,7 @@ class Language {
         *
         * @param int|float $seconds
         * @param array $format An optional argument that formats the returned string in different ways:
+        *   If $format['avoid'] === 'avoidhours': don't show hours, just show days
         *   If $format['avoid'] === 'avoidseconds': don't show seconds if $seconds >= 1 hour,
         *   If $format['avoid'] === 'avoidminutes': don't show seconds/minutes if $seconds > 48 hours,
         *   If $format['noabbrevs'] is true: use 'seconds' and friends instead of 'seconds-abbrev'
@@ -4741,12 +4718,19 @@ class Language {
                        $s = $hoursMsg->params( $this->formatNum( $hours ) )->text();
                        $s .= ' ';
                        $s .= $minutesMsg->params( $this->formatNum( $minutes ) )->text();
-                       if ( !in_array( $format['avoid'], [ 'avoidseconds', 'avoidminutes' ] ) ) {
+                       if ( !in_array( $format['avoid'], [ 'avoidseconds', 'avoidminutes', 'avoidhours' ] ) ) {
                                $s .= ' ' . $secondsMsg->params( $this->formatNum( $secondsPart ) )->text();
                        }
                } else {
                        $days = floor( $seconds / 86400 );
-                       if ( $format['avoid'] === 'avoidminutes' ) {
+                       if ( $format['avoid'] === 'avoidhours' ) {
+                               $hours = round( ( $seconds - $days * 86400 ) / 3600 );
+                               if ( $hours == 24 ) {
+                                       $hours = 0;
+                                       $days++;
+                               }
+                               $s = $daysMsg->params( $this->formatNum( $days ) )->text();
+                       } elseif ( $format['avoid'] === 'avoidminutes' ) {
                                $hours = round( ( $seconds - $days * 86400 ) / 3600 );
                                if ( $hours == 24 ) {
                                        $hours = 0;