jenkins-bot has submitted this change and it was merged. Change subject: Language: Fix 'pretty' fallback in getDateFormatString() ......................................................................
Language: Fix 'pretty' fallback in getDateFormatString() * If using 'default', still fallback to 'date' if 'pretty' is unavailable. * Fix instance caching of 'default', which never worked since $pref would be changed inside the !isset() block. Bug: T110945 Change-Id: Ic53b279f8741371fa1cb642c53e6d487cb1c6b81 --- M languages/Language.php 1 file changed, 17 insertions(+), 14 deletions(-) Approvals: Mattflaschen: Looks good to me, approved jenkins-bot: Verified diff --git a/languages/Language.php b/languages/Language.php index 370e2ed..b47442d 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -2270,30 +2270,33 @@ /** * Get a format string for a given type and preference - * @param string $type May be date, time or both - * @param string $pref The format name as it appears in Messages*.php + * @param string $type May be 'date', 'time', 'both', or 'pretty'. + * @param string $pref The format name as it appears in Messages*.php under + * $datePreferences. * * @since 1.22 New type 'pretty' that provides a more readable timestamp format * * @return string */ function getDateFormatString( $type, $pref ) { + $wasDefault = false; + if ( $pref == 'default' ) { + $wasDefault = true; + $pref = $this->getDefaultDateFormat(); + } + if ( !isset( $this->dateFormatStrings[$type][$pref] ) ) { - if ( $pref == 'default' ) { + $df = self::$dataCache->getSubitem( $this->mCode, 'dateFormats', "$pref $type" ); + + if ( $type === 'pretty' && $df === null ) { + $df = $this->getDateFormatString( 'date', $pref ); + } + + if ( !$wasDefault && $df === null ) { $pref = $this->getDefaultDateFormat(); $df = self::$dataCache->getSubitem( $this->mCode, 'dateFormats', "$pref $type" ); - } else { - $df = self::$dataCache->getSubitem( $this->mCode, 'dateFormats', "$pref $type" ); - - if ( $type === 'pretty' && $df === null ) { - $df = $this->getDateFormatString( 'date', $pref ); - } - - if ( $df === null ) { - $pref = $this->getDefaultDateFormat(); - $df = self::$dataCache->getSubitem( $this->mCode, 'dateFormats', "$pref $type" ); - } } + $this->dateFormatStrings[$type][$pref] = $df; } return $this->dateFormatStrings[$type][$pref]; -- To view, visit https://gerrit.wikimedia.org/r/235268 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ic53b279f8741371fa1cb642c53e6d487cb1c6b81 Gerrit-PatchSet: 2 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Legoktm <legoktm.wikipe...@gmail.com> Gerrit-Reviewer: Catrope <roan.katt...@gmail.com> Gerrit-Reviewer: Legoktm <legoktm.wikipe...@gmail.com> Gerrit-Reviewer: Mattflaschen <mflasc...@wikimedia.org> Gerrit-Reviewer: Nikerabbit <niklas.laxst...@gmail.com> Gerrit-Reviewer: Parent5446 <tylerro...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits