Bug 20089 - Does Koha::Database->schema always return a connected object?
Summary: Does Koha::Database->schema always return a connected object?
Status: NEW
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Bugs List
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-01-25 13:33 UTC by Marcel de Rooy
Modified: 2019-08-14 14:34 UTC (History)
0 users

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marcel de Rooy 2018-01-25 13:33:47 UTC
My log says no:
DBD::mysql::st execute failed: MySQL server has gone away [for Statement "SELECT `me`.`variable`, `me`.`value`, `me`.`options`, `me`.`explanation`, `me`.`type` FROM `systempreferences` `me` WHERE ( `me`.`variable` = ? )" with ParamValues: 0='opacgroupresults'] at /usr/share/perl5/DBIx/Class/Storage/DBI.pm line 1832.

I see them quite often, always for preferences.

Note that we do not test the cached $database->{schema} in sub schema.
If we do, we will however add some time. ( 0.0043 instead of 0.0003 )

What do you think?
Comment 1 Marcel de Rooy 2019-08-14 14:34:01 UTC
For the record:

-        return $database->{schema} if defined $database->{schema};
+        my $schema = $database->{schema};
+        if( $schema && $schema->storage->connected ) {
+            return $schema;