Skip to content
This repository has been archived by the owner on Jun 10, 2019. It is now read-only.

Json decoding error #29

Closed
philspbr opened this issue Apr 7, 2016 · 20 comments
Closed

Json decoding error #29

philspbr opened this issue Apr 7, 2016 · 20 comments

Comments

@philspbr
Copy link

philspbr commented Apr 7, 2016

PHP 7 throws an exception when trying to decode an empty json string, this can result in errors in checkout and customer panel, when trying to save data, see here:
stackoverflow post and magento.stackexchange post.

Apparently it happens in Mage_Persistent_Model_Session in _beforeSave() $this->getData() is empty so $info is empty and decoding fails (taken from stackexchange post). A solution would be to pass "{}" instead of "".

@durzel
Copy link
Contributor

durzel commented Apr 7, 2016

I have seen "Decoding failed, syntax error" exceptions a number of times since upgrading to PHP 7.

The common factor - but might be a bizarre coincidence - is that in each case the affected user was using Safari on an iOS device (iPad usually). I've been unable to reproduce it myself, but have seen it consistently happen for some people.

@philspbr
Copy link
Author

philspbr commented Apr 7, 2016

This is exactly the error I'm talking about. I am also not able to reproduce the error, I only get the error emails sent from our server. I noticed that it happens in about 90% of the cases during checkout, when clicking the submit order button, and 10% in the customer/account route, probably when saving an address.

@durzel
Copy link
Contributor

durzel commented Apr 7, 2016

I'm glad you've flagged it because I thought it was something broken with my install. I've had no joy at all trying to track it down so your links could prove useful. This is an example of one of the errors I would see in the var/report folder - the user is seeing a 500 error page at this point, which since it's happening during checkout is not very reassuring...

URL: https://www.somewebsite.co.uk:443/checkout/onepage/index/
IP Address: 11.22.33.44
Time: 2016-03-02 12:44:52 GMT
Error:
Decoding failed: Syntax error

Trace:
#0 /home/magento/public_html/app/code/core/Mage/Core/Helper/Data.php(659): Zend_Json::decode('', 1)
#1 /home/magento/public_html/app/code/core/Mage/Persistent/Model/Session.php(133): Mage_Core_Helper_Data->jsonDecode(NULL)
#2 /home/magento/public_html/app/code/core/Mage/Core/Model/Abstract.php(226): Mage_Persistent_Model_Session->_afterLoad()
#3 /home/magento/public_html/app/code/core/Mage/Persistent/Model/Session.php(154): Mage_Core_Model_Abstract->load('deleted', 'key')
#4 /home/magento/public_html/app/code/core/Mage/Persistent/Helper/Session.php(67): Mage_Persistent_Model_Session->loadByCookieKey()
#5 /home/magento/public_html/app/code/core/Mage/Persistent/Helper/Session.php(91): Mage_Persistent_Helper_Session->getSession()
#6 /home/magento/public_html/app/code/core/Mage/Persistent/Model/Observer.php(177): Mage_Persistent_Helper_Session->isPersistent()
#7 /home/magento/public_html/app/code/core/Mage/Core/Model/App.php(1358): Mage_Persistent_Model_Observer->emulateQuote(Object(Varien_Event_Observer))
#8 /home/magento/public_html/app/code/core/Mage/Core/Model/App.php(1337): Mage_Core_Model_App->_callObserverMethod(Object(Mage_Persistent_Model_Observer), 'emulateQuote', Object(Varien_Event_Observer))
#9 /home/magento/public_html/app/Mage.php(448): Mage_Core_Model_App->dispatchEvent('controller_acti...', Array)
#10 /home/magento/public_html/app/code/core/Mage/Core/Controller/Varien/Action.php(527): Mage::dispatchEvent('controller_acti...', Array)
#11 /home/magento/public_html/app/code/core/Mage/Core/Controller/Front/Action.php(69): Mage_Core_Controller_Varien_Action->preDispatch()
#12 /home/magento/public_html/app/code/core/Mage/Checkout/controllers/OnepageController.php(59): Mage_Core_Controller_Front_Action->preDispatch()
#13 /home/magento/public_html/app/code/core/Mage/Core/Controller/Varien/Action.php(407): Mage_Checkout_OnepageController->preDispatch()
#14 /home/magento/public_html/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(254): Mage_Core_Controller_Varien_Action->dispatch('index')
#15 /home/magento/public_html/app/code/core/Mage/Core/Controller/Varien/Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#16 /home/magento/public_html/app/code/core/Mage/Core/Model/App.php(365): Mage_Core_Controller_Varien_Front->dispatch()
#17 /home/magento/public_html/app/Mage.php(683): Mage_Core_Model_App->run(Array)
#18 /home/magento/public_html/index.php(83): Mage::run('be', 'website')
#19 {main}

@philspbr
Copy link
Author

philspbr commented Apr 7, 2016

I can confirm that I get the same error message/trace.

@benjamw
Copy link
Contributor

benjamw commented Apr 7, 2016

I've added a commit and pull request that may or may not fix this issue. (One for each branch, but they're both the same)

Will the people that are having this issue implement the change on your installations and see if it fixes the issue? I don't have the resources to be able to test it.

Please note, this is an untested fix, and no guarantees or warranties are offered. Use at your own risk.

@philspbr
Copy link
Author

philspbr commented Apr 7, 2016

Thanks Benjam, I will test the fix and report back in a week if the error went away.

@HRR1337
Copy link

HRR1337 commented Apr 14, 2016

Was wondering if the fix is working. Thanks!

@philspbr
Copy link
Author

It has been one week since I implemented the fix and the error has not appeared again.

@peterjaap
Copy link

Tested and works, haven't had any problems since I've implemented it. Please merge @icurdinj :)

@durzel
Copy link
Contributor

durzel commented Apr 19, 2016

Nice. How does one go about incorporating this fix if I'm running the standard Inchoo_PHP7 branch? Or should I just wait for @icurdinj to commit it?

@peterjaap
Copy link

I created my own small extension for it, but you can also wait for @icurdinj .. I hope he'll merge it today/tomorrow.

@icurdinj
Copy link
Contributor

Patch merged. Big thanks to everyone who contributed in any way.

@durzel
Copy link
Contributor

durzel commented Apr 19, 2016

I just updated to this using "modman update-all", it pulled the changes but now my site crashes with the following error:

PHP Fatal error: Uncaught Error: Class 'Inchoo_PHP7_Helper_Data' not found in /home/magento-dev/public_html/app/Mage.php

EDIT: It looks as if there is no symlink back to ~/.modman/Inchoo_PHP7/app/code/local/Inchoo/PHP7/Helper created - should this happen automatically with the update?

@icurdinj
Copy link
Contributor

Seems like no one updated modman file with new files... I'll fix it now...

@icurdinj icurdinj reopened this Apr 19, 2016
@icurdinj
Copy link
Contributor

Should be fixed in master branch now. Please try it out.

@durzel
Copy link
Contributor

durzel commented Apr 19, 2016

Worked, thanks.

A minor point but the update process moans that the app/code/local/Inchoo/PHP7 directory exists and is not a symlink, but in the latest master branch it's become a symlink (previously etc and Model underneath it were the symlinks).

Not a big deal and moving forwards that's clearly the best way to make things easier for future updates, but you have to use --force to get modman to update to current master from anything previous.

@icurdinj
Copy link
Contributor

Yep, a slight pain now, but should prevent further such problems...

@praveen-tyagi
Copy link

Hi!
We are running a magento website version 1.9.3.7 , now we have switched to php version 7.0 After that We started getting error of "jsonDecode: syntex error" when customer do signup. We googled and found that Inchoo_PHP7 extension willl resolve this error.
So we downloaded it from this url=> https://github.com/Inchoo/Inchoo_PHP7

But still the problem is not resolved. Please help me out as it's crucial for our business.
any help will be appreciated.

Thanks!

@kanevbg
Copy link

kanevbg commented Aug 10, 2018

@praveen-tyagi stack trace is needed to know what is going on. Your project may be experiencing this error from non-core code which is decoding without using the Magento JSON decoder, if that is the case this module will not fix the issue.

@praveen-tyagi
Copy link

praveen-tyagi commented Aug 10, 2018 via email

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants