summaryrefslogtreecommitdiff
path: root/modules/statistics
diff options
context:
space:
mode:
authorwebchick <webchick@24967.no-reply.drupal.org>2011-10-29 12:26:55 -0700
committerwebchick <webchick@24967.no-reply.drupal.org>2011-10-29 12:26:55 -0700
commit4060a322128849fcaea16b337559ece8090a459f (patch)
tree4b8fd3b6c829208666de8d9183fc899f03934fed /modules/statistics
parent50fb0beb7d76edb25b2792fb878e26bbf11cd33d (diff)
downloadbrdo-4060a322128849fcaea16b337559ece8090a459f.tar.gz
brdo-4060a322128849fcaea16b337559ece8090a459f.tar.bz2
Issue #1274406 by marcingy, grndlvl: Fixed PDO exception is thrown when saving a node with a title that is too long.
Diffstat (limited to 'modules/statistics')
-rw-r--r--modules/statistics/statistics.module5
-rw-r--r--modules/statistics/statistics.test16
2 files changed, 18 insertions, 3 deletions
diff --git a/modules/statistics/statistics.module b/modules/statistics/statistics.module
index 69e06f33d..566a8b30a 100644
--- a/modules/statistics/statistics.module
+++ b/modules/statistics/statistics.module
@@ -75,10 +75,13 @@ function statistics_exit() {
}
if (variable_get('statistics_enable_access_log', 0)) {
drupal_bootstrap(DRUPAL_BOOTSTRAP_SESSION);
+
+ // For anonymous users unicode.inc will not have been loaded.
+ include_once DRUPAL_ROOT . '/includes/unicode.inc';
// Log this page access.
db_insert('accesslog')
->fields(array(
- 'title' => strip_tags(drupal_get_title()),
+ 'title' => truncate_utf8(strip_tags(drupal_get_title()), 255),
'path' => $_GET['q'],
'url' => isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '',
'hostname' => ip_address(),
diff --git a/modules/statistics/statistics.test b/modules/statistics/statistics.test
index 126828f4a..1b7f8ac2b 100644
--- a/modules/statistics/statistics.test
+++ b/modules/statistics/statistics.test
@@ -63,9 +63,10 @@ class StatisticsLoggingTestCase extends DrupalWebTestCase {
function setUp() {
parent::setUp('statistics');
+ $this->auth_user = $this->drupalCreateUser(array('access content', 'create page content', 'edit own page content'));
+
// Ensure we have a node page to access.
- $this->node = $this->drupalCreateNode();
- $this->auth_user = $this->drupalCreateUser();
+ $this->node = $this->drupalCreateNode(array('title' => $this->randomName(255), 'uid' => $this->auth_user->uid));
// Enable page caching.
variable_set('cache', TRUE);
@@ -116,6 +117,17 @@ class StatisticsLoggingTestCase extends DrupalWebTestCase {
$this->assertEqual(array_intersect_key($log[5], $expected), $expected);
$node_counter = statistics_get($this->node->nid);
$this->assertIdentical($node_counter['totalcount'], '3');
+
+ // Visit edit page to generate a title greater than 255.
+ $path = 'node/' . $this->node->nid . '/edit';
+ $expected = array(
+ 'title' => truncate_utf8(t('Edit Basic page') . ' ' . $this->node->title, 255),
+ 'path' => $path,
+ );
+ $this->drupalGet($path);
+ $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);
}
}