Bug 14918 - Remove C4::Dates from circ/pendingreserves.pl
Summary: Remove C4::Dates from circ/pendingreserves.pl
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: master
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Jonathan Druart
QA Contact: Marcel de Rooy
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 14870
  Show dependency treegraph
 
Reported: 2015-09-29 09:49 UTC by Marc Véron
Modified: 2016-06-21 21:39 UTC (History)
4 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Bot Control: ---
When did the bot last check this:
Who signed the patch off:
Text to go in the release notes:


Attachments
Remove C4::Dates from circ/pendingreserves.pl (2.81 KB, patch)
2015-09-29 09:55 UTC, Marc Véron
Details | Diff | Splinter Review
[SIGNED-OFF]Remove C4::Dates from circ/pendingreserves.pl (2.96 KB, patch)
2015-09-29 19:56 UTC, Héctor Eduardo Castro Avalos
Details | Diff | Splinter Review
Bug 14918: Remove C4::Dates from circ/pendingreserves.pl (5.51 KB, patch)
2015-10-01 09:14 UTC, Jonathan Druart
Details | Diff | Splinter Review
[Signed-off] Bug 14918: Remove C4::Dates from circ/pendingreserves.pl (5.72 KB, patch)
2015-10-01 11:18 UTC, Marc Véron
Details | Diff | Splinter Review
Bug 14918: Remove C4::Dates from circ/pendingreserves.pl (5.80 KB, patch)
2015-10-23 06:53 UTC, Marcel de Rooy
Details | Diff | Splinter Review
Bug 14918: [QA Follow-up] Correct enddate and use constant (2.51 KB, patch)
2015-10-23 06:53 UTC, Marcel de Rooy
Details | Diff | Splinter Review
Bug 14918: Remove C4::Dates from circ/pendingreserves.pl (5.71 KB, patch)
2015-10-23 06:58 UTC, Marcel de Rooy
Details | Diff | Splinter Review
Bug 14918: [QA Follow-up] Correct enddate and use constant (2.51 KB, patch)
2015-10-23 06:58 UTC, Marcel de Rooy
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Marc Véron 2015-09-29 09:49:42 UTC
This patch removes C4::Dates from circ/pendingreserves.pl
Comment 1 Marc Véron 2015-09-29 09:55:24 UTC Comment hidden (obsolete)
Comment 2 Héctor Eduardo Castro Avalos 2015-09-29 19:56:27 UTC Comment hidden (obsolete)
Comment 3 Jonathan Druart 2015-10-01 09:14:42 UTC Comment hidden (obsolete)
Comment 4 Jonathan Druart 2015-10-01 09:16:00 UTC
I suggest this counter-patch, the badly formatted dates are caught and don't make Koha explodes with a software error.
Comment 5 Marc Véron 2015-10-01 11:18:57 UTC Comment hidden (obsolete)
Comment 6 Marcel de Rooy 2015-10-08 08:14:59 UTC
-    my $pastdate= sprintf("%-04.4d-%-02.2d-%02.2d", Add_Delta_YMD($year, $month, $day, 0, 0, -C4::Context->preference('HoldsToPullStartDate')||TWO_DAYS_AGO ));
-    $startdate = format_date($pastdate);
+    $startdate = $today - DateTime::Duration->new( days => C4::Context->preference('HoldsToPullStartDate') || 2 );


Replacing a constant by a hardcoded value is not an improvement.
Comment 7 Jonathan Druart 2015-10-08 09:15:11 UTC
(In reply to Marcel de Rooy from comment #6)
> -    my $pastdate= sprintf("%-04.4d-%-02.2d-%02.2d", Add_Delta_YMD($year,
> $month, $day, 0, 0,
> -C4::Context->preference('HoldsToPullStartDate')||TWO_DAYS_AGO ));
> -    $startdate = format_date($pastdate);
> +    $startdate = $today - DateTime::Duration->new( days =>
> C4::Context->preference('HoldsToPullStartDate') || 2 );
> 
> 
> Replacing a constant by a hardcoded value is not an improvement.

A constant named TWO_DAYS_AGO does not make really sense...
And is only used once.
Feel free to use TWO_DAYS instead, if you prefer.
Comment 8 Marc Véron 2015-10-10 09:57:13 UTC
I hope that is no blocker :-)
Comment 9 Marcel de Rooy 2015-10-16 11:22:48 UTC
(In reply to Marc Véron from comment #8)
> I hope that is no blocker :-)
No. I will fix it next week.
Comment 10 Marcel de Rooy 2015-10-23 06:53:12 UTC Comment hidden (obsolete)
Comment 11 Marcel de Rooy 2015-10-23 06:53:34 UTC Comment hidden (obsolete)
Comment 12 Marcel de Rooy 2015-10-23 06:58:02 UTC
Created attachment 43798 [details] [review]
Bug 14918: Remove C4::Dates from circ/pendingreserves.pl

This patch uses Koha::DateUtils instead of C4::Dates and Date::Calc. It
also sent DateTime objects to the template, which use the TT plugin to
display them.
If an invalid dates is entered, the default date is picked.

Test plan:
1/ Go to Home > Circulation > Holds to pull
2/ Verify that the the filter and the list behave as before
3/ Enter invalid dates and confirm that you do not get a software error

Counter patch works as expected and is a much cleaner solution.
Signed-off-by: Marc Veron <veron@veron.ch>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 13 Marcel de Rooy 2015-10-23 06:58:06 UTC
Created attachment 43799 [details] [review]
Bug 14918: [QA Follow-up] Correct enddate and use constant

Corrected enddate (subtraction in the revised code must be an addition).
Replaced hardcoded 2 days by a constant.
Renamed the constant TWO_DAYS to PULL_INTERVAL.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Tested all three date formats.
Comment 14 Tomás Cohen Arazi 2015-10-23 13:54:12 UTC
Patches pushed to master.

Thanks Jonathan and Marcel!