Page MenuHomePhabricator

Title::getArticleID (LinkCache::addLinkObj) should not fail with "Service disabled: DBLoadBalancer"
Closed, DeclinedPublic

Description

Whatever the reasons are for "Service disabled: DBLoadBalancer", Title::getArticleID (and hereby LinkCache::addLinkObj) should simply not fail with "Service disabled: DBLoadBalancer" and just return 0 for an unavailable ID or DB connection.

[4eb69185a048af297309d534] /w/mw-config/index.php MediaWiki\Services\ServiceDisabledException from line 340 of /var/www/w/includes/services/ServiceContainer.php: Service disabled: DBLoadBalancer
#0 /var/www/w/includes/MediaWikiServices.php(509): MediaWiki\Services\ServiceContainer->getService(string)
#1 /var/www/w/includes/GlobalFunctions.php(3089): MediaWiki\MediaWikiServices->getDBLoadBalancer()
#2 /var/www/w/includes/GlobalFunctions.php(3075): wfGetLB(boolean)
#3 /var/www/w/includes/cache/LinkCache.php(267): wfGetDB(integer)
#4 /var/www/w/includes/Title.php(3222): LinkCache->addLinkObj(Title)
#5 /var/www/w/includes/Title.php(4295): Title->getArticleID(integer)
#6 /var/www/w/includes/Title.php(2572): Title->exists()
#7 /var/www/w/includes/Title.php(2687): Title->getRestrictionTypes()

Event Timeline

Under what circumstances are you getting this? This error seems to indicate that your code is not allowed to access the database at the time, for whatever reason (e.g. for code running in the MediaWiki installer, where the database does not exist yet).

As far as I remember this happened during MediaWiki installer and as I said before it shouldn't really matter, LinkCache::addLinkObj (Article::getArticleID) expects an active connection and it should just not fail and instead return 0 or null.

That doesn't really make sense for me. The database not being there is a pretty exceptional case. It deserves to throw exceptions. If your code is doing Title->getRestrictionTypes() while the wiki doesn't even have the concept of a Title yet, it's a bug in your code.

DannyS712 subscribed.

Boldly declining per discussion above - exception should be thrown