Bug 15155 - Can't call method "truncate" on an undefined value at /usr/share/koha/lib/C4/Circulation.pm line 1966
Summary: Can't call method "truncate" on an undefined value at /usr/share/koha/lib/C4/...
Status: CLOSED WORKSFORME
Alias: None
Product: Koha
Classification: Unclassified
Component: Circulation (show other bugs)
Version: 3.20
Hardware: All Linux
: P3 normal (vote)
Assignee: Bugs List
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-11-09 02:07 UTC by Francisco Peixoto
Modified: 2016-12-05 21:22 UTC (History)
5 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Who signed the patch off:
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 Francisco Peixoto 2015-11-09 02:07:40 UTC
Hello everyone?
Comment 1 Francisco Peixoto 2015-11-09 02:09:58 UTC
Hi Everyone.
This software error message come up when performing items checkin?

Can't call method "truncate" on an undefined value at /usr/share/koha/lib/C4/Circulation.pm line 1966

Thank very much in advance for any help.

Kind regards
Comment 2 Jonathan Druart 2015-11-13 14:56:36 UTC
Could you report the borrowers.debarred value for the patron you are checkin the item out.
Comment 3 Francisco Peixoto 2015-11-18 02:54:37 UTC
Hello Jonathan, thanks.

The value is NULL. And we got the same value for all patrons.

I think this is how it should be right?

Thank you very much

Kind regards

Francisco
Comment 4 Jonathan Druart 2015-11-25 15:03:36 UTC
With a debarred value set to NULL, I don't know at all how you could get this error.
Could you confirm that the line 1966 of your C4/Circulation.pm is the same as the ligne 1972 of the following snippet (from 3.20.x):

1967         } elsif ( $issue->{date_due} and $borrower->{'debarred'} ) {
1968              if ( $borrower->{debarred} eq "9999-12-31") {
1969                 $messages->{'ForeverDebarred'} = $borrower->{'debarred'};
1970              } else {
1971                   my $borrower_debar_dt = dt_from_string( $borrower->{debarred} );
1972                   $borrower_debar_dt->truncate(to => 'day');
1973                   my $today_dt = $today->clone()->truncate(to => 'day');
1974                   if ( DateTime->compare( $borrower_debar_dt, $today_dt ) != -1 ) {
1975                       $messages->{'PrevDebarred'} = $borrower->{'debarred'};
1976                   }
1977              }
Comment 5 Heinrich Hartl 2016-01-25 20:05:52 UTC
I am also getting that error:
/usr/share/koha/lib/C4/Circulation.pm line 1966. After reading your questions we ran a report on our users and found that a group of users has the value 0000-00-00 in column debarred and apparently is haunted by above error when returning items.

cardnumber;borrowernumber;surname;firstname;debarred
1;1;Admin;Koha;
23529001223637;51;Lanz;Stefan;
23529001223638;52;Pelosi;Silvia;
...
P2304-20150001;57;Landwehr;"Mara ";0000-00-00
P2304-20150002;58;Petry;Margit;0000-00-00
P2304-20150003;59;Friedrich-Sander;Heide;0000-00-00
...
That group may be a set of users that were imported in 2015 under then 3.18. But I am not sure about this. 
The error message pops up when such users return items.

Unfortunately I do not know how to correct the situation, how to reset 
the values of debarred in table Table testsql_comments.borrowers (assuming this is the value causing the trouble)

debarred 	date 	10 	 √  		null 			until this date the patron can only check-in (no loans, no holds, etc.), is a fine based on days instead of money (YYY-MM-DD)

If I try to manually correct the debarred date I can not find a menue to do so. Editing the patron attributes the attributes in this koha version (3.20.00.000) do not include the debarred date. The koha manual is not helpful.

I have never before operated directly on the mysql database, I only ran reports sofar. Since I have 186 occurrences of debarred = 0000-00-00 A script would be helpful. I am also ignorant if it is ok to adjust the debarred value and not to make other corrections to maintain consistency.

Here are my lines from  sudo vi /usr/share/koha/lib/C4/Circulation.pm


   1965                   my $borrower_debar_dt = dt_from_string( $borrower->{debarred} );
   1966                   $borrower_debar_dt->truncate(to => 'day');
   1967                   my $today_dt = $today->clone()->truncate(to => 'day');
Comment 6 Jonathan Druart 2016-01-27 14:55:44 UTC
See bug 14717, which has been pushed to 3.20.4
Comment 7 Katrin Fischer 2016-02-28 20:34:13 UTC
should this bug be closed?
Comment 8 Francisco Peixoto 2016-03-21 04:06:44 UTC
Hello

I think this bug is now solved. After we update to version 3.22.02.000 we stop having this problem.

Thank you all

Kind regards
Comment 9 Katrin Fischer 2016-03-21 06:11:57 UTC
Thank you for the feedback, closing.