View | Details | Raw Unified | Return to bug 20665
Collapse All | Expand All

(-)a/Koha/OAI/Server/Repository.pm (+13 lines)
Lines 115-120 sub new { Link Here
115
115
116
    # OAI-PMH handles dates in UTC, so do that on the database level to avoid need for
116
    # OAI-PMH handles dates in UTC, so do that on the database level to avoid need for
117
    # any conversions
117
    # any conversions
118
    my $sth = C4::Context->dbh->prepare('SELECT @@session.time_zone');
119
    $sth->execute();
120
    my ( $orig_tz ) = $sth->fetchrow();
121
    $self->{ mysql_orig_tz } = $orig_tz;
118
    C4::Context->dbh->prepare("SET time_zone='+00:00'")->execute();
122
    C4::Context->dbh->prepare("SET time_zone='+00:00'")->execute();
119
123
120
    # Check for grammatical errors in the request
124
    # Check for grammatical errors in the request
Lines 152-157 sub new { Link Here
152
}
156
}
153
157
154
158
159
sub DESTROY {
160
    my ( $self ) = @_;
161
162
    # Reset time zone to the original value
163
    C4::Context->dbh->prepare("SET time_zone='" . $self->{ mysql_orig_tz } . "'")->execute()
164
        if $self->{ mysql_orig_tz };
165
}
166
167
155
sub get_biblio_marcxml {
168
sub get_biblio_marcxml {
156
    my ($self, $biblionumber, $format) = @_;
169
    my ($self, $biblionumber, $format) = @_;
157
    my $with_items = 0;
170
    my $with_items = 0;
(-)a/t/db_dependent/OAI/Server.t (-2 / +23 lines)
Lines 20-26 Link Here
20
use Modern::Perl;
20
use Modern::Perl;
21
use Test::MockTime qw/set_fixed_time restore_time/;
21
use Test::MockTime qw/set_fixed_time restore_time/;
22
22
23
use Test::More tests => 29;
23
use Test::More tests => 30;
24
use DateTime;
24
use DateTime;
25
use Test::MockModule;
25
use Test::MockModule;
26
use Test::Warn;
26
use Test::Warn;
Lines 376-379 subtest 'Bug 19725: OAI-PMH ListRecords and ListIdentifiers should use biblio_me Link Here
376
    });
376
    });
377
};
377
};
378
378
379
subtest 'Bug 20665: OAI-PMH Provider should reset the MySQL connection time zone' => sub {
380
    plan tests => 2;
381
382
    # Set time zone to SYSTEM so that it can be checked later
383
    $dbh->do("SET time_zone='SYSTEM'");
384
385
386
    test_query('ListIdentifiers without metadataPrefix', {verb => 'ListIdentifiers'}, {
387
        error => {
388
            code => 'badArgument',
389
            content => "Required argument 'metadataPrefix' was undefined",
390
        },
391
    });
392
393
    my $sth = C4::Context->dbh->prepare('SELECT @@session.time_zone');
394
    $sth->execute();
395
    my ( $tz ) = $sth->fetchrow();
396
397
    ok ( $tz eq 'SYSTEM', 'MySQL connection time zone is SYSTEM' );
398
};
399
400
379
$schema->storage->txn_rollback;
401
$schema->storage->txn_rollback;
380
- 

Return to bug 20665