X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=maintenance%2Fsqlite.php;h=7e02a4b2bddcd298fbc7c6addd53c061fde598b7;hb=0c9dc0f8f92ab7a9d7432ddcce0605d16d1aaf07;hp=1ca8500356f1047d096aae0a41e2b641b45c84d9;hpb=808002979a816c61a4bf8f9024d010f123358890;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/sqlite.php b/maintenance/sqlite.php index 1ca8500356..7e02a4b2bd 100644 --- a/maintenance/sqlite.php +++ b/maintenance/sqlite.php @@ -21,7 +21,7 @@ * @ingroup Maintenance */ -require_once( __DIR__ . '/Maintenance.php' ); +require_once __DIR__ . '/Maintenance.php'; /** * Maintenance script that performs some operations specific to SQLite database backend. @@ -32,7 +32,10 @@ class SqliteMaintenance extends Maintenance { 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 ); @@ -52,6 +55,7 @@ class SqliteMaintenance extends Maintenance { // Should work even if we use a non-SQLite database if ( $this->hasOption( 'check-syntax' ) ) { $this->checkSyntax(); + return; } @@ -59,6 +63,7 @@ class SqliteMaintenance extends Maintenance { if ( $this->db->getType() != 'sqlite' ) { $this->error( "This maintenance script requires a SQLite database.\n" ); + return; } @@ -76,7 +81,7 @@ class SqliteMaintenance extends Maintenance { } 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 ); } @@ -84,7 +89,7 @@ class SqliteMaintenance extends Maintenance { $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 { @@ -98,6 +103,7 @@ class SqliteMaintenance extends Maintenance { if ( !$res || $res->numRows() == 0 ) { $this->error( "Error: integrity check query returned nothing.\n" ); + return; } @@ -109,7 +115,7 @@ class SqliteMaintenance extends Maintenance { 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 ) ) {