From 047c31b4246bb5eb0f20238355190f9535dc4721 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 6 Sep 2016 10:40:46 +0100 Subject: [PATCH] Bug 14637: Fix add patron category under MySQL 5.7 If no dateofbirthrequired or upperagelimit is set on the interface, the ->store method will receive an empty string defined for these values. For INT field, we must explicitely set these empty value to undef instead to avoid MySQL 5.7 (and strict mode) to raise: DBD::mysql::st execute failed: Incorrect integer value: ' for column 'dateofbirthrequired'' Test plan: Using MySQL 5.7 (and/or sql_mode=STRICT_TRANS_TABLES) Create a patron category without specifying upperagelimit or dateofbirthrequired Signed-off-by: Josef Moravec Signed-off-by: Kyle M Hall Signed-off-by: Mason James --- Koha/Patron/Category.pm | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/Koha/Patron/Category.pm b/Koha/Patron/Category.pm index 7b17c8c084..31745abfd2 100644 --- a/Koha/Patron/Category.pm +++ b/Koha/Patron/Category.pm @@ -35,6 +35,41 @@ Koha::Patron;;Category - Koha Patron;;Category Object class =cut +=head3 effective_BlockExpiredPatronOpacActions + +my $BlockExpiredPatronOpacActions = $category->effective_BlockExpiredPatronOpacActions + +Return the effective BlockExpiredPatronOpacActions value. + +=cut + +sub effective_BlockExpiredPatronOpacActions { + my( $self) = @_; + return C4::Context->preference('BlockExpiredPatronOpacActions') if $self->BlockExpiredPatronOpacActions == -1; + return $self->BlockExpiredPatronOpacActions +} + +=head3 store + +=cut + +sub store { + my ($self) = @_; + + $self->dateofbirthrequired(undef) + if not defined $self->dateofbirthrequired + or $self->dateofbirthrequired eq ''; + + $self->upperagelimit(undef) + if not defined $self->upperagelimit + or $self->upperagelimit eq ''; + + $self->checkprevcheckout('inherit') + unless defined $self->checkprevcheckout; + + return $self->SUPER::store; +} + =head3 default_messaging my $messaging = $category->default_messaging(); -- 2.39.5