diff options
author | Max Semenik <maxsem@users.mediawiki.org> | 2010-08-12 16:06:47 +0000 |
---|---|---|
committer | Max Semenik <maxsem@users.mediawiki.org> | 2010-08-12 16:06:47 +0000 |
commit | a2449fea8638e0fab49521f4d15a2f9d497bc55a (patch) | |
tree | 334ff4dab3dbde2ddbe8e739b135101aa10c21f7 /maintenance/sqlite.php | |
parent | 5a8d16a188a4eaf65a35cf985e6b42c7fb4ee6d1 (diff) | |
download | mediawikicore-a2449fea8638e0fab49521f4d15a2f9d497bc55a.tar.gz mediawikicore-a2449fea8638e0fab49521f4d15a2f9d497bc55a.zip |
maintenance/sqlite.php: added the ability to check .sql files for SQLite compatibility
Notes
Notes:
http://mediawiki.org/wiki/Special:Code/MediaWiki/70967
Diffstat (limited to 'maintenance/sqlite.php')
-rw-r--r-- | maintenance/sqlite.php | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/maintenance/sqlite.php b/maintenance/sqlite.php index ebaa69d99c63..ef70d3222fe1 100644 --- a/maintenance/sqlite.php +++ b/maintenance/sqlite.php @@ -29,6 +29,7 @@ class SqliteMaintenance extends Maintenance { $this->addOption( 'vacuum', 'Clean up database by removing deleted pages. Decreases database file size' ); $this->addOption( 'integrity', 'Check database for integrity' ); $this->addOption( 'backup-to', 'Backup database to the given file', false, true ); + $this->addOption( 'check-syntax', 'Check SQL file(s) for syntax errors', false, true ); } /** @@ -42,6 +43,11 @@ class SqliteMaintenance extends Maintenance { public function execute() { global $wgDBtype; + // Should work even if we use a non-SQLite database + if ( $this->hasOption( 'check-syntax' ) ) { + $this->checkSyntax(); + } + if ( $wgDBtype != 'sqlite' ) { $this->error( "This maintenance script requires a SQLite database.\n" ); return; @@ -107,6 +113,20 @@ class SqliteMaintenance extends Maintenance { $this->output( " Releasing lock...\n" ); $this->db->query( 'COMMIT TRANSACTION', __METHOD__ ); } + + private function checkSyntax() { + if ( !Sqlite::IsPresent() ) { + $this->error( "Error: SQLite support not found\n" ); + } + $files = array( $this->getOption( 'check-syntax' ) ); + $files += $this->mArgs; + $result = Sqlite::checkSqlSyntax( $files ); + if ( $result === true ) { + $this->output( "SQL syntax check: no errors detected.\n" ); + } else { + $this->error( "Error: $result\n" ); + } + } } $maintClass = "SqliteMaintenance"; |