Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Living up to the facts, get GS to work under PHP 5.2 again!
#1
GetSimple has always stated to run on PHP 5.1.3 and up. Apparently, as of some version, this has no longer been true.

fstieglitz pointed out an installation problem which was easily traced back to a single function not being available below PHP version 5.2.0. I guess with all us developers* running on higher versions of PHP we never noticed. The solution is simple, we define the function when your version of PHP doesn’t!

I did not feel like we had any need for a complete JSON interpreter. Instead the below function is specially made to only read the two possible replies from the GetSimple API server. I’m throwing it up here and not on the SVN because I’ll leave the call to Chris whether we will just make GetSimple 5.2.0+ only or want to define this function in the core.

The fix, put the following code at the bottom of /admin/inc/basic.php:
Code:
/*******************************************************
* @function json_decode
* @returns the API response in the form of an object
* @about - This is to temporarily fix issues with PHP versions < 5.2.0
*
*/
if(!function_exists('json_decode')) {
    function json_decode($api_data) {
        preg_match('/(?P<status>[^"]+)","((api_key":"(?P<api_key>[^"]+))|(latest":"(?P<latest>[^"]+)))/',$api_data,$api_data);
        return (object)$api_data;
    }
}
/******************************************************/

* I partly made this fix because, to keep my fancy title, I feel like I should keep offering support here on the forum ;-)
“Don’t forget the important ˚ (not °) on the a,” says the Unicode lover.
Help us test a key change for the core! ¶ Problems with GetSimple? Be sure to enable debug mode!
Reply


Messages In This Thread
Living up to the facts, get GS to work under PHP 5.2 again! - by Zegnåt - 2010-04-24, 05:24:45



Users browsing this thread: 1 Guest(s)