From fb5cfe1f58742509dc6c0b5c794ca8a27f8a11a5 Mon Sep 17 00:00:00 2001 From: Marc Balmer Date: Mon, 15 Jul 2013 12:28:43 +0200 Subject: [PATCH] Bug 7802: Remove CUR_DATE() and CURRENT_DATE() MySQLisms, replace by CAST(now() AS date). Signed-off-by: Jonathan Druart --- C4/Acquisition.pm | 4 ++-- C4/NewsChannels.pm | 4 ++-- C4/Reserves.pm | 4 ++-- circ/overdue.pl | 2 +- misc/cronjobs/longoverdue.pl | 6 +++--- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/C4/Acquisition.pm b/C4/Acquisition.pm index aabc0ed..655ee61 100644 --- a/C4/Acquisition.pm +++ b/C4/Acquisition.pm @@ -2382,7 +2382,7 @@ sub GetContracts { $query = "SELECT * FROM aqcontract WHERE booksellerid=? - AND contractenddate >= CURDATE( )"; + AND contractenddate >= CAST(now() AS date)"; } my $sth = $dbh->prepare($query); $sth->execute( $booksellerid ); @@ -2439,7 +2439,7 @@ sub AddClaim { my $query = " UPDATE aqorders SET claims_count = claims_count + 1, - claimed_date = CURDATE() + claimed_date = CAST(now() AS date) WHERE ordernumber = ? "; my $sth = $dbh->prepare($query); diff --git a/C4/NewsChannels.pm b/C4/NewsChannels.pm index 0201729..7698802 100644 --- a/C4/NewsChannels.pm +++ b/C4/NewsChannels.pm @@ -141,11 +141,11 @@ sub GetNewsToDisplay { SELECT *,timestamp AS newdate FROM opac_news WHERE ( - expirationdate >= CURRENT_DATE() + expirationdate >= CAST(now() AS date) OR expirationdate IS NULL OR expirationdate = '00-00-0000' ) - AND `timestamp` <= CURRENT_DATE() + AND `timestamp` <= CAST(now() AS date) AND lang = ? ORDER BY number "; # expirationdate field is NOT in ISO format? diff --git a/C4/Reserves.pm b/C4/Reserves.pm index d1bca25..bed6954 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -372,7 +372,7 @@ sub GetReservesFromItemnumber { WHERE itemnumber=? "; unless ( $all_dates ) { - $query .= " AND reservedate <= CURRENT_DATE()"; + $query .= " AND reservedate <= CAST(now() AS date)"; } my $sth_res = $dbh->prepare($query); $sth_res->execute($itemnumber); @@ -942,7 +942,7 @@ sub CancelExpiredReserves { # Cancel reserves that have passed their expiration date. my $dbh = C4::Context->dbh; my $sth = $dbh->prepare( " - SELECT * FROM reserves WHERE DATE(expirationdate) < DATE( CURDATE() ) + SELECT * FROM reserves WHERE DATE(expirationdate) < CAST(now() AS date) AND expirationdate IS NOT NULL AND found IS NULL " ); diff --git a/circ/overdue.pl b/circ/overdue.pl index 4343592..d73f7b1 100755 --- a/circ/overdue.pl +++ b/circ/overdue.pl @@ -297,7 +297,7 @@ if ($noreport) { $strsth .= " AND borrowers.gonenoaddress <> 0"; } elsif ( $borflagsfilter eq 'debarred' ) { - $strsth .= " AND borrowers.debarred >= CURDATE()" ; + $strsth .= " AND borrowers.debarred >= CAST(now() AS date)" ; } elsif ( $borflagsfilter eq 'lost') { $strsth .= " AND borrowers.lost <> 0"; diff --git a/misc/cronjobs/longoverdue.pl b/misc/cronjobs/longoverdue.pl index 0f64712..4edcda0 100755 --- a/misc/cronjobs/longoverdue.pl +++ b/misc/cronjobs/longoverdue.pl @@ -117,7 +117,7 @@ unless ($confirm) { } # In my opinion, this line is safe SQL to have outside the API. --atz -our $bounds_sth = C4::Context->dbh->prepare("SELECT DATE_SUB(CURDATE(), INTERVAL ? DAY)"); +our $bounds_sth = C4::Context->dbh->prepare("SELECT DATE_SUB(CAST(now() AS date), INTERVAL ? DAY)"); sub bounds ($) { $bounds_sth->execute(shift); @@ -130,8 +130,8 @@ sub longoverdue_sth { SELECT items.itemnumber, borrowernumber, date_due FROM issues, items WHERE items.itemnumber = issues.itemnumber - AND DATE_SUB(CURDATE(), INTERVAL ? DAY) > date_due - AND DATE_SUB(CURDATE(), INTERVAL ? DAY) <= date_due + AND DATE_SUB(CAST(now() AS date), INTERVAL ? DAY) > date_due + AND DATE_SUB(CAST(now() AS date), INTERVAL ? DAY) <= date_due AND itemlost <> ? ORDER BY date_due "; -- 1.7.10.4