public function __construct() {
parent::__construct();
$this->mDescription = "Performs some operations specific to SQLite database backend";
- $this->addOption( 'vacuum', 'Clean up database by removing deleted pages. Decreases database file size' );
+ $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 );
// Should work even if we use a non-SQLite database
if ( $this->hasOption( 'check-syntax' ) ) {
$this->checkSyntax();
+
return;
}
if ( $this->db->getType() != 'sqlite' ) {
$this->error( "This maintenance script requires a SQLite database.\n" );
+
return;
}
}
private function vacuum() {
- $prevSize = filesize( $this->db->mDatabaseFile );
+ $prevSize = filesize( $this->db->getDbFilePath() );
if ( $prevSize == 0 ) {
$this->error( "Can't vacuum an empty database.\n", true );
}
$this->output( 'VACUUM: ' );
if ( $this->db->query( 'VACUUM' ) ) {
clearstatcache();
- $newSize = filesize( $this->db->mDatabaseFile );
+ $newSize = filesize( $this->db->getDbFilePath() );
$this->output( sprintf( "Database size was %d, now %d (%.1f%% reduction).\n",
$prevSize, $newSize, ( $prevSize - $newSize ) * 100.0 / $prevSize ) );
} else {
if ( !$res || $res->numRows() == 0 ) {
$this->error( "Error: integrity check query returned nothing.\n" );
+
return;
}
private function backup( $fileName ) {
$this->output( "Backing up database:\n Locking..." );
$this->db->query( 'BEGIN IMMEDIATE TRANSACTION', __METHOD__ );
- $ourFile = $this->db->mDatabaseFile;
+ $ourFile = $this->db->getDbFilePath();
$this->output( " Copying database file $ourFile to $fileName... " );
wfSuppressWarnings( false );
if ( !copy( $ourFile, $fileName ) ) {