Merge "Fix form submission on Special:RandomInCategory"
[lhc/web/wiklou.git] / includes / User.php
index fedc6a9..25b35b3 100644 (file)
@@ -1240,7 +1240,10 @@ class User {
 
                $defOpt = $wgDefaultUserOptions;
                // Default language setting
-               $defOpt['language'] = $defOpt['variant'] = $wgContLang->getCode();
+               $defOpt['language'] = $wgContLang->getCode();
+               foreach ( LanguageConverter::$languagesWithVariants as $langCode ) {
+                       $defOpt[$langCode == $wgContLang->getCode() ? 'variant' : "variant-$langCode"] = $langCode;
+               }
                foreach ( SearchEngine::searchableNamespaces() as $nsnum => $nsname ) {
                        $defOpt['searchNs' . $nsnum] = !empty( $wgNamespacesToBeSearchedDefault[$nsnum] );
                }
@@ -2596,6 +2599,26 @@ class User {
                return $this->mDatePreference;
        }
 
+       /**
+        * Determine based on the wiki configuration and the user's options,
+        * whether this user must be over HTTPS no matter what.
+        *
+        * @return bool
+        */
+       public function requiresHTTPS() {
+               global $wgSecureLogin;
+               if ( !$wgSecureLogin ) {
+                       return false;
+               } else {
+                       $https = $this->getBoolOption( 'prefershttps' );
+                       wfRunHooks( 'UserRequiresHTTPS', array( $this, &$https ) );
+                       if ( $https ) {
+                               $https = wfCanIPUseHTTPS( $this->getRequest()->getIP() );
+                       }
+                       return $https;
+               }
+       }
+
        /**
         * Get the user preferred stub threshold
         *
@@ -3183,7 +3206,7 @@ class User {
                 * will cause the site to redirect the user to HTTPS, if they access
                 * it over HTTP. Bug 29898.
                 */
-               if ( $request->getCheck( 'wpStickHTTPS' ) ) {
+               if ( $request->getCheck( 'wpStickHTTPS' ) || $this->requiresHTTPS() ) {
                        $this->setCookie( 'forceHTTPS', 'true', time() + 2592000, false ); //30 days
                }
        }
@@ -3736,6 +3759,8 @@ class User {
                } elseif ( $type === true ) {
                        $message = 'confirmemail_body_changed';
                } else {
+                       // Give grep a chance to find the usages:
+                       // confirmemail_body_changed, confirmemail_body_set
                        $message = 'confirmemail_body_' . $type;
                }