CMS MADE SIMPLE FORGE

TweetMadeSimple

 

[#5671] Twitter's new Status ID generator Snowflake with >32-bit unsigned integers display in TMS in scientific notation

avatar
Created By: Miia Ranta (myrtti)
Date Submitted: Sat Nov 13 15:32:11 -0500 2010

Assigned To: Jean-Christophe Cuvelier (totophe)
Version: Twitter 1.2.1
CMSMS Version: None
Severity: Major
Resolution: Fixed
State: Closed
Summary:
Twitter's new Status ID generator Snowflake with >32-bit unsigned integers display in TMS in scientific notation
Detailed Description:
Version 1.2.1, 1.0.1 with CMSMS Version 1.9, PHP 5.2.14, MySQL 5.0.77, Apache
and Linux 2.6.18

BUG DETAILED DESCRIPTIONS
===========================================================
Due to Twitter making a transition to new 64-bit unsigned integers as Status
ID's starting from 4th November 2010, some versions of TMS/CMSMS/PHP may end up
returning $tweet->id in scientific notation, for example 1.2024E+09 (a double)
instead of an integer. If the ID is used to create links to the original tweets,
the links break. The problem exists but is not necessarily limited to the JSON
API.

EXACT STEPS LEADING TO PROBLEM:
===========================================================
1. Install TweetMadeSimple
2. Create a template which utilises the ID in creation of an URL; for example 
<ul>
{foreach from=$timeline item=tweet}  
<li id="status_{$tweet->id}><a
href="http://twitter.com/{$tweet->author_name}/status/{$tweet->id}"><strong>{$tweet->getWhen()}</strong></a><br
/>
{$tweet->getText()}
    </li>
{/foreach}
</ul>

EXPECTED OUTCOME:
===================
Link points to a correct tweet.

ACTUAL OUTCOME:
===================
Link points to non-existing tweet, user is disappointed

SUGGESTED FIX:
===================
modifying the integer to be displayed as a string, or force it to be displayed
as is;

in classes/Tweet.class.php

$datas['id'] = number_format($content->id, 0, '.', '');
$datas['id'] = number_format($json['id'], 0, '.', '');

seems to remove the problem for me.

ADDITIONAL LINKS:
===================
http://groups.google.com/group/twitter-development-talk/browse_thread/thread/6a16efa375532182
http://jetlogs.org/2008/02/05/php-problems-with-big-integers-and-scientific-notation/


History

Comments
avatar
Date: 2010-11-14 04:07
Posted By: Jean-Christophe Cuvelier (totophe)

Dear Miia, thanks for the info. This is fixed for the next release.

Br,

Totophe
      
Updates

Updated: 2010-11-14 04:07
resolution_id: 5 => 7
state: Open => Closed

Updated: 2010-11-13 15:43
description: Version 1.2.1, 1.0.1 with CMSMS Version 1.9, PHP 5.2.14, MySQL 5.0.77, Apache and Linux 2.6.18 BUG DETAILED DESCRIPTIONS =========================================================== Due to Twitter making a transition to new 64-bit unsigned integers as => Version 1.2.1, 1.0.1 with CMSMS Version 1.9, PHP 5.2.14, MySQL 5.0.77, Apache and Linux 2.6.18 BUG DETAILED DESCRIPTIONS =========================================================== Due to Twitter making a transition to new 64-bit unsigned integers as

Updated: 2010-11-13 15:36
description: Version 1.2.1, 1.0.1 with CMSMS Version 1.9, PHP 5.2.14, MySQL 5.0.77, Apache and Linux 2.6.18 BUG DETAILED DESCRIPTIONS =========================================================== Due to Twitter making a transition to new 64-bit unsigned integers as => Version 1.2.1, 1.0.1 with CMSMS Version 1.9, PHP 5.2.14, MySQL 5.0.77, Apache and Linux 2.6.18 BUG DETAILED DESCRIPTIONS =========================================================== Due to Twitter making a transition to new 64-bit unsigned integers as
resolution_id: => 5