/** Open an SQLite database and return a resource handle to it
* NOTE: only $dbName is used, the other parameters are irrelevant for SQLite databases
*
- * @param $server
- * @param $user
- * @param $pass
- * @param $dbName
+ * @param string $server
+ * @param string $user
+ * @param string $pass
+ * @param string $dbName
*
+ * @throws DBConnectionError
* @return PDO
*/
function open( $server, $user, $pass, $dbName ) {
*
* @param $fileName string
*
+ * @throws DBConnectionError
* @return PDO|bool SQL connection or false if failed
*/
function openFile( $fileName ) {
* @return string User-friendly database information
*/
public function getServerInfo() {
- return wfMsg( self::getFulltextSearchModule() ? 'sqlite-has-fts' : 'sqlite-no-fts', $this->getServerVersion() );
+ return wfMessage( self::getFulltextSearchModule() ? 'sqlite-has-fts' : 'sqlite-no-fts', $this->getServerVersion() )->text();
}
/**
return false;
}
- function begin( $fname = '' ) {
+ protected function doBegin( $fname = '' ) {
if ( $this->mTrxLevel == 1 ) {
$this->commit( __METHOD__ );
}
$this->mTrxLevel = 1;
}
- function commit( $fname = '' ) {
+ protected function doCommit( $fname = '' ) {
if ( $this->mTrxLevel == 0 ) {
return;
}
$this->mTrxLevel = 0;
}
- function rollback( $fname = '' ) {
+ protected function doRollback( $fname = '' ) {
if ( $this->mTrxLevel == 0 ) {
return;
}
function addQuotes( $s ) {
if ( $s instanceof Blob ) {
return "x'" . bin2hex( $s->fetch() ) . "'";
+ } else if ( strpos( $s, "\0" ) !== false ) {
+ // SQLite doesn't support \0 in strings, so use the hex representation as a workaround.
+ // This is a known limitation of SQLite's mprintf function which PDO should work around,
+ // but doesn't. I have reported this to php.net as bug #63419:
+ // https://bugs.php.net/bug.php?id=63419
+ // There was already a similar report for SQLite3::escapeString, bug #62361:
+ // https://bugs.php.net/bug.php?id=62361
+ return "x'" . bin2hex( $s ) . "'";
} else {
return $this->mConn->quote( $s );
}