diff options
author | catch <catch@35733.no-reply.drupal.org> | 2011-10-29 17:55:37 +0900 |
---|---|---|
committer | catch <catch@35733.no-reply.drupal.org> | 2011-10-29 17:55:37 +0900 |
commit | 5155d6d2e3348671151a20138d578eff9497c00e (patch) | |
tree | 98b823843bf4347b4a0e262c66a2f568984c890e /modules | |
parent | af8e263568d6225ecd28c8aa17b801a299de4bff (diff) | |
download | drupal-5155d6d2e3348671151a20138d578eff9497c00e.tar.gz drupal-5155d6d2e3348671151a20138d578eff9497c00e.zip |
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')
-rw-r--r-- | modules/statistics/statistics.module | 5 | ||||
-rw-r--r-- | modules/statistics/statistics.test | 16 |
2 files changed, 18 insertions, 3 deletions
diff --git a/modules/statistics/statistics.module b/modules/statistics/statistics.module index 0ba9d7f733e..2cbe94bf575 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 126828f4a08..1b7f8ac2b99 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); } } |