Page MenuHomePhabricator

SqliteMaintenance.php broken after change to use DBConnRef
Closed, ResolvedPublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

  • Have a MediaWiki instance using an SQLite database.
  • Try to perform any operation involving this database with maintenance/SqliteMaintenance.php i.e. --backup-to / --integrity / --vacuum

What happens?:

An error is returned: This maintenance script requires a SQLite database.

This seems to have occurred because change 759634 ("Convert various callers to LoadBalancer::getConnectionRef()") performed this February as part of T193565 did not account for the test $dbw instanceof DatabaseSqlite immediately following the modification. $dbw is now an instance of Wikimedia\Rdbms\DBConnRef, not [Wikimedia\Rdbms\]DatabaseSqlite.

In my case this meant that backups were no longer generated. In fact, they were also not being generated for another reason: I previously used it in a crontab as Sqlite.php, but the file was moved in MW 1.36. Ideally, I would have caught this earlier, but the error was not emailed due to lack of an MTA.

What should have happened instead?:

  • The SQLite database operation should have executed as requested.
    • Code-wise, the test might could be modified to if ( $dbw->getType() != "sqlite" ) { similar to how it was before, and vacuum(), integrityCheck() and backup() should accept a DBConnRef rather than DatabaseSqlite (else they fail).
  • The failure to perform a backup should have been caught by an automated test, as this is part of the critical backup path for SQLite installations.

Software version (skip for WMF-hosted wikis like Wikipedia):

At least REL1_38 and REL1_39 (on current git branches).

Event Timeline

Change 876201 had a related patch set uploaded (by Ladsgroup; author: Amir Sarabadani):

[mediawiki/core@master] sqlite: Fix maint script runs

https://gerrit.wikimedia.org/r/876201

Change 876201 merged by jenkins-bot:

[mediawiki/core@master] SqliteMaintenance.php: Fix fatally broken instanceof check

https://gerrit.wikimedia.org/r/876201

Change 879797 had a related patch set uploaded (by Ladsgroup; author: Amir Sarabadani):

[mediawiki/core@REL1_39] SqliteMaintenance.php: Fix fatally broken instanceof check

https://gerrit.wikimedia.org/r/879797

Change 879797 merged by jenkins-bot:

[mediawiki/core@REL1_39] SqliteMaintenance.php: Fix fatally broken instanceof check

https://gerrit.wikimedia.org/r/879797