Page MenuHomePhabricator

Patching DatabaseMysql.php's close to meet specification
Closed, ResolvedPublic

Description

Resetting mConn upon closing MySQL database connection

The documentation of the close function in includesDatabase.php:730--736 says that 'close' should return true, when called for an already closed connection.

Calling close on an already closed DatabaseMysql object fails, by something like:
-----8<------
PHP Warning: mysql_close(): 4 is not a valid MySQL-Link resource in /home/christian/sources/Wikimedia/shreddingPHPUnit/dummy.php on line 13

Warning: mysql_close(): 4 is not a valid MySQL-Link resource in /home/christian/sources/Wikimedia/shreddingPHPUnit/dummy.php on line 13
-----8<------

The problem seems to be that mConn is not cleared upon closing DatabaseMysql.

The attached patch resolves this issue.


Version: 1.20.x
Severity: normal

Attached:

Details

Reference
bz34762

Event Timeline

bzimport raised the priority of this task from to Low.Nov 22 2014, 12:18 AM
bzimport set Reference to bz34762.
bzimport added a subscriber: Unknown Object (MLST).

Why would you call ->close() twice anyway? It seems like that is the bug that should be fixed.

Fixed in r112565 for all DatabaseBase subclasses (except Sqlite, which wasn't affected).