rdbms: make DOMAIN_ANY ignore bogus MySQL DB names in config
authorAaron Schulz <aschulz@wikimedia.org>
Fri, 9 Feb 2018 02:48:38 +0000 (18:48 -0800)
committerAaron Schulz <aschulz@wikimedia.org>
Fri, 9 Feb 2018 06:43:24 +0000 (06:43 +0000)
commite59b0556f4531b87d80113fcefc845ed9d6e3500
tree012e6f313b10327f696f8a58902d34c1c2b2f101
parent384455a5cf526e01452ec12382d9590708a1d52a
rdbms: make DOMAIN_ANY ignore bogus MySQL DB names in config

This regressed in 14ee3f2, trying to select the server config
"dbname" value as the database on connect. If that config is
bogus, then the connection attempt would fail. Instead, always
pass null to the driver's connection function if the DB domain
doesn't matter.

This affected WMF sites during lag checks, on account of the
"serverTemplate" value in $wgLBFactoryConf always using the local
wiki domain (whether the cluster had such a database or not).

Use strlen() as mysqli sees null and "" as the same for $dbname.

Bug: T186764
Change-Id: I6699d17c0125a08415046211fee7906bbaf2c366
includes/libs/rdbms/database/DatabaseMysqlBase.php
includes/libs/rdbms/loadbalancer/LoadBalancer.php
tests/phpunit/includes/db/LBFactoryTest.php