Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON encoding /decoding problems on older PHP versions #2735

Closed
sgiehl opened this issue Oct 23, 2011 · 8 comments
Closed

JSON encoding /decoding problems on older PHP versions #2735

sgiehl opened this issue Oct 23, 2011 · 8 comments
Assignees
Labels
Bug For errors / faults / flaws / inconsistencies etc.
Milestone

Comments

@sgiehl
Copy link
Member

sgiehl commented Oct 23, 2011

On our meetup today a user reported problems with displaying some statistics in piwik mobile. As that were parse errors in the json string given from the server, we checked the response.

Seems to be that on his server the numberformating didn't work as expected as there were parts formated like {'key': 12,7} which is just invalid and should be {'key': 12.7}

I searched a bit, and I guess that might be a problem with older versions of PHP (<5.2.15). see https://bugs.php.net/bug.php?id=53507

I currently don't have a server with php 5.2 running, so I can't reproduce that bug.

In order to fix that issue, maybe we should set the locale to english before using json_encode and reset that afterwards.

@robocoder
Copy link
Contributor

I think bug 53507 lists the wrong php version; I tested 5.2.6, 5.2.13 (and above) and the locale had no effect

I was able to reproduce the problem with 5.2.1. I checked the php 5 changelog, and this problem was reportedly fixed in 5.2.5.

@robocoder
Copy link
Contributor

(In [5432]) fixes #2735

@mattab
Copy link
Member

mattab commented Nov 13, 2011

Cool to get this fixed, what a complicated thing to do to be cross version compatible :) but this is good.

Can you please confirm that it does not break BC for existing JSON strings (except those with the buggy php version)?

@robocoder
Copy link
Contributor

The fallback is libs/upgradephp/upgrade.php's json_encode/json_decode, which is already used by Piwik users running PHP 5.1.x. This will now also apply to users running:

  • php 5.2.0, and
  • php 5.2.1 to 5.2.4 where the locale's decimal separator isn't '.'

@anonymous-matomo-user
Copy link

[https://bugs.php.net/bug.php?id=53507] < can you elaborate a bit on what you see here?

@robocoder
Copy link
Contributor

(In [5520]) refs #2735, refs #2812

@robocoder
Copy link
Contributor

(In [5984]) refs #2735

@mattab
Copy link
Member

mattab commented Mar 7, 2012

(In [5994]) refs #2735 I assume it cannot hurt

@sgiehl sgiehl added this to the 1.7 Piwik 1.7 milestone Jul 8, 2014
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc.
Projects
None yet
Development

No branches or pull requests

4 participants