Issue #1274406 by marcingy, grndlvl: Fixed PDO exception is thrown when saving a node with a title that is too long.
parent
50fb0beb7d
commit
4060a32212
|
@ -75,10 +75,13 @@ function statistics_exit() {
|
||||||
}
|
}
|
||||||
if (variable_get('statistics_enable_access_log', 0)) {
|
if (variable_get('statistics_enable_access_log', 0)) {
|
||||||
drupal_bootstrap(DRUPAL_BOOTSTRAP_SESSION);
|
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.
|
// Log this page access.
|
||||||
db_insert('accesslog')
|
db_insert('accesslog')
|
||||||
->fields(array(
|
->fields(array(
|
||||||
'title' => strip_tags(drupal_get_title()),
|
'title' => truncate_utf8(strip_tags(drupal_get_title()), 255),
|
||||||
'path' => $_GET['q'],
|
'path' => $_GET['q'],
|
||||||
'url' => isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '',
|
'url' => isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '',
|
||||||
'hostname' => ip_address(),
|
'hostname' => ip_address(),
|
||||||
|
|
|
@ -63,9 +63,10 @@ class StatisticsLoggingTestCase extends DrupalWebTestCase {
|
||||||
function setUp() {
|
function setUp() {
|
||||||
parent::setUp('statistics');
|
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.
|
// Ensure we have a node page to access.
|
||||||
$this->node = $this->drupalCreateNode();
|
$this->node = $this->drupalCreateNode(array('title' => $this->randomName(255), 'uid' => $this->auth_user->uid));
|
||||||
$this->auth_user = $this->drupalCreateUser();
|
|
||||||
|
|
||||||
// Enable page caching.
|
// Enable page caching.
|
||||||
variable_set('cache', TRUE);
|
variable_set('cache', TRUE);
|
||||||
|
@ -116,6 +117,17 @@ class StatisticsLoggingTestCase extends DrupalWebTestCase {
|
||||||
$this->assertEqual(array_intersect_key($log[5], $expected), $expected);
|
$this->assertEqual(array_intersect_key($log[5], $expected), $expected);
|
||||||
$node_counter = statistics_get($this->node->nid);
|
$node_counter = statistics_get($this->node->nid);
|
||||||
$this->assertIdentical($node_counter['totalcount'], '3');
|
$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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue