XH_decodeJson() is broken

A place to report and discuss bugs - please mention CMSimple-version, server, platform and browser version
Post Reply
cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

XH_decodeJson() is broken

Post by cmb » Sun Dec 21, 2014 9:40 pm

Hello Community,

I've just noticed that the fallback in XH_decodeJson() behaves as if the $assoc argument is true, but the native json_decode() is called with the default $assoc == false. IOW: XH_decodeJson() is broken.

How shall we fix it? Shall it behave like $assoc == true or $assoc == false? I suggest the latter, because (a) that's the default behavior of json_encode() and (b) if anybody uses XH_decodeJson() at all (it's not used by the core or the standard plugins) than that's most likely the expected behavior (a dev would probably have tested it with json_decode() available rather than without).

Another option would be to add an optional $assoc parameter to XH_decodeJson(), but that seems to be overkill considering that a potential client (e.g. a plugin) could easily require PHP >= 5.2 and use json_decode() directly.

Thoughts?

Christoph

PS: I've put it on the 1.6.5, because it is a bug.
Christoph M. Becker – Plugins for CMSimple_XH

cmb
Posts: 14225
Joined: Tue Jun 21, 2011 11:04 am
Location: Bingen, RLP, DE
Contact:

Re: XH_decodeJson() is broken

Post by cmb » Fri Jan 09, 2015 6:31 pm

Done (r1446).
Christoph M. Becker – Plugins for CMSimple_XH

Post Reply