Merge "Sort MWNamespace::getValidNamespaces list numerically"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Tue, 6 Oct 2015 16:20:57 +0000 (16:20 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Tue, 6 Oct 2015 16:20:57 +0000 (16:20 +0000)
includes/db/Database.php
includes/libs/MultiHttpClient.php
includes/search/SearchResult.php
phpcs.xml

index 86ea0c4..f044002 100644 (file)
@@ -4307,6 +4307,9 @@ abstract class DatabaseBase implements IDatabase {
        }
 }
 
+/**
+ * @since 1.27
+ */
 abstract class Database extends DatabaseBase {
        // B/C until nothing type hints for DatabaseBase
        // @TODO: finish renaming DatabaseBase => Database
index 6af3ed5..49966cf 100644 (file)
@@ -55,6 +55,8 @@ class MultiHttpClient {
        protected $maxConnsPerHost = 50;
        /** @var string|null proxy */
        protected $proxy;
+       /** @var string */
+       protected $userAgent = 'MW-MultiHttpClient';
 
        /**
         * @param array $options
@@ -63,6 +65,7 @@ class MultiHttpClient {
         *   - proxy           : HTTP proxy to use
         *   - usePipelining   : whether to use HTTP pipelining if possible (for all hosts)
         *   - maxConnsPerHost : maximum number of concurrent connections (per host)
+        *   - userAgent       : The User-Agent header value to send
         * @throws Exception
         */
        public function __construct( array $options ) {
@@ -73,7 +76,7 @@ class MultiHttpClient {
                        }
                }
                static $opts = array(
-                       'connTimeout', 'reqTimeout', 'usePipelining', 'maxConnsPerHost', 'proxy'
+                       'connTimeout', 'reqTimeout', 'usePipelining', 'maxConnsPerHost', 'proxy', 'userAgent'
                );
                foreach ( $opts as $key ) {
                        if ( isset( $options[$key] ) ) {
@@ -343,6 +346,10 @@ class MultiHttpClient {
                        $req['headers']['content-length'] = 0;
                }
 
+               if ( !isset( $req['headers']['user-agent'] ) ) {
+                       $req['headers']['user-agent'] = $this->userAgent;
+               }
+
                $headers = array();
                foreach ( $req['headers'] as $name => $value ) {
                        if ( strpos( $name, ': ' ) ) {
index 7bfcd45..765cfc1 100644 (file)
@@ -179,7 +179,8 @@ class SearchResult {
        }
 
        /**
-        * @return Title|null Title object (pagename+fragment) for the section, null if none or not supported
+        * @return Title|null Title object (pagename+fragment) for the section,
+        *  null if none or not supported
         */
        function getSectionTitle() {
                return null;
index bebed28..a4fb301 100644 (file)
--- a/phpcs.xml
+++ b/phpcs.xml
@@ -2,7 +2,6 @@
 <ruleset name="MediaWiki">
        <rule ref="vendor/mediawiki/mediawiki-codesniffer/MediaWiki">
                <!-- Disable failing rules -->
-               <exclude name="Generic.Files.LineLength"/>
                <exclude name="PSR2.Methods.MethodDeclaration.Underscore"/>
                <exclude name="Squiz.Classes.ValidClassName.NotCamelCaps"/>
                <exclude name="MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.EmptyComment"/>