Bugzilla – Attachment 38723 Details for
Bug 12167
datetime type casting issue regarding bug 7567
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12167: Clean up GetNewsToDisplay
Bug-12167-Clean-up-GetNewsToDisplay.patch (text/plain), 2.58 KB, created by
Mark Tompsett
on 2015-04-30 14:28:11 UTC
(
hide
)
Description:
Bug 12167: Clean up GetNewsToDisplay
Filename:
MIME Type:
Creator:
Mark Tompsett
Created:
2015-04-30 14:28:11 UTC
Size:
2.58 KB
patch
obsolete
>From acc1b2464fafcd124c678c1978373d9a789d4d4c Mon Sep 17 00:00:00 2001 >From: Mark Tompsett <mtompset@hotmail.com> >Date: Sun, 27 Jul 2014 21:39:53 -0400 >Subject: [PATCH] Bug 12167: Clean up GetNewsToDisplay > >This bug started out as a result of busting while in transitions >of MySQL were happening in Ubuntu. However, I figured this fix >should remove backtick MySQLisms as per >http://wiki.koha-community.org/wiki/Coding_Guidelines#SQL6:_Backticks >And clean up GetNewsToDisplay a bit. > >TEST PLAN >--------- >1) News should function fine before applying any patches. >2) Apply all patches. >3) prove -v t/db_dependent/NewsChannels.t > -- expecting all happy results. > -- note the removal of backticks and the assumed typecasting > of a timestamp to date. > -- specified opac_news.timestamp to make sure that it would > more likely parse as a fieldname and not as a keyword. > >Signed-off-by: Bernardo Gonzalez Kriegel <bgkriegel@gmail.com> > >All patches applied, test pass, cleaner code, no regressions found, >no koha-qa errors > >Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de> >--- > C4/NewsChannels.pm | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > >diff --git a/C4/NewsChannels.pm b/C4/NewsChannels.pm >index 8694c1b..fc820d9 100644 >--- a/C4/NewsChannels.pm >+++ b/C4/NewsChannels.pm >@@ -188,27 +188,27 @@ sub get_opac_news { > sub GetNewsToDisplay { > my ($lang,$branch) = @_; > my $dbh = C4::Context->dbh; >- # SELECT *,DATE_FORMAT(timestamp, '%d/%m/%Y') AS newdate > my $query = q{ >- SELECT *,timestamp AS newdate >+ SELECT *,opac_news.timestamp AS newdate > FROM opac_news > WHERE ( > expirationdate >= CURRENT_DATE() > OR expirationdate IS NULL > OR expirationdate = '00-00-0000' > ) >- AND DATE(timestamp) < DATE_ADD(CURDATE(), INTERVAL 1 DAY) >+ AND CAST( opac_news.timestamp AS DATE ) <= CURRENT_DATE() > AND (lang = '' OR lang = ?) > AND (branchcode IS NULL OR branchcode = ?) > ORDER BY number > }; # expirationdate field is NOT in ISO format? >- # timestamp has HH:mm:ss, CURRENT_DATE generates 00:00:00 >- # by adding 1, that captures today correctly. >+ # casting timestamp to date truncates HH:mm:ss >+ # changing to <= CURRENT_DATE() today is captured. > my $sth = $dbh->prepare($query); > $lang = $lang // q{}; > $sth->execute($lang,$branch); > my @results; > while ( my $row = $sth->fetchrow_hashref ){ >+ # this will type cast and respect system preferences. > $row->{newdate} = format_date($row->{newdate}); > push @results, $row; > } >-- >1.9.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 12167
:
27825
|
27826
|
30171
|
30172
|
30173
|
30174
|
30175
|
30176
|
30599
|
30600
|
30601
|
30642
|
30663
|
30882
|
30883
|
30884
|
30885
|
31139
|
38721
|
38722
| 38723 |
38724