diff --git a/core/modules/statistics/statistics.module b/core/modules/statistics/statistics.module index 6f01535..4f72553 100644 --- a/core/modules/statistics/statistics.module +++ b/core/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/core/modules/statistics/statistics.test b/core/modules/statistics/statistics.test index 1b7f8ac..a014767 100644 --- a/core/modules/statistics/statistics.test +++ b/core/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)); + } }