Bug 9066: VirtualShelves db access not Plack+MariaDB compatible
authorJared Camins-Esakov <jcamins@cpbibliography.com>
Tue, 13 Nov 2012 14:25:42 +0000 (09:25 -0500)
committerJared Camins-Esakov <jcamins@cpbibliography.com>
Tue, 20 Nov 2012 11:49:07 +0000 (06:49 -0500)
commit49c7d69561dcfccf36194a32a25962fa33df8c95
tree4d7c751d5900d0baab09dd14d02707c56a7acbd0
parenta7ff2a2e4d6deaf63922dd5568f466e878923b67
Bug 9066: VirtualShelves db access not Plack+MariaDB compatible

The $dbh database handle in C4::VirtualShelves was declared at the
module level, which means under Plack it is initialized only once, when
the server first starts. With the default MySQL configuration this is
not a problem, since the MySQL connection does not time out, but the
MariaDB default configuration does time out, resulting in every page
that calls any sub in C4::VirtualShelves failing after a certain period.
This patch eliminates the module-level $dbh variable and replaces it
with $dbh handles in each subroutine that requires it.

To test:
Confirm that Virtual Shelves functionality still works as expected. The
problem is not reproducible when using Apache or Plack+MySQL, but if
everything works after the patch has been applied, the changes are safe.

Signed-off-by: Mason James <mtj@kohaaloha.com>
Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
Signed-off-by: Jared Camins-Esakov <jcamins@cpbibliography.com>
C4/VirtualShelves.pm