Revert "Use display name in category page subheadings if provided"
[lhc/web/wiklou.git] / includes / db / loadbalancer / LBFactoryMulti.php
index f8ddd12..4b9cccc 100644 (file)
 
 /**
  * A multi-wiki, multi-master factory for Wikimedia and similar installations.
- * Ignores the old configuration globals
+ * Ignores the old configuration globals.
+ *
+ * Template override precedence (highest => lowest):
+ *   - templateOverridesByServer
+ *   - masterTemplateOverrides
+ *   - templateOverridesBySection/templateOverridesByCluster
+ *   - externalTemplateOverrides
+ *   - serverTemplate
+ * Overrides only work on top level keys (so nested values will not be merged).
  *
  * Configuration:
  *     sectionsByDB                A map of database names to section names.
  *
  *     sectionLoads                A 2-d map. For each section, gives a map of server names to
  *                                 load ratios. For example:
- *                                 array(
- *                                     'section1' => array(
+ *                                 [
+ *                                     'section1' => [
  *                                         'db1' => 100,
  *                                         'db2' => 100
- *                                     )
- *                                 )
+ *                                     ]
+ *                                 ]
  *
  *     serverTemplate              A server info associative array as documented for $wgDBservers.
  *                                 The host, hostName and load entries will be overridden.
  *
  *     groupLoadsBySection         A 3-d map giving server load ratios for each section and group.
  *                                 For example:
- *                                 array(
- *                                     'section1' => array(
- *                                         'group1' => array(
+ *                                 [
+ *                                     'section1' => [
+ *                                         'group1' => [
  *                                             'db1' => 100,
  *                                             'db2' => 100
- *                                         )
- *                                     )
- *                                 )
+ *                                         ]
+ *                                     ]
+ *                                 ]
  *
  *     groupLoadsByDB              A 3-d map giving server load ratios by DB name.
  *
@@ -63,7 +71,7 @@
  *     templateOverridesByServer   A 2-d map overriding serverTemplate and
  *                                 externalTemplateOverrides on a server-by-server basis. Applies
  *                                 to both core and external storage.
- *
+ *     templateOverridesBySection  A 2-d map overriding the server info by section.
  *     templateOverridesByCluster  A 2-d map overriding the server info by external storage cluster.
  *
  *     masterTemplateOverrides     An override array for all master servers.
@@ -119,6 +127,9 @@ class LBFactoryMulti extends LBFactory {
         */
        private $templateOverridesByServer;
 
+       /** @var array A 2-d map overriding the server info by section */
+       private $templateOverridesBySection;
+
        /** @var array A 2-d map overriding the server info by external storage cluster */
        private $templateOverridesByCluster;
 
@@ -162,7 +173,7 @@ class LBFactoryMulti extends LBFactory {
                $required = [ 'sectionsByDB', 'sectionLoads', 'serverTemplate' ];
                $optional = [ 'groupLoadsBySection', 'groupLoadsByDB', 'hostsByName',
                        'externalLoads', 'externalTemplateOverrides', 'templateOverridesByServer',
-                       'templateOverridesByCluster', 'masterTemplateOverrides',
+                       'templateOverridesByCluster', 'templateOverridesBySection', 'masterTemplateOverrides',
                        'readOnlyBySection', 'loadMonitorClass' ];
 
                foreach ( $required as $key ) {
@@ -222,8 +233,13 @@ class LBFactoryMulti extends LBFactory {
                        $readOnlyReason = $this->readOnlyBySection[$section];
                }
 
+               $template = $this->serverTemplate;
+               if ( isset( $this->templateOverridesBySection[$section] ) ) {
+                       $template = $this->templateOverridesBySection[$section] + $template;
+               }
+
                return $this->newLoadBalancer(
-                       $this->serverTemplate,
+                       $template,
                        $this->sectionLoads[$section],
                        $groupLoads,
                        $readOnlyReason
@@ -301,7 +317,9 @@ class LBFactoryMulti extends LBFactory {
                        'servers' => $this->makeServerArray( $template, $loads, $groupLoads ),
                        'loadMonitor' => $this->loadMonitorClass,
                        'readOnlyReason' => $readOnlyReason,
-                       'trxProfiler' => $this->trxProfiler
+                       'trxProfiler' => $this->trxProfiler,
+                       'srvCache' => $this->srvCache,
+                       'wanCache' => $this->wanCache
                ] );
        }
 
@@ -346,6 +364,8 @@ class LBFactoryMulti extends LBFactory {
                        }
                        $serverInfo['hostName'] = $serverName;
                        $serverInfo['load'] = $load;
+                       $serverInfo += [ 'flags' => DBO_DEFAULT ];
+
                        $servers[] = $serverInfo;
                }