Page MenuHomePhabricator

1406 Data too long for column 'th_change_comment' at row 1
Open, Needs TriagePublic

Description

Setup

  • MediaWiki 1.27.4 (d314c84) 01:07, 9 December 2017
  • PHP 7.0.22-0ubuntu0.16.04.1 (apache2handler)
  • MySQL 5.7.20-0ubuntu0.16.04.1
  • Liquid Threads 2.2-alpha (0a16469) 22:43, 31 January 2017

Issue
A database query error has occurred. This may indicate a bug in the software.

The reason for this to happen is that the contents of the thread is inserted uncut to the field "Other/additional reason:". Thus the contents is too long.

Query:

INSERT  INTO `thread_history` (th_id,th_thread,th_timestamp,th_user,th_user_text,th_change_type,th_change_object,th_change_comment,th_content) VALUES (NULL,'2501','20171227170705','74','Kghbln','4','2501','Unnecessary page: content was: \"Hi everyone,  I am translating the system messages in Translatewiki.net to Spanish. During the translation I found an error i...\", and the only contributor was \"[[Special:Contributions/Ivanhercaz|Ivanhercaz]]\" ([[User talk:Ivanhercaz|talk]])','O:6:\"Thread\":26:{s:9:\"\0*\0rootId\";s:5:\"14004\";s:12:\"\0*\0articleId\";s:4:\"3334\";s:12:\"\0*\0summaryId\";N;s:13:\"\0*\0ancestorId\";s:1:\"0\";s:11:\"\0*\0parentId\";N;s:14:\"\0*\0superthread\";N;s:11:\"\0*\0ancestor\";r:1;s:19:\"\0*\0articleNamespace\";s:1:\"4\";s:15:\"\0*\0articleTitle\";s:16:\"Community_portal\";s:11:\"\0*\0modified\";s:14:\"20171227170705\";s:10:\"\0*\0created\";s:14:\"20171225214016\";s:10:\"\0*\0sortkey\";s:14:\"20171227170705\";s:5:\"\0*\0id\";s:4:\"2501\";s:7:\"\0*\0type\";i:2;s:10:\"\0*\0subject\";s:36:\"English error in the system messages\";s:11:\"\0*\0authorId\";s:4:\"3092\";s:13:\"\0*\0authorName\";s:10:\"Ivanhercaz\";s:12:\"\0*\0signature\";s:62:\"[[User:Ivanhercaz|Ivanhercaz]] ([[User talk:Ivanhercaz|talk]])\";s:16:\"\0*\0allDataLoaded\";N;s:15:\"\0*\0isHistorical\";b:0;s:15:\"\0*\0rootRevision\";N;s:10:\"editedness\";s:1:\"0\";s:10:\"\0*\0editors\";N;s:10:\"\0*\0replies\";a:0:{}s:12:\"\0*\0reactions\";N;s:10:\"replyCount\";s:1:\"0\";}')

Function: ThreadRevision::insert
Error: 1406 Data too long for column 'th_change_comment' at row 1 (localhost)

Backtrace

#0 /../w/includes/db/Database.php(901): DatabaseBase->reportQueryError('Data too long f...', 1406, 'INSERT  INTO `t...', 'ThreadRevision:...', false)
#1 /../w/includes/db/Database.php(1467): DatabaseBase->query('INSERT  INTO `t...', 'ThreadRevision:...')
#2 /../w/extensions/LiquidThreads/classes/ThreadRevision.php(99): DatabaseBase->insert('`thread_history...', Array, 'ThreadRevision:...')
#3 /../w/extensions/LiquidThreads/classes/ThreadRevision.php(88): ThreadRevision->insert()
#4 /../w/extensions/LiquidThreads/classes/Thread.php(188): ThreadRevision::create(Object(Thread), 4, Object(Thread), 'Unnecessary pag...')
#5 /../w/extensions/LiquidThreads/classes/Thread.php(345): Thread->commitRevision(4, Object(Thread), 'Unnecessary pag...')
#6 /../w/extensions/LiquidThreads/classes/DeletionController.php(22): Thread->delete('Unnecessary pag...')
#7 /../w/includes/Hooks.php(195): LqtDeletionController::onArticleDeleteComplete(Object(WikiPage), Object(User), 'Unnecessary pag...', 14004, Object(WikitextContent), Object(ManualLogEntry))
#8 /../w/includes/page/WikiPage.php(2950): Hooks::run('ArticleDeleteCo...', Array)
#9 /../w/includes/page/Article.php(1896): WikiPage->doDeleteArticleReal('Unnecessary pag...', false, 0, true, '', Object(User))
#10 /../w/includes/page/Article.php(1714): Article->doDelete('Unnecessary pag...', false)
#11 /../w/includes/actions/DeleteAction.php(54): Article->delete()
#12 /../w/includes/MediaWiki.php(493): DeleteAction->show()
#13 /../w/includes/MediaWiki.php(288): MediaWiki->performAction(Object(Article), Object(Title))
#14 /../w/includes/MediaWiki.php(735): MediaWiki->performRequest()
#15 /../w/includes/MediaWiki.php(509): MediaWiki->main()
#16 /../w/index.php(43): MediaWiki->run()
#17 {main}

Solution
The interim solution to mitigate this issue is to reduce the lenght of the content added to field "Other/additional reason:" when deleting a thread to an acceptable lenght. It will e.g. be nice if there is a size limit imposed by the software.

Event Timeline

Do you know if this was a problem before?

It uses TINYTEXT, which is 255 bytes...

But, if we look at the code, it does truncate... https://github.com/wikimedia/mediawiki-extensions-LiquidThreads/blob/master/classes/ThreadRevision.php#L90-L91

php > var_dump( strlen( 'Unnecessary page: content was: "Hi everyone,  I am translating the system messages in Translatewiki.net to Spanish. During the translation I found an error i...", and the only contributor was "[[Special:Contributions/Ivanhercaz|Ivanhercaz]]" ([[User talk:Ivanhercaz|talk]])' ) );
php shell code:1:
int(273)

Aside: I'm wondering if this is related to when comments was extended to 767 in https://github.com/wikimedia/mediawiki/commit/5d9b67e09ed150f342b17383e53cc0d4be1ba754#diff-f0c20561c771b8ca65f557c1aef33ba2

> echo mb_strlen( $wgContLang->truncate( 'Unnecessary page: content was: "Hi everyone,  I am translating the system messages in Translatewiki.net to Spanish. During the translation I found an error i...", and the only contributor was "[[Special:Contributions/Ivanhercaz|Ivanhercaz]]" ([[User talk:Ivanhercaz|talk]])', 255 ) );
255
> var_dump( $wgContLang->truncate( 'Unnecessary page: content was: "Hi everyone,  I am translating the system messages in Translatewiki.net to Spanish. During the translation I found an error i...", and the only contributor was "[[Special:Contributions/Ivanhercaz|Ivanhercaz]]" ([[User talk:Ivanhercaz|talk]])', 255 ) );
/var/www/wiki/mediawiki/core/maintenance/eval.php(78) : eval()'d code:1:
string(255) "Unnecessary page: content was: "Hi everyone,  I am translating the system messages in Translatewiki.net to Spanish. During the translation I found an error i...", and the only contributor was "[[Special:Contributions/Ivanhercaz|Ivanhercaz]]" ([[User ta..."

:/

Do you know if this was a problem before?

I cannot tell for sure since I very rarely delete threads but I am pretty sure that this did not happen when the wiki was on MW 1.23 and MySQL 5.5

It's nothing to do with MySQL, AFAIK. It's obvious that MW hasn't truncated the string properly, the question is why.

What content language is set on the wiki?

It's nothing to do with MySQL, AFAIK. It's obvious that MW hasn't truncated the string properly, the question is why.

Ah, ok. No worries. I trust your judgement.

What content language is set on the wiki?

It's "en".