Bugzilla – Attachment 20058 Details for
Bug 7802
A MySQLism is used to get the current date.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 7802: Followup Remove CUR_DATE() and CURRENT_DATE() MySQLisms, replace by CAST(now() AS date).
Bug-7802-Followup-Remove-CURDATE-and-CURRENTDATE-M.patch (text/plain), 4.96 KB, created by
Kyle M Hall (khall)
on 2013-08-02 15:02:56 UTC
(
hide
)
Description:
Bug 7802: Followup Remove CUR_DATE() and CURRENT_DATE() MySQLisms, replace by CAST(now() AS date).
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2013-08-02 15:02:56 UTC
Size:
4.96 KB
patch
obsolete
>From 54797299bcda0a65fc786757cee5970e29b3645e Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@biblibre.com> >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). > >--- > 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 2052f09..f9928e0 100755 >--- a/C4/HoldsQueue.pm >+++ b/C4/HoldsQueue.pm >@@ -222,7 +222,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); >@@ -266,7 +266,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 ea8c2a6..959faaf 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 6429575..1bb6927 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -962,7 +962,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
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 7802
:
8526
|
8616
|
8901
|
8952
|
8953
|
19643
|
19644
|
20057
|
20058
|
20733
|
22755
|
22756
|
22760
|
22761
|
22816
|
22817