The field is defined as varchar 255, so it throws an error when you try to send a message longer than 255 characters. According to http://tools.ietf.org/html/rfc2812 IRC messages are limited to 512 characters, so the field should probably be changed to type text to at least handle the IRC limit.

I'm not sure what happens if you send an IRC message longer than the 512 character limit, but it might also be worth breaking up longer messages into 512 character chunks.

Comments

Drave Robber’s picture

I can't quite tell where did I get 255 from, but I'm somewhat hesitant to change it. 512 includes PRIVMSG<space><target><space>, so the maximum length of message body depends on the target but can never exceed 502; I reckon 255 will always be on the safe side.

Splitting up longer data is a must though, but the limit could be configurable - e.g., you could split longer messages into chunks of max 70 chars if you so wish.

sreynen’s picture

In testing, comments longer than 512 still go through and just get truncated to the max length, which is better than not posting at all. So that's good.

Bad news: depending on the rule, a PDO error can cause data loss, since some actions happen before content is saved.

I suspect you used 255 since that's the max size of varchar fields. Anything larger than that will, I believe, need to be a text field, which can be huge, so size restrictions would need to be applied in code.

Drave Robber’s picture

Title: PDOException on longer data in botrules_queue content » Split long messages into chunks to avoid data loss
Version: 7.x-1.0-beta1 » 7.x-1.x-dev
Status: Active » Needs review
StatusFileSize
new4 KB

Let's make it configurable. I can see someone wanting to split into smaller chunks for better readability (so that the whole message fits into one line in his/her IRC client - e.g., for me ~160 is optimal).

Further TODO: #1692900: Configuration form needs some validation

On a side note, 255 used to be the maximum size of varchar until MySQL 5.0.3; it's more complex (subject to row size limits) these days. 255 is hopefully on the safe side both with MySQL and other dbs.

sreynen’s picture

Status: Needs review » Needs work

I think hook_schema also needs to change, or this will hit the same PDO error when it's configured larger than 255.

Drave Robber’s picture

My point was I'd rather limit it to 255 than mess with changing schema, unless someone can present a use case where 255+ character long messages are vitally needed. In addition to laziness considerations :), text may have worse performance than varchar, and the table in question is scanned at least once in 15 seconds.

So, this should be viewed in context with the patch just posted in #1692900: Configuration form needs some validation. (I'm of course open to discussion)

sreynen’s picture

Status: Needs work » Reviewed & tested by the community

Ah, I see. Limiting it to 255 on validation, as you've done in #1692900: Configuration form needs some validation looks good to me.

Drave Robber’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 7.x-1.x-dev.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.