Page MenuHomePhabricator

Check if $wgDBname exists
Closed, ResolvedPublic

Description

In LocalSettings.php make $wgDBname='SomeNonExistentDatabaseName';
Now browse http://your.wiki/
You will get this cryptic error:

Fatal error: Call to a member function selectRow() on a non-object in
/var/lib/mediawiki-1.11.0/includes/User.php on line 759

The program probably never expected all to go well except for $wgDBname.

It would be much better to do some error checking and say "$wgDBname
problem" instead of letting get all the way to that point, saying
"Can't get into room 1403", when in fact the problem is really
"Entire State of Louisiana gone."


Version: unspecified
Severity: minor

Details

Reference
bz12307

Event Timeline

bzimport raised the priority of this task from to Lowest.Nov 21 2014, 10:01 PM
bzimport set Reference to bz12307.
bzimport added a subscriber: Unknown Object (MLST).

When setting $wgDBname = 'bug12307'; I got a clean error message:


MediaWikiDev has a problem

Sorry! This site is experiencing technical difficulties.

Try waiting a few minutes and reloading.

(Can't contact the database server: Access denied for user 'xxxxx'@'localhost' to database 'bug12307' (localhost))

That's with current 1.10, 1.11 and trunk branch.

Now I half remember what I was doing. I had changed the name of the
database not in LocalSettings.php, but instead in mysql, without
restarting mysql, or even by the wrong method of
$ mv db1 db2
OK, sorry for thinking this was the same as pointing
$wgDBname to the wrong database.

OK, I found out what is going on and hereby restate the bug:

I discovered a very interesting error, here offline on my simulated Internet.
I used tcpflow to capture traffic.
First remove your mysql server from the DNS, causing

$ http_proxy= w3m -dump http://transgender-taiwan.org/
[transgende]蝶園 has a problem

Sorry! This site is experiencing technical difficulties.

Try waiting a few minutes and reloading.

(Can't contact the database server: Unknown MySQL server host
'mysql.transgender-taiwan.org' (4) (mysql.transgender-taiwan.org))

The above is expected and proper.
Note that the HTTP headers I sent causing the above did NOT any cookies.

Now try again with a browser that sends cookies

 Cookie2: $Version="1"
 Cookie: transgender_wiki_UserID=2; transgender_wiki_UserName=Jidanni

$ http_proxy= lynx -dump http://transgender-taiwan.org/
                            蝶園 has a problem

 Fatal error: Call to a member function selectRow() on a non-object in
 /var/lib/mediawiki-1.11.0/includes/User.php on line 759

So the bug is: Mediawiki sees the cookies, and being hungry, skips its
usual health check, gobbles them down without chewing first, and pukes
out the contents of its guts embarrassingly. So we see we eat cookies
too fast, skipping the stomach, directly to the large intestine.

(Anyways, to restore normal operations I then at this point do

  1. pdnsd-ctl add cname localhost mysql.transgender-taiwan.org)

Seriously, I cant reproduce the problem. I always get the clean error message.