https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=36137 --- Comment #6 from Lucas Gass <lucas@bywatersolutions.com> --- (In reply to Emily Lamancusa from comment #4)
(In reply to Lucas Gass from comment #1)
I don't see why an if/else is needed here. We can just pass the value $incremental to UpdateTotalIssues
- my $ret; - if ( $incremental && $totalissues > 0 ) { - $ret = UpdateTotalIssues( $biblionumber, $totalissues ); - } - else { - $ret = UpdateTotalIssues( $biblionumber, 0, $totalissues ); - }
Instead this should work just as good:
+ my $ret = UpdateTotalIssues( $biblionumber, $incremental, $totalissues, 1 );
The if/else is necessary. In the if branch, $totalissues is being passed as the $increase parameter (i.e. the amount to increment the existing value by). In the else branch, $totalissues is being passed as the $value parameter (i.e. the value to overwrite the existing value).
Providing a defined $value parameter causes UpdateTotalIssues to ignore the $increment parameter, so if the --incremental flag is set, the third parameter needs to be undef. Otherwise UpdateTotalIssues will overwrite the existing value instead of incrementing it as desired.
That being said...if the --incremental flag is set, but $totalissues is 0 for a particular biblio, the else clause will still trigger, and wipe out the totalissues value for that biblio! So the if/else isn't correct to begin with - those conditions need to be checked separately.
Thanks Emily. -- You are receiving this mail because: You are watching all bug changes.