Twitter module cron import recently failed on one of our sites and when I debugged I found that the in_reply_to_user_id was a negative value. Because the database field is unsigned this was resulting in a PDO exception.

I believe this is related to this issue https://drupal.org/node/491794

For some reason the row for insertion into the twitter table is created as follows:

$row = array(
'twitter_id' => $status->id,
'screen_name' => $status->user->screen_name,
'created_time' => strtotime($status->created_at),
'text' => $status->text,
'source' => $status->source,
'in_reply_to_status_id' => ($status->in_reply_to_status_id > 0) ? (string) $status->in_reply_to_status_id : NULL,
// ISSUE HERE
'in_reply_to_user_id' => (int) $status->in_reply_to_user_id,
'in_reply_to_screen_name' => $status->in_reply_to_screen_name,
'truncated' => (int) $status->truncated,
);

The 'in_reply_to_user_id' value is being converted to an int. By changing that line to

'in_reply_to_user_id' => $status->in_reply_to_user_id,

everything works fine, cron runs, the correct ID gets inserted and all is well.

My concern is why this value is being converted to an int in the first place. Will something break as a result of me making this change? If not, then this should be applied as a patch, because all > 32bit IDs will cause cron to fail at that point.

Thanks,
Hawasha

CommentFileSizeAuthor
#3 twitter-2142055-3.patch594 bytescs_shadow

Comments

hawasha’s picture

Or, to correct - not all greater than 32 bit IDs will cause cron to fail. They will only fail if they are converted to a negative 32-bit. Otherwise they will be silently converted to another 32 bit, which might, in fact, be a different user ID. Definitely a bug.

Christopher Riley’s picture

Is there any movement on this issue I would love to use the module for a client but I can't with this issue being unresolved.

Thanks in advance.

cs_shadow’s picture

Status: Active » Needs review
StatusFileSize
new594 bytes

Attaching a basic patch that implements the fix suggested in the description. It fixes the bug though I'm not sure if its the best way to resolve this issue.

xurizaemon’s picture

Status: Needs review » Closed (duplicate)
Issue tags: +twitpocalypse

Are you hosting on 32-bit OS then? Please review #2205277: Twitpocalypse issues redux, I've added this issue to the list on that page. (Other issues tagged "twitpocalypse" are @ https://drupal.org/project/issues/search/twitter?text=twitpocalypse ...)

Your patch submission is appreciated, but note that it reverses a previous commit related to the same underlying issue (db2a4a4f relates to #985544: {twitter}.twitter_id incompletely stored (final digits are zeroes) due to json_decode limitation in PHP<5.3 and #780712: Port twitter to Drupal 7).

I'm open to this patch if you can back it up, but ask that you at least review those two issues and the meta-issue #2205277: Twitpocalypse issues redux before changing the status of this issue back to "needs review"; I'm going to mark duplicate for now.

adamps’s picture

Followers of this issue might like to see my comment/patch posted to the meta-issue #2205277: Twitpocalypse issues redux