Issue #1180642 by franz, catch, xjm, musicnode: Fixed PDOException in statistics_exit() when path longer than 255 characters.
parent
58237ba0b2
commit
77c0c9a48c
|
@ -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,
|
||||
|
|
|
@ -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));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue