WPIntell

Source evidence

Fatal error: json_last_error

WCM User Language Switcher · support · 2013-01-29T19:17:00+00:00

mixedsentiment
highseverity
0.95relevance
18replies
Evidence linked to opportunitycommercial context

Proof Health

Open evidence

Commercial opportunities need traceable source links before they are treated as build-worthy.

6 / 26 rows with source links

23.1% of this page's analysis has direct source links.

0 build-decision rows missing links

0 rows here require auditable proof before promotion.

20 rows with no attached evidence

0 rows have source counts but still need direct links.

Conversation

support
Jarrel resolved
I´m desperate! I downloaded plugin to translate my Swedish homepage to English, but when I activated the program I just got a massage saying: Fatal error: Call to undefined function json_last_error() in /home/userA/a1319300/public_html/jarrelgolf.com/wp-content/plugins/wcm-user-language-switcher/wcm_lang_switch.class.php on line 249 Now I can´t do anything with my wordpress page!!! What am I suppose to do? How can I undefine the function json_lasr_error? Call line 249… what? Please help! http://wordpress.org/extend/plugins/wcm-user-language-switcher/ Jarrel I am in the same spot you were my fatal error reads: Fatal error: Call to undefined function json_last_error() in /home/content/c/a/m/cambiame/html/wordpress/wp-content/plugins/wcm-user-language-switcher/wcm_lang_switch.class.php on line 249 Were you able to fix your your problem? If so, what did you do? I need help. I am not a developer but I am looking through the plugin files Source file found at: https://github.com/wecodemore/wcm_lang_switch/blob/master/wcm_lang_switch.class.php I’m pasting this here in case this helps someone to figure out the problem faster. This is what I see at line 249 of ‘…/wcm_lang_switch.class.php’: return apply_filters( ‘wcm_get_langs’, array_merge( You can see the code around line 249 below: /** * Get Languages * @since 0.3 * @return array */ public function get_langs() { return apply_filters( ‘wcm_get_langs’, array_merge( get_available_languages() ,array( ‘en_US’ ) ) ); } Hi Jarrel & DanMo2013 Sorry to say, but we’ve completely missed out your error report. We will investigate this today and get back to you. Please – in the meantime – just go to GitHub [1] where the development versions are and download a working copy. The error itself is just a typo. Nothing to worry about. Thanks for your reports! Kaiser. [1] GitHub https://github.com/wecodemore/wcm_lang_switch I checked source [1] after reading Jarrels note about the missing function “json_lasr_error” and tought we had a typo, but this is clearly not the case. Now the function “json_last_error()” was introduced to PHP with version 5 [2]. Could you please check what PHP version you got? Simply install the following plugin or check your admin account at your hoster (or ask them). The minimum required version for WordPress itself currently is 5.2.1 and for this plugin it’s 5.0.0. So far I think you both just haven’t got a current PHP version running. <?php /* Plugin Name: Show PHP Version after footer */ add_action( 'shutdown', 'wcm_show_php_version' ); function wcm_show_php_version() { if ( version_compare( PHP_VERSION, '5.0.0', '>=' ) ) { printf( 'I am using PHP 5, my version is: %s', PHP_VERSION ); } } Please come back with more info. [1] http://plugins.trac.wordpress.org/browser/wcm-user-language-switcher/trunk/wcm_lang_switch.class.php#L249 [2] http://php.net/manual/en/function.json-last-error.php After some googlefoo, it could be that the info on PHP.net about the version when json_last_error() was introduced (5.0.0) is simply wrong and this function was introduced with (5.3.0). Please come back with more info and we’ll alter the error check according to your report. Thanks. Wish you a nice Sunday. Franz thanks for your quick reply and for helping us out. I am running php version 5.2.17 Ok, I’ll try to find a way around it and push a working version to GitHub. You’ll be able to work with this one and an update for the wp.org version will follow. We anyway wanted to do one as we got plenty of changes and improvements already built in on GitHub that aren’t in the current .org version. There’s now a working version on GitHub where I fixed it . I misread the minimum required version number on PHP.net for json_last_error() and it is indeed only available for people running PHP 5.3.0+. Please do a test of the new version and report your outcome at this issue . Thanks. This is what I did: I went to Github: https://github.com/wecodemore/wcm_lang_switch registered in Github downloaded the zip folder for wcm_lang_switch unzipped the folder and I changed the name of the folder from “wcm_lang_switch-master” to “wcm-user-language-switcher” Used ftp to remove the existing wcm_lang_switch folder (found under WordPress/plugins/wcm-user-language-switcher and replaced it with the one downloaded from github. I cleared the recent history in my browser (cookies, cache) and refreshed my browser. Now I can see the label “English” on the top of the page, on the admin bar. So, it seems to work. Thanks for fixing this. Wish you a nice Sunday. You’re welcome. Could we switch this to resolved now? RESOLVED Yes. Thank you again. @danmo2013 Are you able to mark it as such? I somehow can’t. It may be that since Jarrel started the support request, he or she is the one that has the option to set it to Resolved. function isJson($string) { return ((is_string($string) && (is_object(json_decode($string)) || is_array(json_decode($string))))) ? true : false;//PHP Version 5.2.17 server //json_decode($string); //return (json_last_error() == JSON_ERROR_NONE);//PHP Version 5.3.10-1ubuntu3.6 mylocal } @jaybharatjay What exactly are you trying to tell us? I am saying if your php 5.2.x version not supporting the json_last_error() then one solution for that i.e: return ((is_string($string) && (is_object(json_decode($string)) || is_array(json_decode($string))))) ? true : false; @jaybharatjay The issue is already resolved . The OP just didn’t mark it as such. You can see the details on GitHub . Anyway: Thanks for your efforts 🙂 My solution is universal like for core php developer also.:)

Comments

18 shown
DanMo2013 2013-03-03T07:31:00+00:00

Jarrel I am in the same spot you were my fatal error reads: Fatal error: Call to undefined function json_last_error() in /home/content/c/a/m/cambiame/html/wordpress/wp-content/plugins/wcm-user-language-switcher/wcm_lang_switch.class.php on line 249 Were you able to fix your your problem? If so, what did you do? I need help.

DanMo2013 2013-03-03T08:43:00+00:00

I am not a developer but I am looking through the plugin files Source file found at: https://github.com/wecodemore/wcm_lang_switch/blob/master/wcm_lang_switch.class.php I’m pasting this here in case this helps someone to figure out the problem faster. This is what I see at line 249 of ‘…/wcm_lang_switch.class.php’: return apply_filters( ‘wcm_get_langs’, array_merge( You can see the code around line 249 below: /** * Get Languages * @since 0.3 * @return array */ public function get_langs() { return apply_filters( ‘wcm_get_langs’, array_merge( get_available_languages() ,array( ‘en_US’ ) ) ); }

Franz Josef Kaiser 2013-03-03T08:45:00+00:00

Hi Jarrel & DanMo2013 Sorry to say, but we’ve completely missed out your error report. We will investigate this today and get back to you. Please – in the meantime – just go to GitHub [1] where the development versions are and download a working copy. The error itself is just a typo. Nothing to worry about. Thanks for your reports! Kaiser. [1] GitHub https://github.com/wecodemore/wcm_lang_switch

Franz Josef Kaiser 2013-03-03T08:55:00+00:00

I checked source [1] after reading Jarrels note about the missing function “json_lasr_error” and tought we had a typo, but this is clearly not the case. Now the function “json_last_error()” was introduced to PHP with version 5 [2]. Could you please check what PHP version you got? Simply install the following plugin or check your admin account at your hoster (or ask them). The minimum required version for WordPress itself currently is 5.2.1 and for this plugin it’s 5.0.0. So far I think you both just haven’t got a current PHP version running. <?php /* Plugin Name: Show PHP Version after footer */ add_action( 'shutdown', 'wcm_show_php_version' ); function wcm_show_php_version() { if ( version_compare( PHP_VERSION, '5.0.0', '>=' ) ) { printf( 'I am using PHP 5, my version is: %s', PHP_VERSION ); } } Please come back with more info. [1] http://plugins.trac.wordpress.org/browser/wcm-user-language-switcher/trunk/wcm_lang_switch.class.php#L249 [2] http://php.net/manual/en/function.json-last-error.php

Franz Josef Kaiser 2013-03-03T09:02:00+00:00

After some googlefoo, it could be that the info on PHP.net about the version when json_last_error() was introduced (5.0.0) is simply wrong and this function was introduced with (5.3.0). Please come back with more info and we’ll alter the error check according to your report. Thanks. Wish you a nice Sunday.

DanMo2013 2013-03-03T09:29:00+00:00

Franz thanks for your quick reply and for helping us out. I am running php version 5.2.17

Franz Josef Kaiser 2013-03-03T09:43:00+00:00

Ok, I’ll try to find a way around it and push a working version to GitHub. You’ll be able to work with this one and an update for the wp.org version will follow. We anyway wanted to do one as we got plenty of changes and improvements already built in on GitHub that aren’t in the current .org version.

Franz Josef Kaiser 2013-03-03T10:30:00+00:00

There’s now a working version on GitHub where I fixed it . I misread the minimum required version number on PHP.net for json_last_error() and it is indeed only available for people running PHP 5.3.0+. Please do a test of the new version and report your outcome at this issue . Thanks.

DanMo2013 2013-03-03T18:11:00+00:00

This is what I did: I went to Github: https://github.com/wecodemore/wcm_lang_switch registered in Github downloaded the zip folder for wcm_lang_switch unzipped the folder and I changed the name of the folder from “wcm_lang_switch-master” to “wcm-user-language-switcher” Used ftp to remove the existing wcm_lang_switch folder (found under WordPress/plugins/wcm-user-language-switcher and replaced it with the one downloaded from github. I cleared the recent history in my browser (cookies, cache) and refreshed my browser. Now I can see the label “English” on the top of the page, on the admin bar. So, it seems to work. Thanks for fixing this. Wish you a nice Sunday.

Franz Josef Kaiser 2013-03-03T21:36:00+00:00

You’re welcome. Could we switch this to resolved now? RESOLVED

DanMo2013 2013-03-03T21:44:00+00:00

Yes. Thank you again.

Franz Josef Kaiser 2013-03-03T21:45:00+00:00

@danmo2013 Are you able to mark it as such? I somehow can’t.

DanMo2013 2013-03-03T21:49:00+00:00

It may be that since Jarrel started the support request, he or she is the one that has the option to set it to Resolved.

jaybharatjay 2013-04-26T07:11:00+00:00

function isJson($string) { return ((is_string($string) && (is_object(json_decode($string)) || is_array(json_decode($string))))) ? true : false;//PHP Version 5.2.17 server //json_decode($string); //return (json_last_error() == JSON_ERROR_NONE);//PHP Version 5.3.10-1ubuntu3.6 mylocal }

Franz Josef Kaiser 2013-04-26T10:23:00+00:00

@jaybharatjay What exactly are you trying to tell us?

jaybharatjay 2013-04-26T10:34:00+00:00

I am saying if your php 5.2.x version not supporting the json_last_error() then one solution for that i.e: return ((is_string($string) && (is_object(json_decode($string)) || is_array(json_decode($string))))) ? true : false;

Franz Josef Kaiser 2013-04-26T11:52:00+00:00

@jaybharatjay The issue is already resolved . The OP just didn’t mark it as such. You can see the details on GitHub . Anyway: Thanks for your efforts 🙂

jaybharatjay 2013-04-26T13:18:00+00:00

My solution is universal like for core php developer also.:)