From 0d100b57dcffe54ec7f46d8f577a4c26fcf34202 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Fri, 26 Dec 2008 14:23:38 +0000 Subject: - Patch #332002 by Crell et al: MergeQuery should refuse to execute if there are no key fields. With tests. --- modules/statistics/statistics.module | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'modules/statistics/statistics.module') diff --git a/modules/statistics/statistics.module b/modules/statistics/statistics.module index d90c257d2..8cb1cc6e2 100644 --- a/modules/statistics/statistics.module +++ b/modules/statistics/statistics.module @@ -51,14 +51,13 @@ function statistics_exit() { // We are counting content views. if ((arg(0) == 'node') && is_numeric(arg(1)) && arg(2) == '') { // A node has been viewed, so update the node's counters. - $fields = array( - 'daycount' => 1, - 'totalcount' => 1, - 'nid' => arg(1), - 'timestamp' => REQUEST_TIME, - ); db_merge('node_counter') - ->fields($fields) + ->key(array('nid' => arg(1))) + ->fields(array( + 'daycount' => 1, + 'totalcount' => 1, + 'timestamp' => REQUEST_TIME, + )) ->expression('daycount', 'daycount + 1') ->expression('totalcount', 'totalcount + 1') ->execute(); -- cgit v1.2.3