From 1fa31fb376de0a92ad8d376b92cd812df4f1753e Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Mon, 24 Feb 2014 11:48:27 +0800 Subject: [PATCH] MDL-44061 Ajax: Log whitespace issues to the server error log --- lib/ajax/ajaxlib.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/ajax/ajaxlib.php b/lib/ajax/ajaxlib.php index 0ed5f0ce34d..8c7336789ba 100644 --- a/lib/ajax/ajaxlib.php +++ b/lib/ajax/ajaxlib.php @@ -68,11 +68,15 @@ function ajax_check_captured_output() { $output = ob_get_contents(); ob_end_clean(); - if ($CFG->debugdeveloper && !empty($output)) { - // Only throw an error if the site is in debugdeveloper. - throw new coding_exception('Unexpected output whilst processing AJAX request. ' . + if (!empty($output)) { + $message = 'Unexpected output whilst processing AJAX request. ' . 'This could be caused by trailing whitespace. Output received: ' . - var_export($output, true)); + var_export($output, true); + if ($CFG->debugdeveloper && !empty($output)) { + // Only throw an error if the site is in debugdeveloper. + throw new coding_exception($message); + } + error_log('Potential coding error: ' . $message); } return $output; }