From 4690e35f68ec53d677681a1af275a41fd23878d2 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 6 Apr 2012 14:58:19 +0200 Subject: [PATCH] Bug 7802: Followup Remove CUR_DATE() and CURRENT_DATE() MySQLisms, replace by CAST(now() AS date). Signed-off-by: Kyle M Hall --- C4/HoldsQueue.pm | 4 ++-- C4/Koha.pm | 2 +- C4/Reserves.pm | 2 +- misc/cronjobs/cleanup_database.pl | 10 +++++----- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/C4/HoldsQueue.pm b/C4/HoldsQueue.pm index ce4594b..a5ff72e 100755 --- a/C4/HoldsQueue.pm +++ b/C4/HoldsQueue.pm @@ -230,7 +230,7 @@ sub GetBibsWithPendingHoldRequests { FROM reserves WHERE found IS NULL AND priority > 0 - AND reservedate <= CURRENT_DATE() + AND reservedate <= CAST(now() AS date) AND suspend = 0 "; my $sth = $dbh->prepare($bib_query); @@ -274,7 +274,7 @@ sub GetPendingHoldRequestsForBib { WHERE biblionumber = ? AND found IS NULL AND priority > 0 - AND reservedate <= CURRENT_DATE() + AND reservedate <= CAST(now() AS date) AND suspend = 0 ORDER BY priority"; my $sth = $dbh->prepare($request_query); diff --git a/C4/Koha.pm b/C4/Koha.pm index 6f91b8b..3cb71a4 100644 --- a/C4/Koha.pm +++ b/C4/Koha.pm @@ -1451,7 +1451,7 @@ sub GetDailyQuote { # Fall through... we also return a random quote as a catch-all if all else fails } else { - $query = 'SELECT * FROM quotes WHERE timestamp LIKE CONCAT(CURRENT_DATE,\'%\') ORDER BY timestamp DESC LIMIT 0,1'; + $query = 'SELECT * FROM quotes WHERE timestamp LIKE CONCAT(CAST(now() AS date),\'%\') ORDER BY timestamp DESC LIMIT 0,1'; $sth = $dbh->prepare($query); $sth->execute(); $quote = $sth->fetchrow_hashref(); diff --git a/C4/Reserves.pm b/C4/Reserves.pm index 11300e9..78b5f79 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -974,7 +974,7 @@ sub AutoUnsuspendReserves { my $dbh = C4::Context->dbh; - my $query = "UPDATE reserves SET suspend = 0, suspend_until = NULL WHERE DATE( suspend_until ) < DATE( CURDATE() )"; + my $query = "UPDATE reserves SET suspend = 0, suspend_until = NULL WHERE DATE( suspend_until ) < CAST(now() AS date)"; my $sth = $dbh->prepare( $query ); $sth->execute(); diff --git a/misc/cronjobs/cleanup_database.pl b/misc/cronjobs/cleanup_database.pl index 4b6444f..1b2ce8c 100755 --- a/misc/cronjobs/cleanup_database.pl +++ b/misc/cronjobs/cleanup_database.pl @@ -128,7 +128,7 @@ if ($zebraqueue_days) { } $sth = $dbh->prepare( "SELECT id,biblio_auth_number,server,time FROM zebraqueue - WHERE done=1 and time < date_sub(curdate(), interval ? day)" + WHERE done=1 and time < date_sub(CAST(now() AS date), interval ? day)" ); $sth->execute($zebraqueue_days) or die $dbh->errstr; $sth2 = $dbh->prepare("DELETE FROM zebraqueue WHERE id=?"); @@ -144,7 +144,7 @@ if ($zebraqueue_days) { if ($mail) { print "Mail queue purge triggered for $mail days.\n" if ($verbose); - $sth = $dbh->prepare("DELETE FROM message_queue WHERE time_queued < date_sub(curdate(), interval ? day)"); + $sth = $dbh->prepare("DELETE FROM message_queue WHERE time_queued < date_sub(CAST(now() AS date), interval ? day)"); $sth->execute($mail) or die $dbh->errstr; my $count = $sth->rows; $sth->finish; @@ -167,7 +167,7 @@ if($pImport) { if($pLogs) { print "Purging records from action_logs.\n" if $verbose; - $sth = $dbh->prepare("DELETE FROM action_logs WHERE timestamp < date_sub(curdate(), interval ? DAY)"); + $sth = $dbh->prepare("DELETE FROM action_logs WHERE timestamp < date_sub(CAST(now() AS date), interval ? DAY)"); $sth->execute($pLogs) or die $dbh->errstr; print "Done with purging action_logs.\n" if $verbose; } @@ -204,7 +204,7 @@ sub RemoveOldSessions { sub PurgeImportTables { #First purge import_records #Delete cascades to import_biblios, import_items and import_record_matches - $sth = $dbh->prepare("DELETE FROM import_records WHERE upload_timestamp < date_sub(curdate(), interval ? DAY)"); + $sth = $dbh->prepare("DELETE FROM import_records WHERE upload_timestamp < date_sub(CAST(now() AS date), interval ? DAY)"); $sth->execute($pImport) or die $dbh->errstr; # Now purge import_batches @@ -216,6 +216,6 @@ sub PurgeImportTables { FROM import_batches ba LEFT JOIN import_records re ON re.import_batch_id=ba.import_batch_id WHERE re.import_record_id IS NULL AND - ba.upload_timestamp < date_sub(curdate(), interval ? DAY)"); + ba.upload_timestamp < date_sub(CAST(now() AS date), interval ? DAY)"); $sth->execute($pImport) or die $dbh->errstr; } -- 1.7.2.5