summaryrefslogtreecommitdiff
path: root/modules/statistics
diff options
context:
space:
mode:
authorwebchick <webchick@24967.no-reply.drupal.org>2011-11-11 11:55:48 -0800
committerwebchick <webchick@24967.no-reply.drupal.org>2011-11-11 11:55:48 -0800
commit77c0c9a48cb63da96b1dc1020363324890418c44 (patch)
treed8af92612eb2ca6016f30c421b0d875f28864afa /modules/statistics
parent58237ba0b26f52a5634adf81f73492fea3961c3b (diff)
downloadbrdo-77c0c9a48cb63da96b1dc1020363324890418c44.tar.gz
brdo-77c0c9a48cb63da96b1dc1020363324890418c44.tar.bz2
Issue #1180642 by franz, catch, xjm, musicnode: Fixed PDOException in statistics_exit() when path longer than 255 characters.
Diffstat (limited to 'modules/statistics')
-rw-r--r--modules/statistics/statistics.module2
-rw-r--r--modules/statistics/statistics.test10
2 files changed, 11 insertions, 1 deletions
diff --git a/modules/statistics/statistics.module b/modules/statistics/statistics.module
index 566a8b30a..a9c944b99 100644
--- a/modules/statistics/statistics.module
+++ b/modules/statistics/statistics.module
@@ -82,7 +82,7 @@ function statistics_exit() {
db_insert('accesslog')
->fields(array(
'title' => truncate_utf8(strip_tags(drupal_get_title()), 255),
- 'path' => $_GET['q'],
+ 'path' => truncate_utf8($_GET['q'], 255),
'url' => isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '',
'hostname' => ip_address(),
'uid' => $user->uid,
diff --git a/modules/statistics/statistics.test b/modules/statistics/statistics.test
index 1b7f8ac2b..a0147679b 100644
--- a/modules/statistics/statistics.test
+++ b/modules/statistics/statistics.test
@@ -128,6 +128,16 @@ class StatisticsLoggingTestCase extends DrupalWebTestCase {
$log = db_query('SELECT * FROM {accesslog}')->fetchAll(PDO::FETCH_ASSOC);
$this->assertTrue(is_array($log) && count($log) == 7, t('Page request was logged.'));
$this->assertEqual(array_intersect_key($log[6], $expected), $expected);
+
+ // Create a path longer than 255 characters.
+ $long_path = $this->randomString(256);
+
+ // Test that the long path is properly truncated when logged.
+ $this->drupalGet($long_path);
+ $log = db_query('SELECT * FROM {accesslog}')->fetchAll(PDO::FETCH_ASSOC);
+ $this->assertTrue(is_array($log) && count($log) == 8, 'Page request was logged for a path over 255 characters.');
+ $this->assertEqual($log[7]['path'], truncate_utf8($long_path, 255));
+
}
}