Page MenuHomePhabricator

Fatal error when $wgDebugDBTransactions is enabled with SQLite: Object of class PDO could not be converted to string in /includes/db/Database.php:3850
Closed, ResolvedPublic

Description

If SQLite is used, setting $wgDebugDBTransactions = true in LocalSettings.php causes "Catchable fatal error: Object of class PDO could not be converted to string in <path to MediaWiki installation>/includes/db/Database.php on line 3850"


Version: 1.22.0
Severity: normal

Details

Reference
bz54120

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 1:46 AM
bzimport set Reference to bz54120.
bzimport added a subscriber: Unknown Object (MLST).

Thanks for taking the time to report this!

Setting https://www.mediawiki.org/wiki/Manual:$wgShowExceptionDetails and pasting more information here is welcome.

That doesn't yield any additional information.

I can't reproduce this bug on an up-to-date MediaWiki installation using SQLite.

I added $wgDebugDBTransactions = true in the configuration.
What do you do to get the error? You have to go to a specific page or do a specific action?

Jackmcbarn: What do you do to get the error? You have to go to a specific page or do a specific action?

Viewing any page causes the error for me. This still happens with latest git, except the error is on line 4096 now (which is still "return (string)$this->mConn;"). This happens with PHP 5.4.22 (with XAMPP 1.8.2) in case that helps.

allex wrote:

I've faced the same issue. The problem starts in debug message:

includes/objectcache/SqlBagOStuff.php:147:

if ( $wgDebugDBTransactions ) {

wfDebug( sprintf( "Connection %s will be used for SqlBagOStuff\n", $db ) );

}

that calls __toString method for $db:

includes/db/Database.php:

public function __toString() {

return (string)$this->mConn;

}

I use MySQL database and in my case $this->mConn is an object of type mysqli that can't be converted to String.

To print type of connection I've changed return expression to $this->getType() but not sure what behaviour was intended.

My config:
MediaWiki 1.22.0 (80d6477)

Krinkle claimed this task.
Krinkle moved this task from Untriaged to Rdbms library on the MediaWiki-libs-Rdbms board.
Krinkle edited projects, added Performance-Team; removed SQLite.
Krinkle subscribed.

This is now working as expected. For example:

[SQLBagOStuff] Connection 28 will be used for SqlBagOStuff

For mysqli, this was fixed in MediaWiki 1.23 (c393aa71e3e8b55e5459bceb16eb71a48a26c877).

For sqlite, this was fixed in MediaWiki 1.27 (2c03cd32d04e8877fd2caf56d84dc28c44eb681a; T114709).