August 10, 2010 at 4:59 pm #1658
Currently the return value of main function “wp_aff_award_commission” which do the job for award referer is a piece of html text always says the award is success no matter if this operation is indeed success or fail.
The possibility of award fail is very tiny, but if the operation failed once and nobody to handle this mistake, it can occur twice, triple, and more. It is important for us to know if the operation unfortunately failed thus we can correct this manually and do something to avoid it happen again.
Is there already a plan for this?August 11, 2010 at 2:11 am #23274amin007Participant
As you have mentioned already that the possibility of a failure is tiny so if it does fail just knowing about it doesn’t help that much. What really helps is if you can have some sort of indication as to why it failed too.
So I have made the function return a big string rather than just true or false. You can then search for the following in this returned string:
“The sale has been registered in the WP Affiliates Platform Database”
If the above is not present then that would mean a failure in which case you can print out the full string which will hopefully some indication as to why or where it actually failed.August 11, 2010 at 3:51 am #23275
I’m sorry, but in current logic of your script, “The sale has been registered in the WP Affiliates Platform Database” will always be presented, unless the script crashes, in that case, no message will be presented also includes this one.
The only case it will not be presented is the input parameter $referer is empty, which is not so useful.
Also i think crashes’d better be avoided at least in this MAIN function, because once it crashes, all following actions will not be executedAugust 11, 2010 at 4:50 am #23276amin007Participant
I see. I can add in more checks so if it returns false then it adds the appropriate message to that string. I think the only one that can fail is the database update execution.August 11, 2010 at 5:24 am #23277
That’d be appreciated!
And ye, database operation, like get, update, wordpress guys did a lot of error handling in these functions to catch exception in various situation, make use of their return value is easy and greatly improve script robustness.
- You must be logged in to reply to this topic.