Dr0ptp4kt has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/178589

Change subject: Ensure zerodot redirects stay on zerodot if OK
......................................................................

Ensure zerodot redirects stay on zerodot if OK

Also, shim in the optimal language code on the
language landing page before the other languages.
The optimal language code may not even be in showLangs,
which is totally cool in the case that the operator
zero-rates all languages. This shimming concept was
okay'd by the director and product tech manager.

Change-Id: I8cc307dd2cceb604b834ee6e23107e8b9c2e951d
---
M includes/PageRendering.php
M includes/ZeroSpecialPage.php
2 files changed, 9 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ZeroBanner 
refs/changes/89/178589/1

diff --git a/includes/PageRendering.php b/includes/PageRendering.php
index 4807389..03f7cf2 100644
--- a/includes/PageRendering.php
+++ b/includes/PageRendering.php
@@ -992,7 +992,8 @@
                        }
                        // if the operator zero-rates mdot only,
                        // but not zerodot, then send the user to mdot
-                       if ( $this->isZeroSubdomain() && !in_array( 'zero', 
$config->sites() ) ) {
+                       $info = $this->getWikiInfo();
+                       if ( $this->isZeroSubdomain() && !in_array( 'zero.' . 
$info[2], $config->sites() ) ) {
                                $flags |= self::FORCE_MDOT;
                        }
                }
@@ -1108,7 +1109,7 @@
         * @param WebRequest $request
         * @return string A language code string for redirects.
         */
-       private function getOptimalLanguageCode( $config, $request ) {
+       public function getOptimalLanguageCode( $config, $request ) {
                global $wgLocalDatabases;
 
                $showLangs = $config->showLangs();
diff --git a/includes/ZeroSpecialPage.php b/includes/ZeroSpecialPage.php
index e712274..98e877d 100644
--- a/includes/ZeroSpecialPage.php
+++ b/includes/ZeroSpecialPage.php
@@ -122,7 +122,12 @@
         */
        private function renderPrimaryLangs( $state, $config, $languageNames, 
$tag = 'h3' ) {
                $primaryLangs = '';
-               foreach ( $config->showLangs() as $languageCode ) {
+               $optimalLangCode = $state->getOptimalLanguageCode( $config, 
$state->getRequest() );
+               $languageCodes = $config->showLangs();
+               $languageCodes = array_merge( array( $optimalLangCode ), 
$languageCodes );
+               $languageCodes = array_unique( $languageCodes );
+
+               foreach ( $languageCodes as $languageCode ) {
                        if ( !array_key_exists( $languageCode, $languageNames ) 
) {
                                continue;
                        }

-- 
To view, visit https://gerrit.wikimedia.org/r/178589
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8cc307dd2cceb604b834ee6e23107e8b9c2e951d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ZeroBanner
Gerrit-Branch: master
Gerrit-Owner: Dr0ptp4kt <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to