cornernote / yii-embed-opencart

A lightweight Yii application embedded into OpenCart
http://cornernote.github.io/yii-embed-opencart/
Other
18 stars 7 forks source link

Enabling Yii error handler breaks at least one 3rd party payment plug in #11

Closed dfumagalli closed 10 years ago

dfumagalli commented 10 years ago

Hello,

back again to bother you :smiling_imp:

I have a payment gateway plug in that stops working if I set `YII_ENABLE_ERROR_HANDLER' to true in config.php.

At the moment I have to keep my config.php as follows:

// Yii
define('YII_DEBUG', true); // set to true for fancy error messages
define('YII_TRACE_LEVEL', 0);
define('YII_ENABLE_EXCEPTION_HANDLER', true);
define('YII_ENABLE_ERROR_HANDLER', false);

If I don't, this specific plug in (from a company called MultiSafepay) won't process checkouts and won't redirect my website to their gateway's web page.

Now, I am certainly not going to ask you to check their (enormous and whose quality I can't vouch) code out, but could you please give me some pointers?

I can't change payment company, their code throws some undefined variables notices here and there. If I don't enable Yii error handler however their "thing" ... "works" and processes payments. If I do, it silently fails, no logs anywhere, no clues. Talking with their devs is a total bump against a rubber wall, they won't even let me talk with them (they play Big Important Bank vs us, little peasants).

Needless to say, debugging hidden forms full of fields sent to an OC controller (*) is nasty at best, so if you could please tell me if there's some Yii logging feature or anything related with setting the Yii error handler to true that could help me understand where their code silently dies, I'd be most happy and grateful!

(*) Unlike Paypal and others, this backend works as follows: in OC the customers clicks "Confirm Order". Then, instead of directly going to the bank's back end a la Paypal and others, an OC controller is called, POSTing a couple of variables. That OC controller, in turn, prepares a number of XML queries and other similar stuff and only then, it redirects itself to the backend. The bug happens somewhere between the OC controller beginning and the place where it redirects. I have no idea how to debug that quite massive code being called with a POST from an hidden form from an Ajax checkout.

cornernote commented 10 years ago

Sounds like quite a doozie.

All I can suggest is writing to a log file between every line until you isolate where it gets upto. Once you know where it's failing it will give a lot more insight and the ability to replicate it in a smaller piece of code.

dfumagalli commented 10 years ago

Yeah, I agree. Though, it does not fail unless I enable Yii error handler. That is, there's something the OC built in error handle does different. So, one thing is to have to debug for "tangible" errors, another is to debug why errors you know exist somewhere, behave in a different way depending on which error handler is enabled.

Error handlers should not change the program flow, apparently this is the case when enabling or not Yii handling.

cornernote commented 10 years ago

It may be that yii is throwing an error, but as it's in an ajax call you're missing it. You may be interested in a yii extension that I created that will save all the errors into a table: http://cornernote.github.io/yii-audit-module/

Although it may be overkill just to find this issue. I'll leave it with you.

dfumagalli commented 10 years ago

Eh eh did I say you are awesome (no, it's not flattery)? Thank you so much!

cornernote commented 10 years ago

Feel free to throw gold and hundred dollar bills. ;)

Seriously tho, it's no trouble at all. Hope you can isolate the issue. If you do, post me as to what it was as I'm a little curious.