* @return bool
*/
public static function isPresent() {
- wfSuppressWarnings();
- $compiled = wfDl( 'pdo_sqlite' );
- wfRestoreWarnings();
- return $compiled;
+ return extension_loaded( 'pdo_sqlite' );
}
/**
* Checks given files for correctness of SQL syntax. MySQL DDL will be converted to
* SQLite-compatible during processing.
* Will throw exceptions on SQL errors
- * @param $files
+ * @param array|string $files
* @throws MWException
- * @return mixed true if no error or error string in case of errors
+ * @return string|bool true if no error or error string in case of errors
*/
public static function checkSqlSyntax( $files ) {
if ( !Sqlite::isPresent() ) {
$tables = $db->query( "SELECT name FROM sqlite_master WHERE type='table'", __METHOD__ );
foreach ( $tables as $table ) {
- if ( strpos( $table->name, 'sqlite_' ) === 0 ) continue;
+ if ( strpos( $table->name, 'sqlite_' ) === 0 ) {
+ continue;
+ }
$columns = $db->query( "PRAGMA table_info({$table->name})", __METHOD__ );
foreach ( $columns as $col ) {
if ( !isset( $allowedTypes[strtolower( $col->type )] ) ) {
$db->close();
+
return "Table {$table->name} has column {$col->name} with non-native type '{$col->type}'";
}
}
return $e->getMessage();
}
$db->close();
+
return true;
}
- };
+}