MDL-31410 always send 200 in PayPal IPN response and hide all errors
This commit is contained in:
@@ -28,6 +28,9 @@
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
// Disable moodle specific debug messages and any errors in output,
|
||||
// comment out when debugging or better look into error log!
|
||||
define('NO_DEBUG_DISPLAY', true);
|
||||
|
||||
require("../../config.php");
|
||||
require_once("lib.php");
|
||||
@@ -35,6 +38,9 @@ require_once($CFG->libdir.'/eventslib.php');
|
||||
require_once($CFG->libdir.'/enrollib.php');
|
||||
require_once($CFG->libdir . '/filelib.php');
|
||||
|
||||
// PayPal does not like when we return error messages here,
|
||||
// the custom handler just logs exceptions and stops.
|
||||
set_exception_handler('enrol_paypal_ipn_exception_handler');
|
||||
|
||||
/// Keep out casual intruders
|
||||
if (empty($_POST) or !empty($_GET)) {
|
||||
@@ -330,4 +336,20 @@ function message_paypal_error_to_admin($subject, $data) {
|
||||
message_send($eventdata);
|
||||
}
|
||||
|
||||
/**
|
||||
* Silent exception handler.
|
||||
*
|
||||
* @param Exception $ex
|
||||
* @return void - does not return. Terminates execution!
|
||||
*/
|
||||
function enrol_paypal_ipn_exception_handler($ex) {
|
||||
$info = get_exception_info($ex);
|
||||
|
||||
$logerrmsg = "enrol_paypal IPN exception handler: ".$info->message;
|
||||
if (debugging('', DEBUG_NORMAL)) {
|
||||
$logerrmsg .= ' Debug: '.$info->debuginfo."\n".format_backtrace($info->backtrace, true);
|
||||
}
|
||||
error_log($logerrmsg);
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user