Bug 16550 - Can't set opac news expiration date to NULL, it reverts to today
Summary: Can't set opac news expiration date to NULL, it reverts to today
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: master
Hardware: All All
: P3 normal (vote)
Assignee: Marc Véron
QA Contact: Testopia
URL:
Keywords:
Depends on: 13813
Blocks:
  Show dependency treegraph
 
Reported: 2016-05-19 02:05 UTC by Nick Clemens
Modified: 2016-12-05 21:25 UTC (History)
3 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 16550: Can't set opac news expiration date to NULL, it reverts to today (2.29 KB, patch)
2016-05-20 10:26 UTC, Marc Véron
Details | Diff | Splinter Review
Bug 16550: Add test to NewsChannels.t (2.72 KB, patch)
2016-05-20 12:50 UTC, Marc Véron
Details | Diff | Splinter Review
Bug 16550: Can't set opac news expiration date to NULL, it reverts to today (2.33 KB, patch)
2016-05-20 13:56 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 16550: Add test to NewsChannels.t (2.77 KB, patch)
2016-05-20 13:57 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 16550: Can't set opac news expiration date to NULL, it reverts to today (2.41 KB, patch)
2016-05-20 16:34 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 16550: Add test to NewsChannels.t (2.85 KB, patch)
2016-05-20 16:34 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 16550: Clean the tests (5.25 KB, patch)
2016-05-20 16:34 UTC, Jonathan Druart
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Clemens 2016-05-19 02:05:04 UTC
Bug 13813 changed koha-news.pl to remove use of C4::Dates

However, dt_from_string defaults to today when passed a blank value, so news now must have an expiration date and it defaults to today
Comment 1 Marc Véron 2016-05-20 10:26:34 UTC Comment hidden (obsolete)
Comment 2 Marc Véron 2016-05-20 12:50:45 UTC Comment hidden (obsolete)
Comment 3 Nick Clemens 2016-05-20 13:01:54 UTC
When editing the news item the date is populated to today's date and must be cleared.  It does save as empty, but shouldn't auto-populate

Tests pass
Comment 4 Marc Véron 2016-05-20 13:24:52 UTC
Hi Nick,

I just re-tested:

- Applied both patches

- With MySql, emptied table opac_news
- Went to Home > Tools > News
- New entry, save it without filling in Expiration date
Result OK: News has no Expiration date in list

- Edit the entry
Result OK: In edit form, Expiration date is empty, does not auto-populate

- Change title, leave Expiration date empty, save
Result OK: News has no Expiration date in list

- Edit News, add an expiration date, save
Result OK: Expiration date appears in list

- Edit News again, remove date from Expiration date, save
Result OK: No expiration date in list
Comment 5 Nick Clemens 2016-05-20 13:56:57 UTC Comment hidden (obsolete)
Comment 6 Nick Clemens 2016-05-20 13:57:02 UTC Comment hidden (obsolete)
Comment 7 Jonathan Druart 2016-05-20 16:34:19 UTC
Created attachment 51668 [details] [review]
Bug 16550: Can't set opac news expiration date to NULL, it reverts to today

This patch fixes an issue with the expiration dates for news always reverting to today if empty.

To test:
- Apply patch
- Go to Home > Tools > News
- Create a news item, do not set expiration date
- Verify that expiration date stays empty
- Edit this news item
- Do not set expiration date
- Verify that expiration date stays empty
- Do the same with expiration dates
- Verify that they are saved properly

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 8 Jonathan Druart 2016-05-20 16:34:22 UTC
Created attachment 51669 [details] [review]
Bug 16550: Add test to NewsChannels.t

To test: Run t/db_dependent/NewsChannels.t

Tests adding and retreiving a news item without expiration date.
This test should fail without patch for Bug 16550 and pass OK with patch.

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 9 Jonathan Druart 2016-05-20 16:34:26 UTC
Created attachment 51670 [details] [review]
Bug 16550: Clean the tests

- replace ok with is
- remove diag
- replace $dbh->prepare->execute->fetchrow with $dbh->selectrow_array

And remove unecessary force to scalar context in pl

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 10 Kyle M Hall 2016-05-23 17:39:11 UTC
Pushed to master for 16.05, thanks Marc, Jonathan!
Comment 11 Julian Maurice 2016-05-25 09:30:52 UTC
Patches pushed to 3.22.x, will be in 3.22.7