Skip to content
TORNLIFE More

[API] issue with 'code' in users/attacks selection

Started by Manuito [2225097] Committee on in Bugs & Issues.

2 replies · 51 views · thread synced · 5 days ago · View on torn.com
About this thread

Posts archived: 3 / 3 posts (100%) · the total is Torn's reply count + the opening post at the last fetch

Counted by TornLife from the archived posts.

Archived posts
3
Discussion span
→
People posting
2
Likes on archived posts
0
Posts by staff, officers and moderators
3
Authority score
57 / 100
Historical score
39 / 100
Story score
30 / 100
Engagement score
35 / 100
Manuito [2225097] Committee Committee
When the 'code' parameter in the users/attacks selection can be transformed into a number, it comes as a double/integer and is not transformed into a string. It's a very rare occurrence, but it can happen.

Example:

[background color=var(--bbc-body-bg-color)]"code": 5.085933525620613e+31,[/background]

When it should be:

[background color=var(--bbc-body-bg-color)]"code": "5.085933525620613e+31",[/background]

... for consistency.


I'd suggest to transform it into a string in any case.
Chedburn [1] Admin Developer
It seems to be almost impossible to prevent scientific notation on a string that can occasionally be a number, without touching php.ini.
I've gone with the only hack that seems to work:

(is_int($code) ? rtrim(sprintf("%.0f ",$code)) : $code)

I don't know what the odds are of having one of these attack log codes only contain numbers, I thought it was practically impossible - but apparently not.

Thanks.