Merge "Move MaxUserDBWriteDuration logic to LBFactory"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Fri, 29 Jan 2016 19:05:16 +0000 (19:05 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 29 Jan 2016 19:05:16 +0000 (19:05 +0000)
includes/Sanitizer.php
includes/Title.php
includes/api/ApiMain.php

index e2564cd..60c9498 100644 (file)
@@ -1241,7 +1241,7 @@ class Sanitizer {
 
        /**
         * Return an associative array of attribute names and values from
-        * a partial tag string. Attribute names are forces to lowercase,
+        * a partial tag string. Attribute names are forced to lowercase,
         * character references are decoded to UTF-8 text.
         *
         * @param string $text
index e549037..882b7dd 100644 (file)
@@ -246,7 +246,7 @@ class Title {
         * Create a new Title from text, such as what one would find in a link. De-
         * codes any HTML entities in the text.
         *
-        * @param string|null $text The link text; spaces, prefixes, and an
+        * @param string|int|null $text The link text; spaces, prefixes, and an
         *   initial ':' indicating the main namespace are accepted.
         * @param int $defaultNamespace The namespace to use if none is specified
         *   by a prefix.  If you want to force a specific namespace even if
@@ -259,7 +259,8 @@ class Title {
                if ( is_object( $text ) ) {
                        throw new InvalidArgumentException( '$text must be a string.' );
                }
-               if ( $text !== null && !is_string( $text ) ) {
+               // DWIM: Integers can be passed in here when page titles are used as array keys.
+               if ( $text !== null && !is_string( $text ) && !is_int( $text ) ) {
                        wfDebugLog( 'T76305', wfGetAllCallers( 5 ) );
                        return null;
                }
@@ -268,7 +269,7 @@ class Title {
                }
 
                try {
-                       return Title::newFromTextThrow( $text, $defaultNamespace );
+                       return Title::newFromTextThrow( strval( $text ), $defaultNamespace );
                } catch ( MalformedTitleException $ex ) {
                        return null;
                }
index 6ddc28a..458fd18 100644 (file)
@@ -1231,7 +1231,8 @@ class ApiMain extends ApiBase {
         * @param array $params An array with the request parameters
         */
        protected function setupExternalResponse( $module, $params ) {
-               if ( !$this->getRequest()->wasPosted() && $module->mustBePosted() ) {
+               $request = $this->getRequest();
+               if ( !$request->wasPosted() && $module->mustBePosted() ) {
                        // Module requires POST. GET request might still be allowed
                        // if $wgDebugApi is true, otherwise fail.
                        $this->dieUsageMsgOrDebug( array( 'mustbeposted', $this->mAction ) );
@@ -1243,6 +1244,15 @@ class ApiMain extends ApiBase {
                        // Create an appropriate printer
                        $this->mPrinter = $this->createPrinterByName( $params['format'] );
                }
+
+               if ( $request->getProtocol() === 'http' && (
+                       $request->getSession()->shouldForceHTTPS() ||
+                       ( $this->getUser()->isLoggedIn() &&
+                               $this->getUser()->requiresHTTPS() )
+               ) ) {
+                       $this->logFeatureUsage( 'https-expected' );
+                       $this->setWarning( 'HTTP used when HTTPS was expected' );
+               }
        }
 
        /**