From: Marius Hoch Date: Mon, 5 Oct 2015 20:42:28 +0000 (+0200) Subject: Fix DatabaseSqlite::__toString X-Git-Tag: 1.31.0-rc.0~9551^2 X-Git-Url: http://git.cyclocoop.org/%7B%7B%20url_for%28%27admin_vote_del%27%2C%20idvote=vote.voteid%29%20%7D%7D?a=commitdiff_plain;h=2c03cd32d04e8877fd2caf56d84dc28c44eb681a;p=lhc%2Fweb%2Fwiklou.git Fix DatabaseSqlite::__toString Failed with "Catchable fatal error: Object of class PDO could not be converted to string in". The message I used was a rather arbitrary choice, but I think it makes sense. Bug: T114709 Change-Id: I0023fae3fa2a0c2b37cb3c34751706fe0d481d19 --- diff --git a/includes/db/DatabaseSqlite.php b/includes/db/DatabaseSqlite.php index e9095970a7..dd65042be5 100644 --- a/includes/db/DatabaseSqlite.php +++ b/includes/db/DatabaseSqlite.php @@ -1032,6 +1032,14 @@ class DatabaseSqlite extends DatabaseBase { return $endArray; } + + /** + * @return string + */ + public function __toString() { + return 'SQLite ' . (string)$this->mConn->getAttribute( PDO::ATTR_SERVER_VERSION ); + } + } // end DatabaseSqlite class /** diff --git a/tests/phpunit/includes/db/DatabaseSqliteTest.php b/tests/phpunit/includes/db/DatabaseSqliteTest.php index 9307b0cda9..0db7af9392 100644 --- a/tests/phpunit/includes/db/DatabaseSqliteTest.php +++ b/tests/phpunit/includes/db/DatabaseSqliteTest.php @@ -482,4 +482,12 @@ class DatabaseSqliteTest extends MediaWikiTestCase { $this->assertTrue( $db->close(), "closing database" ); } + + public function testToString() { + $db = DatabaseSqlite::newStandaloneInstance( ':memory:' ); + + $toString = (string)$db; + + $this->assertContains( 'SQLite ', $toString ); + } }