When the following conditions are true, visiting the node edit page or node delete page causes an error:

  • statistics module is enabled
  • enable access log is set on statistics settings page
  • node title is 255 characters
  • you visit that node's edit page or delete page

The error message is:

PDOException: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'title' at row 1: INSERT INTO {accesslog} (title, path, url, hostname, uid, sid, timer, timestamp) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7); Array ( [:db_insert_placeholder_0] => Edit Basic page Cras sed ante. Phasellus in massa. Curabitur dolor eros, gravida et, hendrerit ac, cursus non, massa. Aliquam lorem. In hac habitasse platea dictumst. Cras eu mauris. Quisque lacus. Donec ipsum. Nullam vitae sem at nunc pharetra ultricies. Vivamus elit e. [:db_insert_placeholder_1] => node/52/edit [:db_insert_placeholder_2] => http://drupal7/node/52 [:db_insert_placeholder_3] => 127.0.0.1 [:db_insert_placeholder_4] => 1 [:db_insert_placeholder_5] => drd1ggxfgimsmX3TYJb0jgF2PNU5MoKEldFrI0xyCig [:db_insert_placeholder_6] => 358 [:db_insert_placeholder_7] => 1311015739 ) in statistics_exit() (line 90 of /Users/balarama/Sites/git/drupal/modules/statistics/statistics.module).
CommentFileSizeAuthor
#7 pdo_title-exception-1222434-7.patch2.08 KBmarcingy
PASSED: [[SimpleTest]]: [MySQL] 32,952 pass(es). View
#5 pdo_title-exception-1222434-5.patch2.57 KBmarcingy
PASSED: [[SimpleTest]]: [MySQL] 33,572 pass(es). View
Members fund testing for the Drupal project. Drupal Association Learn more

Comments

moonray’s picture

moonray’s picture

marcingy’s picture

Status: Active » Closed (duplicate)

Yes it is a duplicate of #1180642: PDOException in statistics_exit() when path longer than 255 characters.

marcingy’s picture

Version: 7.x-dev » 8.x-dev
Priority: Major » Normal
Status: Closed (duplicate) » Active

Actually no isn't a dup but it is related as the 255 are being appended with additional characters. Marking as normal.

marcingy’s picture

Status: Active » Needs review
Issue tags: +needs backport to D7
FileSize
2.57 KB
PASSED: [[SimpleTest]]: [MySQL] 33,572 pass(es). View

Amends columns to text.

catch’s picture

Status: Needs review » Needs work

I think we can skip the update for Drupal 8 and just do that straight for Drupal 7, otherwise looks great.

marcingy’s picture

Status: Needs work » Needs review
FileSize
2.08 KB
PASSED: [[SimpleTest]]: [MySQL] 32,952 pass(es). View

Reroll for d8 without an update, d7 will need a reroll with the update hunk readded before it can applied.

catch’s picture

If we do any sorting on this table then turning this from varchar to text risks making any temporary tables disk rather than in memory - MySQL can't create memory temp tables with TEXT or BLOB columns.

marcingy’s picture

No sorting is done on title, the only potential issue is

$query->addExpression('MAX(title)', 'title');

but I don't believe this affects the index at all after doing some explains against the query built in statistics_top_pages with the title column set to text and varchar in both cases 'Using temporary; Using filesort' is utilised for this query

explain SELECT path, MAX(title), COUNT(path) as hits, AVG(timer), SUM(timer) FROM `d8`.`accesslog` group by path  order by hits;
catch’s picture

The index won't be affected, however the temporary table will always be written to disk, whereas without it has a chance of being written to memory. I'm not sure if there's an easy way to do before/after for in memory vs disk temporary tables but will try to find out.

marcingy’s picture

Status: Needs review » Closed (duplicate)