OpenGuides/OpenGuides — pull request #78 by jmdh (2014-09-14 21:31:33+00:00)
Title: Refresh the database before caching a connection handle to it

OpenGuides->new() caches a connection to the SQLite database. When
OpenGuides::Test::refresh_db() is called, it removes the database file
and reconnects to it. If that happens after OpenGuides->new(), the cached
handle becomes read-only as of SQLite 3.8.3. From its changelog:

Add SQLITE_READONLY_DBMOVED error code, returned at the beginning of
a transaction, to indicate that the underlying database file has been
renamed or moved out from under SQLite.

This causes test failures with error messages like

Unhandled error: [DBD::SQLite::st execute failed: attempt to write a readonly database at /usr/share/perl5/Wiki/Toolkit/Store/Database.pm line 567.
] at /usr/share/perl5/Wiki/Toolkit.pm line 849.

Moving the refresh_db() call earlier fixes these failures.