Bugzilla – Attachment 80876 Details for
Bug 21600
t/db_dependent/api/v1/patrons.t is failing with new SQL modes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21600: /patrons should have timestamp/datetime values converted from rfc3339 into valid MySQL values
Bug-21600-patrons-should-have-timestampdatetime-va.patch (text/plain), 2.24 KB, created by
Jonathan Druart
on 2018-10-18 19:37:32 UTC
(
hide
)
Description:
Bug 21600: /patrons should have timestamp/datetime values converted from rfc3339 into valid MySQL values
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2018-10-18 19:37:32 UTC
Size:
2.24 KB
patch
obsolete
>From 5b570c0b8fdf18542f3c509627cf61ba039f6091 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Thu, 18 Oct 2018 15:50:27 -0300 >Subject: [PATCH] Bug 21600: /patrons should have timestamp/datetime values > converted from rfc3339 into valid MySQL values > >Bug 21597 enabled the option so set strict SQL modes in koha-conf.xml to >be able to improve Koha's comformance to current standards on DB >engines. > >This causes lots of parts of Koha to fail because they rely on MySQL >fallbacks that are no longer default behaviours. > >While we can workaround this by setting SQL modes on runtime, the >decision has been that this needs fixing. > >This patch deals with the /patrons API failing to correctly convert >datetimes into valid SQL timestamps. > >To test: >- Run: > $ kshell > k$ prove t/db_dependent/api/v1/patrons.t >=> SUCCESS: Tests pass >- Add <strict_sql_modes>1</strict_sql_modes> on your koha-conf.xml > $ sudo vim /etc/koha/sites/kohadev/koha-conf.xml >- Restart memcached and Plack: > $ restart_all >- Run: > k$ prove t/db_dependent/api/v1/patrons.t >=> FAIL: Tests fail due to updated_on and/or lastseen fields wrong >format (MySQL error) >- Apply this patch >- Run: > k$ prove t/db_dependent/api/v1/patrons.t >=> SUCCESS: Tests pass! It all makes sense! >- Sign off :-D > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > Koha/REST/V1/Patrons.pm | 9 +++++++++ > 1 file changed, 9 insertions(+) > >diff --git a/Koha/REST/V1/Patrons.pm b/Koha/REST/V1/Patrons.pm >index a43d57114b..8d298a0aab 100644 >--- a/Koha/REST/V1/Patrons.pm >+++ b/Koha/REST/V1/Patrons.pm >@@ -19,6 +19,7 @@ use Modern::Perl; > > use Mojo::Base 'Mojolicious::Controller'; > >+use Koha::DateUtils; > use Koha::Patrons; > > use Scalar::Util qw(blessed); >@@ -365,6 +366,14 @@ sub _to_model { > $patron->{gonenoaddress} = ($patron->{gonenoaddress}) ? 1 : 0; > } > >+ if ( exists $patron->{lastseen} ) { >+ $patron->{lastseen} = output_pref({ dt => dt_from_string( $patron->{lastseen} ), dateformat => 'sql' }); >+ } >+ >+ if ( exists $patron->{updated_on} ) { >+ $patron->{updated_on} = output_pref({ dt => dt_from_string( $patron->{updated_on} ), dateformat => 'sql' }); >+ } >+ > return $patron; > } > >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 21600
:
80875
|
80876
|
80877
|
80898
|
80899