From 087f7b78294adfc0cf99b2ae6dacc50fbfd0b293 Mon Sep 17 00:00:00 2001 From: Dhananjay Nakrani Date: Sat, 10 May 2014 01:48:56 +0530 Subject: [PATCH 01/35] Add script that will report all the errors of current-script-run. This script is intended to be used same as common.inc.php, but at the end of each script. Signed-off-by: Dhananjay Nakrani --- libraries/Error_Handler.class.php | 9 ++++ libraries/common_error_reporting.inc.php | 56 ++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 libraries/common_error_reporting.inc.php diff --git a/libraries/Error_Handler.class.php b/libraries/Error_Handler.class.php index c9c3176eee..075a1516fd 100644 --- a/libraries/Error_Handler.class.php +++ b/libraries/Error_Handler.class.php @@ -94,6 +94,15 @@ class PMA_Error_Handler return $this->errors; } + /** + * returns the errorsoccured in the current run only. Does not include the errors save din the SESSION + * + */ + public function getCurrentErrors() + { + return $this->errors; + } + /** * Error handler - called when errors are triggered/occurred * diff --git a/libraries/common_error_reporting.inc.php b/libraries/common_error_reporting.inc.php new file mode 100644 index 0000000000..8dd39bd8ac --- /dev/null +++ b/libraries/common_error_reporting.inc.php @@ -0,0 +1,56 @@ +hasErrors()) { + // then log them in a local file. + $path = "./pma_error_log.txt"; + $fp = fopen($path, "w"); + + // for each errors in the list + foreach($GLOBALS['error_handler']->getCurrentErrors() as $errObj ) { + /** + * Following check is to avoid error reported by PMA_warnMissingExtension(); + * + */ + if ($errObj->getLine() && $errObj->getType()) { + $str = "\n\n".$errObj->getFile() . "(#" . $errObj->getLine() . ")\n\t". $errObj->getTitle(); + // for stack trace + // ------------------------------------------------------------------------------------------ + $backtrace = $errObj->getBacktrace(); + $error_str= ""; + foreach($backtrace as $i=>$stack_frame) + { + $error_str .= "\n \t\t\t Frame[".$i."]: \tfile:".$stack_frame["file"]."\tline:".$stack_frame["line"]."\tfunction:".$stack_frame["function"]."("; + foreach($stack_frame["args"] as $j=>$arg) + { + if($j != 0) + { + $error_str .= ", "; + } + + $error_str .= "arg[".$j."] = ".$arg; + } + $error_str .= ")"; + + if($i >= 5) // MAX 5 of stack frames. + { + break; + } + } + // ------------------------------------------------------------------------------------------ + $retVal = fwrite ($fp , $str); + $retVal = fwrite ($fp , $error_str); + } + } + fclose($fp); +} +?> From 9ef2231859f0c176da72dd4a35c2e7f3daef608f Mon Sep 17 00:00:00 2001 From: Dhananjay Nakrani Date: Sat, 10 May 2014 01:49:25 +0530 Subject: [PATCH 02/35] Include error reporitng script at the end of index.php. Corrosponding error local & temporary log file. Signed-off-by: Dhananjay Nakrani --- index.php | 6 +++++ pma_error_log.txt | 62 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100755 pma_error_log.txt diff --git a/index.php b/index.php index c23250e1dc..c533e7a33a 100644 --- a/index.php +++ b/index.php @@ -662,4 +662,10 @@ function PMA_printListItem($name, $listId = null, $url = null, } echo ''; } + +echo $sdh; + +require_once 'libraries/common_error_reporting.inc.php'; + + ?> diff --git a/pma_error_log.txt b/pma_error_log.txt new file mode 100755 index 0000000000..6b53729d46 --- /dev/null +++ b/pma_error_log.txt @@ -0,0 +1,62 @@ + + +./libraries/Config.class.php(#1185) + Warning: fileperms(): stat failed for ./config.inc.php + Frame[0]: file:/var/www/phpmyadmin/libraries/Config.class.php line:1185 function:fileperms(arg[0] = ./config.inc.php) + Frame[1]: file:/var/www/phpmyadmin/libraries/common.inc.php line:580 function:checkPermissions() + Frame[2]: file:/var/www/phpmyadmin/index.php line:12 function:require_once(arg[0] = /var/www/phpmyadmin/libraries/common.inc.php) + +./index.php(#497) + User Warning: The configuration file now needs a secret passphrase (blowfish_secret). + Frame[0]: file:/var/www/phpmyadmin/index.php line:497 function:trigger_error(arg[0] = The configuration file now needs a secret passphrase (blowfish_secret)., arg[1] = 512) + +./index.php(#666) + Notice: Undefined variable: sdh + +./libraries/Config.class.php(#1185) + Warning: fileperms(): stat failed for ./config.inc.php + Frame[0]: file:/var/www/phpmyadmin/libraries/Config.class.php line:1185 function:fileperms(arg[0] = ./config.inc.php) + Frame[1]: file:/var/www/phpmyadmin/libraries/common.inc.php line:580 function:checkPermissions() + Frame[2]: file:/var/www/phpmyadmin/index.php line:12 function:require_once(arg[0] = /var/www/phpmyadmin/libraries/common.inc.php) + +./libraries/Config.class.php(#1185) + Warning: fileperms(): stat failed for ./config.inc.php + Frame[0]: file:/var/www/phpmyadmin/libraries/Config.class.php line:1185 function:fileperms(arg[0] = ./config.inc.php) + Frame[1]: file:/var/www/phpmyadmin/libraries/common.inc.php line:580 function:checkPermissions() + Frame[2]: file:/var/www/phpmyadmin/index.php line:12 function:require_once(arg[0] = /var/www/phpmyadmin/libraries/common.inc.php) + +./libraries/Config.class.php(#1185) + Warning: fileperms(): stat failed for ./config.inc.php + Frame[0]: file:/var/www/phpmyadmin/libraries/Config.class.php line:1185 function:fileperms(arg[0] = ./config.inc.php) + Frame[1]: file:/var/www/phpmyadmin/libraries/common.inc.php line:580 function:checkPermissions() + Frame[2]: file:/var/www/phpmyadmin/index.php line:12 function:require_once(arg[0] = /var/www/phpmyadmin/libraries/common.inc.php) + +./libraries/Config.class.php(#1185) + Warning: fileperms(): stat failed for ./config.inc.php + Frame[0]: file:/var/www/phpmyadmin/libraries/Config.class.php line:1185 function:fileperms(arg[0] = ./config.inc.php) + Frame[1]: file:/var/www/phpmyadmin/libraries/common.inc.php line:580 function:checkPermissions() + Frame[2]: file:/var/www/phpmyadmin/index.php line:12 function:require_once(arg[0] = /var/www/phpmyadmin/libraries/common.inc.php) + +./libraries/Config.class.php(#1185) + Warning: fileperms(): stat failed for ./config.inc.php + Frame[0]: file:/var/www/phpmyadmin/libraries/Config.class.php line:1185 function:fileperms(arg[0] = ./config.inc.php) + Frame[1]: file:/var/www/phpmyadmin/libraries/common.inc.php line:580 function:checkPermissions() + Frame[2]: file:/var/www/phpmyadmin/index.php line:12 function:require_once(arg[0] = /var/www/phpmyadmin/libraries/common.inc.php) + +./libraries/Config.class.php(#1185) + Warning: fileperms(): stat failed for ./config.inc.php + Frame[0]: file:/var/www/phpmyadmin/libraries/Config.class.php line:1185 function:fileperms(arg[0] = ./config.inc.php) + Frame[1]: file:/var/www/phpmyadmin/libraries/common.inc.php line:580 function:checkPermissions() + Frame[2]: file:/var/www/phpmyadmin/index.php line:12 function:require_once(arg[0] = /var/www/phpmyadmin/libraries/common.inc.php) + +./libraries/Config.class.php(#1185) + Warning: fileperms(): stat failed for ./config.inc.php + Frame[0]: file:/var/www/phpmyadmin/libraries/Config.class.php line:1185 function:fileperms(arg[0] = ./config.inc.php) + Frame[1]: file:/var/www/phpmyadmin/libraries/common.inc.php line:580 function:checkPermissions() + Frame[2]: file:/var/www/phpmyadmin/index.php line:12 function:require_once(arg[0] = /var/www/phpmyadmin/libraries/common.inc.php) + +./libraries/Config.class.php(#1185) + Warning: fileperms(): stat failed for ./config.inc.php + Frame[0]: file:/var/www/phpmyadmin/libraries/Config.class.php line:1185 function:fileperms(arg[0] = ./config.inc.php) + Frame[1]: file:/var/www/phpmyadmin/libraries/common.inc.php line:580 function:checkPermissions() + Frame[2]: file:/var/www/phpmyadmin/index.php line:12 function:require_once(arg[0] = /var/www/phpmyadmin/libraries/common.inc.php) \ No newline at end of file From 64451c557a642f3933f4334455b95a9964bd71ca Mon Sep 17 00:00:00 2001 From: Dhananjay Nakrani Date: Sun, 11 May 2014 11:23:31 +0530 Subject: [PATCH 03/35] Add standard pma code for the library files. Add comments explaining file usage. Signed-off-by: Dhananjay Nakrani --- libraries/common_error_reporting.inc.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/libraries/common_error_reporting.inc.php b/libraries/common_error_reporting.inc.php index 8dd39bd8ac..869e2aebce 100644 --- a/libraries/common_error_reporting.inc.php +++ b/libraries/common_error_reporting.inc.php @@ -1,10 +1,16 @@ Date: Fri, 23 May 2014 23:31:29 +0530 Subject: [PATCH 04/35] Add another parameter to existing js error reporting code. Signed-off-by: Dhananjay Nakrani --- js/error_report.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/js/error_report.js b/js/error_report.js index 853a76cfed..a8e7da7dd1 100644 --- a/js/error_report.js +++ b/js/error_report.js @@ -23,7 +23,8 @@ var ErrorReport = { ajax_request: true, server: PMA_commonParams.get('server'), token: PMA_commonParams.get('token'), - get_settings: true + get_settings: true, + exception_type: 'js' }, function (data) { if (data.success !== true) { PMA_ajaxShowMessage(data.error, false); @@ -227,7 +228,8 @@ var ErrorReport = { "token": PMA_commonParams.get('token'), "exception": exception, "current_url": window.location.href, - "microhistory": ErrorReport._get_microhistory() + "microhistory": ErrorReport._get_microhistory(), + "exception_type": 'js' }; if (typeof AJAX.cache.pages[AJAX.cache.current - 1] !== 'undefined') { report_data.scripts = AJAX.cache.pages[AJAX.cache.current - 1].scripts.map( From e74cd6ec1d544a80e2183ff92ff69a070191854a Mon Sep 17 00:00:00 2001 From: Dhananjay Nakrani Date: Fri, 23 May 2014 23:56:07 +0530 Subject: [PATCH 05/35] Report errors based on user preference. All the cases taken care of. Signed-off-by: Dhananjay Nakrani --- error_report.php | 167 ++++++++++++++++------- libraries/Error_Handler.class.php | 42 +++++- libraries/Response.class.php | 3 + libraries/common_error_reporting.inc.php | 73 +++++----- libraries/error_report.lib.php | 84 ++++++++---- 5 files changed, 251 insertions(+), 118 deletions(-) diff --git a/error_report.php b/error_report.php index 7bc310f067..ec7161a7d0 100644 --- a/error_report.php +++ b/error_report.php @@ -10,63 +10,132 @@ require_once 'libraries/error_report.lib.php'; $response = PMA_Response::getInstance(); -if (isset($_REQUEST['send_error_report']) - && $_REQUEST['send_error_report'] == true -) { - $server_response = PMA_sendErrorReport(PMA_getReportData()); +if (isset($_REQUEST['exception_type']) + && $_REQUEST['exception_type'] == 'js' + ) { + if (isset($_REQUEST['send_error_report']) + && $_REQUEST['send_error_report'] == true + ) { + $server_response = PMA_sendErrorReport(PMA_getReportData()); - if ($server_response === false) { - $success = false; - } else { - $decoded_response = json_decode($server_response, true); - $success = !empty($decoded_response) ? $decoded_response["success"] : false; - } + if ($server_response === false) { + $success = false; + } else { + $decoded_response = json_decode($server_response, true); + $success = !empty($decoded_response) ? $decoded_response["success"] : false; + } - /* Message to show to the user */ - if ($success) { - if (isset($_REQUEST['automatic']) - && $_REQUEST['automatic'] === "true" - ) { + /* Message to show to the user */ + if ($success) { + if (isset($_REQUEST['automatic']) + && $_REQUEST['automatic'] === "true" + ) { + $message = __( + 'An error has been detected and an error report has been ' + . 'automatically submitted based on your settings.' + ); + } else { + $message = __('Thank you for submitting this report.'); + } + } else { $message = __( 'An error has been detected and an error report has been ' - . 'automatically submitted based on your settings.' + . 'generated but failed to be sent.' + ) + . ' ' + . __( + 'If you experience any ' + . 'problems please submit a bug report manually.' ); - } else { - $message = __('Thank you for submitting this report.'); } + $message .= ' ' . __('You may want to refresh the page.'); + + /* Create message object */ + if ($success) { + $message = PMA_Message::notice($message); + } else { + $message = PMA_Message::error($message); + } + + /* Add message to JSON response */ + $response->addJSON('message', $message); + + /* Persist always send settings */ + if (! isset($_REQUEST['automatic']) + && $_REQUEST['automatic'] !== "true" + && isset($_REQUEST['always_send']) + && $_REQUEST['always_send'] === "true" + ) { + PMA_persistOption("SendErrorReports", "always", "ask"); + } + } elseif (! empty($_REQUEST['get_settings'])) { + $response->addJSON('report_setting', $GLOBALS['cfg']['SendErrorReports']); } else { - $message = __( - 'An error has been detected and an error report has been ' - . 'generated but failed to be sent.' - ) - . ' ' - . __( - 'If you experience any ' - . 'problems please submit a bug report manually.' - ); + $response->addHTML(PMA_getErrorReportForm()); } - $message .= ' ' . __('You may want to refresh the page.'); +}elseif (isset($_REQUEST['exception_type']) + && $_REQUEST['exception_type'] == 'php' + ) { + if (isset($_REQUEST['send_error_report']) + && $_REQUEST['send_error_report'] == '1' + ) { + $reportData = PMA_getReportData('php'); + $server_response = PMA_sendErrorReport($reportData); + if ($server_response === false) { + $success = false; + } else { + $decoded_response = json_decode($server_response, true); + $success = !empty($decoded_response) ? $decoded_response["success"] : false; + } + + if($GLOBALS['cfg']['SendErrorReports'] == 'ask'){ + if($success) { + $errSubmitMsg = PMA_Message::error( + __('Thank You for subitting error report!!') + . __('Report has been succesfully submitted.') + ); + } else { + $errSubmitMsg = PMA_Message::error( + __('Thank You for subitting error report!!') + . '
' + . __(' Unfortunately submission failed.') + . '
' + . __(' If you experience any problems please submit a bug report manually.') + ); + } + } elseif($GLOBALS['cfg']['SendErrorReports'] == 'always') { + if($success) { + $errSubmitMsg = PMA_Message::error( + __( + 'An error has been detected on the server and an error report has been ' + . 'automatically submitted based on your settings.' + ) + ); + } else { + $errSubmitMsg = PMA_Message::error( + __( + 'An error has been detected and an error report has been ' + . 'generated but failed to be sent.' + ) + . '
' + . __('If you experience any problems please submit a bug report manually.') + ); + } + } - /* Create message object */ - if ($success) { - $message = PMA_Message::notice($message); - } else { - $message = PMA_Message::error($message); - } - - /* Add message to JSON response */ - $response->addJSON('message', $message); - - /* Persist always send settings */ - if (! isset($_REQUEST['automatic']) - && $_REQUEST['automatic'] !== "true" - && isset($_REQUEST['always_send']) - && $_REQUEST['always_send'] === "true" - ) { - PMA_persistOption("SendErrorReports", "always", "ask"); - } -} elseif (! empty($_REQUEST['get_settings'])) { - $response->addJSON('report_setting', $GLOBALS['cfg']['SendErrorReports']); + if($response->isAjax()) { + $response->addJSON('_errSubmitMsg',$errSubmitMsg); + } else { + $jsCode = 'PMA_ajaxShowMessage("
' + .$errSubmitMsg + .'
", false);'; + $response->getFooter()->getScripts()->addCode($jsCode); + } + } + // clear previous errors & save new ones. + $GLOBALS['error_handler']->savePreviousErrors(); } else { - $response->addHTML(PMA_getErrorReportForm()); + die('Oops, something went wrong!!'); } + +require_once 'libraries/common_error_reporting.inc.php'; \ No newline at end of file diff --git a/libraries/Error_Handler.class.php b/libraries/Error_Handler.class.php index 075a1516fd..b9d1bcb886 100644 --- a/libraries/Error_Handler.class.php +++ b/libraries/Error_Handler.class.php @@ -290,7 +290,10 @@ class PMA_Error_Handler public function getDispErrors() { $retval = ''; - if ($GLOBALS['cfg']['Error_Handler']['display']) { + // display errors if SendErrorReports is set to 'ask'. + if ($GLOBALS['cfg']['SendErrorReports'] != 'never' + || $GLOBALS['cfg']['Error_Handler']['display'] + ) { foreach ($this->getErrors() as $error) { if ($error instanceof PMA_Error) { if (! $error->isDisplayed()) { @@ -306,6 +309,27 @@ class PMA_Error_Handler } else { $retval .= $this->getDispUserErrors(); } + if($GLOBALS['cfg']['SendErrorReports'] == 'ask'){ + // add report button. + $retval .= '
' + . '' + . '' + . '' + . '' + . '
'; + + // add ignore buttons + $retval .=''; + $retval .=''; + } return $retval; } @@ -398,7 +422,9 @@ class PMA_Error_Handler */ public function countDisplayErrors() { - if ($GLOBALS['cfg']['Error_Handler']['display']) { + if ($GLOBALS['cfg']['SendErrorReports'] != 'never' + || $GLOBALS['cfg']['Error_Handler']['display'] + ) { return $this->countErrors(); } else { return $this->countUserErrors(); @@ -414,5 +440,17 @@ class PMA_Error_Handler { return (bool) $this->countDisplayErrors(); } + + /** + * Deletes prevsiously stored errors in SESSION. + * Saves current errors in session as previous errros. + * Required to save current errors in case 'ask' + * + */ + public function savePreviousErrors() + { + unset($_SESSION['prev_errors']); + $_SESSION['prev_errors'] = $GLOBALS['error_handler']->getCurrentErrors(); + } } ?> diff --git a/libraries/Response.class.php b/libraries/Response.class.php index 45a4fd2c98..3c43c23251 100644 --- a/libraries/Response.class.php +++ b/libraries/Response.class.php @@ -316,6 +316,9 @@ class PMA_Response if (strlen($errors)) { $this->addJSON('_errors', $errors); } + $promptPhpErrors = ($GLOBALS['cfg']['SendErrorReports'] != 'never' || $GLOBALS['cfg']['Error_Handler']['display']); + $this->addJSON('_promptPhpErrors', $promptPhpErrors); + if (empty($GLOBALS['error_message'])) { // set current db, table and sql query in the querywindow $query = ''; diff --git a/libraries/common_error_reporting.inc.php b/libraries/common_error_reporting.inc.php index 869e2aebce..0227ae74d1 100644 --- a/libraries/common_error_reporting.inc.php +++ b/libraries/common_error_reporting.inc.php @@ -13,50 +13,43 @@ if (! defined('PHPMYADMIN')) { exit; } -/** if there were any errors currently write them to a log file. - * Later it will be changed to submit them to the error reporting server. +/** + * if there were any errors then take appropriate actions based on user preferences. */ if($GLOBALS['error_handler']->hasErrors()) { - // then log them in a local file. - $path = "./pma_error_log.txt"; - $fp = fopen($path, "w"); + // Delete all the prev_errors in session & store new prev_errors in session + $GLOBALS['error_handler']->savePreviousErrors(); - // for each errors in the list - foreach($GLOBALS['error_handler']->getCurrentErrors() as $errObj ) { - /** - * Following check is to avoid error reported by PMA_warnMissingExtension(); - * - */ - if ($errObj->getLine() && $errObj->getType()) { - $str = "\n\n".$errObj->getFile() . "(#" . $errObj->getLine() . ")\n\t". $errObj->getTitle(); - // for stack trace - // ------------------------------------------------------------------------------------------ - $backtrace = $errObj->getBacktrace(); - $error_str= ""; - foreach($backtrace as $i=>$stack_frame) - { - $error_str .= "\n \t\t\t Frame[".$i."]: \tfile:".$stack_frame["file"]."\tline:".$stack_frame["line"]."\tfunction:".$stack_frame["function"]."("; - foreach($stack_frame["args"] as $j=>$arg) - { - if($j != 0) - { - $error_str .= ", "; - } + if($GLOBALS['cfg']['SendErrorReports'] == 'always'){ + //send the error reports directly + + $_REQUEST['exception_type'] = 'php'; + $_REQUEST['send_error_report'] = '1'; + require_once('error_report.php'); + + // The errors are already sent. Just focus on errors division upon load event. + $jsCode = '$("html, body").animate({scrollTop:$(document).height()}, "slow");'; + $response = PMA_Response::getInstance(); + $response->getFooter()->getScripts()->addCode($jsCode); + } + elseif($GLOBALS['cfg']['SendErrorReports'] == 'ask') { + //ask user whether to submit errors or not. + if($response->isAjax()) { + // Send the errors in '_error' param. That is Already done in PMA_Response::_ajaxResponse(). + } + else { + // The errors are already sent. Just focus on errors division upon load event. + $jsCode = 'PMA_ajaxShowMessage(PMA_messages["phpErrorsFound"], 2000);' + . '$("html, body").animate({scrollTop:$(document).height()}, "slow");'; + + $response = PMA_Response::getInstance(); + $response->getFooter()->getScripts()->addCode($jsCode); + } + + } + else { + //$GLOBALS['cfg']['SendErrorReports'] set to 'never'. Do not submit error reports. - $error_str .= "arg[".$j."] = ".$arg; - } - $error_str .= ")"; - - if($i >= 5) // MAX 5 of stack frames. - { - break; - } - } - // ------------------------------------------------------------------------------------------ - $retVal = fwrite ($fp , $str); - $retVal = fwrite ($fp , $error_str); - } } - fclose($fp); } ?> diff --git a/libraries/error_report.lib.php b/libraries/error_report.lib.php index 0df479c8fe..e1bc0d4c6e 100644 --- a/libraries/error_report.lib.php +++ b/libraries/error_report.lib.php @@ -27,7 +27,8 @@ if (is_readable('js/line_counts.php')) { /** * the url where to submit reports to */ -define('SUBMISSION_URL', "http://reports.phpmyadmin.net/incidents/create"); +// define('SUBMISSION_URL', "http://reports.phpmyadmin.net/incidents/create"); +define('SUBMISSION_URL', "http://127.0.0.1/error-reporting-server/incidents/create"); /** * returns the pretty printed error report data collected from the @@ -54,35 +55,64 @@ function PMA_getPrettyReportData() * * @return Array the report */ -function PMA_getReportData() +function PMA_getReportData($exception_type = 'js') { - if (empty($_REQUEST['exception'])) { - return array(); - } - $exception = $_REQUEST['exception']; - $exception["stack"] = PMA_translateStacktrace($exception["stack"]); - List($uri, $script_name) = PMA_sanitizeUrl($exception["url"]); - $exception["uri"] = $uri; - unset($exception["url"]); + // common params for both, php & js execptions $report = array( - "exception" => $exception, - "script_name" => $script_name, - "pma_version" => PMA_VERSION, - "browser_name" => PMA_USR_BROWSER_AGENT, - "browser_version" => PMA_USR_BROWSER_VER, - "user_os" => PMA_USR_OS, - "server_software" => $_SERVER['SERVER_SOFTWARE'], - "user_agent_string" => $_SERVER['HTTP_USER_AGENT'], - "locale" => $_COOKIE['pma_lang'], - "configuration_storage" => - empty($GLOBALS['cfg']['Servers'][1]['pmadb']) ? "disabled" : - "enabled", - "php_version" => phpversion(), - "microhistory" => $_REQUEST['microhistory'], - ); + "pma_version" => PMA_VERSION, + "browser_name" => PMA_USR_BROWSER_AGENT, + "browser_version" => PMA_USR_BROWSER_VER, + "user_os" => PMA_USR_OS, + "server_software" => $_SERVER['SERVER_SOFTWARE'], + "user_agent_string" => $_SERVER['HTTP_USER_AGENT'], + "locale" => $_COOKIE['pma_lang'], + "configuration_storage" => + empty($GLOBALS['cfg']['Servers'][1]['pmadb']) ? "disabled" : + "enabled", + "php_version" => phpversion() + ); - if (! empty($_REQUEST['description'])) { - $report['steps'] = $_REQUEST['description']; + if($exception_type == 'js') { + if (empty($_REQUEST['exception'])) { + return ''; + } + $exception = $_REQUEST['exception']; + $exception["stack"] = PMA_translateStacktrace($exception["stack"]); + List($uri, $script_name) = PMA_sanitizeUrl($exception["url"]); + $exception["uri"] = $uri; + unset($exception["url"]); + + $report ["exception_type"] = 'js'; + $report ["exception"] = $exception; + $report ["script_name"] = $script_name; + $report ["microhistory"] = $_REQUEST['microhistory']; + ); + + if (! empty($_REQUEST['description'])) { + $report['steps'] = $_REQUEST['description']; + } + } + elseif($exception_type == 'php'){ + $errors = array(); + // create php error report + $i=0; + foreach($_SESSION['prev_errors'] as $errorObj ) { + if ($errorObj->getLine() && $errorObj->getType() && $errorObj->getNumber() != E_USER_WARNING) { + $errors[$i++] = array( + "lineNum" => $errorObj->getLine(), + "file" => $errorObj->getFile(), + "type" => $errorObj->getType(), + "msg" => $errorObj->getMessage(), + "stackTrace" => $errorObj->getBacktraceDisplay(5) + ); + + } + } + $report ["exception_type"] = 'php'; + $report["errors"] = $errors; + } + else{ + return false; } return $report; From 026209d51b7f5560e882edc20f3b671d94990f7b Mon Sep 17 00:00:00 2001 From: Dhananjay Nakrani Date: Fri, 23 May 2014 23:57:09 +0530 Subject: [PATCH 06/35] Add appropriate msgs & js functions to handle user actions. Signed-off-by: Dhananjay Nakrani --- js/ajax.js | 11 +++++++++++ js/functions.js | 26 ++++++++++++++++++++++++++ js/messages.php | 12 ++++++++++++ 3 files changed, 49 insertions(+) diff --git a/js/ajax.js b/js/ajax.js index cb41d2ed6d..005b32b334 100644 --- a/js/ajax.js +++ b/js/ajax.js @@ -388,11 +388,22 @@ var AJAX = { } $('#pma_errors').remove(); + + var msg = ''; + if(data._errSubmitMsg){ + msg = data._errSubmitMsg; + } if (data._errors) { $('
', {id : 'pma_errors'}) .insertAfter('#selflink') .append(data._errors); + if(data._promptPhpErrors){ + msg = msg + PMA_messages['phpErrorsFound']; + // scroll to bottom where all the erros are displayed. + $('html, body').animate({scrollTop:$(document).height()}, 'slow'); + } } + PMA_ajaxShowMessage(msg, false); if (typeof AJAX._callback === 'function') { AJAX._callback.call(); diff --git a/js/functions.js b/js/functions.js index 000704fee6..c5e8975d44 100644 --- a/js/functions.js +++ b/js/functions.js @@ -4379,3 +4379,29 @@ function PMA_previewSQL($form) } }); } + +/** + * Ignore the displayed php errors. + * Simply removes the displayed errors. + * + * @param clearPrevErrors whether to clear errors stored + * in $_SESSION['prev_errors'] at server + * + */ +function PMA_ignorePhpErrors(clearPrevErrors){ + if (typeof(clearPrevErrors) === "undefined" + || clearPrevErrors === null + ) { + str = false; + } + // send AJAX request to error_report.php with send_error_report=0, exception_type=php & token. + // It clears the prev_errors stored in session. + if(clearPrevErrors){ + $('#pma_report_errors_form input[name="send_error_report"]').val(0); // change send_error_report to '0' + $('#pma_report_errors_form').submit(); + } + + // remove dislayed errors + $('#pma_errors').fadeOut( "slow"); + $('#pma_errors').remove(); +} diff --git a/js/messages.php b/js/messages.php index 1f3c1edb85..1d284696bc 100644 --- a/js/messages.php +++ b/js/messages.php @@ -426,6 +426,18 @@ $js_messages['strTooManyInputs'] = __( . "max_input_vars configuration." ); +$js_messages['phpErrorsFound'] = '
' + . __('Warning: Some errors have been detected on the server!!') + . '
' + . __('Please look at the bottom of this window.') + . '' + . '' + . '
'; + echo "var PMA_messages = new Array();\n"; foreach ($js_messages as $name => $js_message) { PMA_printJsValue("PMA_messages['" . $name . "']", $js_message); From 43e1aa5ce218312da1da385427b9d76f2058c980 Mon Sep 17 00:00:00 2001 From: Dhananjay Nakrani Date: Sat, 24 May 2014 10:28:06 +0530 Subject: [PATCH 07/35] Fix Syntax errors. Signed-off-by: Dhananjay Nakrani --- libraries/error_report.lib.php | 1 - 1 file changed, 1 deletion(-) diff --git a/libraries/error_report.lib.php b/libraries/error_report.lib.php index e1bc0d4c6e..5b1a390faf 100644 --- a/libraries/error_report.lib.php +++ b/libraries/error_report.lib.php @@ -86,7 +86,6 @@ function PMA_getReportData($exception_type = 'js') $report ["exception"] = $exception; $report ["script_name"] = $script_name; $report ["microhistory"] = $_REQUEST['microhistory']; - ); if (! empty($_REQUEST['description'])) { $report['steps'] = $_REQUEST['description']; From 7b8006651bd1a6bdc72cf58ca61bbb238ba26c6b Mon Sep 17 00:00:00 2001 From: Dhananjay Nakrani Date: Mon, 26 May 2014 03:35:14 +0530 Subject: [PATCH 08/35] Make "Ignore All" button work on login page. Signed-off-by: Dhananjay Nakrani --- libraries/plugins/auth/AuthenticationCookie.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/plugins/auth/AuthenticationCookie.class.php b/libraries/plugins/auth/AuthenticationCookie.class.php index 0f2a883dac..96771075a0 100644 --- a/libraries/plugins/auth/AuthenticationCookie.class.php +++ b/libraries/plugins/auth/AuthenticationCookie.class.php @@ -284,7 +284,7 @@ class AuthenticationCookie extends AuthenticationPlugin // END Swekey Integration if ($GLOBALS['error_handler']->hasDisplayErrors()) { - echo '
'; + echo '
'; $GLOBALS['error_handler']->dispErrors(); echo '
'; } From 3d72f549182abcfa34752e2467ef159590212875 Mon Sep 17 00:00:00 2001 From: Dhananjay Nakrani Date: Mon, 26 May 2014 11:26:40 +0530 Subject: [PATCH 09/35] Remove unnecessary file. Signed-off-by: Dhananjay Nakrani --- pma_error_log.txt | 62 ----------------------------------------------- 1 file changed, 62 deletions(-) delete mode 100755 pma_error_log.txt diff --git a/pma_error_log.txt b/pma_error_log.txt deleted file mode 100755 index 6b53729d46..0000000000 --- a/pma_error_log.txt +++ /dev/null @@ -1,62 +0,0 @@ - - -./libraries/Config.class.php(#1185) - Warning: fileperms(): stat failed for ./config.inc.php - Frame[0]: file:/var/www/phpmyadmin/libraries/Config.class.php line:1185 function:fileperms(arg[0] = ./config.inc.php) - Frame[1]: file:/var/www/phpmyadmin/libraries/common.inc.php line:580 function:checkPermissions() - Frame[2]: file:/var/www/phpmyadmin/index.php line:12 function:require_once(arg[0] = /var/www/phpmyadmin/libraries/common.inc.php) - -./index.php(#497) - User Warning: The configuration file now needs a secret passphrase (blowfish_secret). - Frame[0]: file:/var/www/phpmyadmin/index.php line:497 function:trigger_error(arg[0] = The configuration file now needs a secret passphrase (blowfish_secret)., arg[1] = 512) - -./index.php(#666) - Notice: Undefined variable: sdh - -./libraries/Config.class.php(#1185) - Warning: fileperms(): stat failed for ./config.inc.php - Frame[0]: file:/var/www/phpmyadmin/libraries/Config.class.php line:1185 function:fileperms(arg[0] = ./config.inc.php) - Frame[1]: file:/var/www/phpmyadmin/libraries/common.inc.php line:580 function:checkPermissions() - Frame[2]: file:/var/www/phpmyadmin/index.php line:12 function:require_once(arg[0] = /var/www/phpmyadmin/libraries/common.inc.php) - -./libraries/Config.class.php(#1185) - Warning: fileperms(): stat failed for ./config.inc.php - Frame[0]: file:/var/www/phpmyadmin/libraries/Config.class.php line:1185 function:fileperms(arg[0] = ./config.inc.php) - Frame[1]: file:/var/www/phpmyadmin/libraries/common.inc.php line:580 function:checkPermissions() - Frame[2]: file:/var/www/phpmyadmin/index.php line:12 function:require_once(arg[0] = /var/www/phpmyadmin/libraries/common.inc.php) - -./libraries/Config.class.php(#1185) - Warning: fileperms(): stat failed for ./config.inc.php - Frame[0]: file:/var/www/phpmyadmin/libraries/Config.class.php line:1185 function:fileperms(arg[0] = ./config.inc.php) - Frame[1]: file:/var/www/phpmyadmin/libraries/common.inc.php line:580 function:checkPermissions() - Frame[2]: file:/var/www/phpmyadmin/index.php line:12 function:require_once(arg[0] = /var/www/phpmyadmin/libraries/common.inc.php) - -./libraries/Config.class.php(#1185) - Warning: fileperms(): stat failed for ./config.inc.php - Frame[0]: file:/var/www/phpmyadmin/libraries/Config.class.php line:1185 function:fileperms(arg[0] = ./config.inc.php) - Frame[1]: file:/var/www/phpmyadmin/libraries/common.inc.php line:580 function:checkPermissions() - Frame[2]: file:/var/www/phpmyadmin/index.php line:12 function:require_once(arg[0] = /var/www/phpmyadmin/libraries/common.inc.php) - -./libraries/Config.class.php(#1185) - Warning: fileperms(): stat failed for ./config.inc.php - Frame[0]: file:/var/www/phpmyadmin/libraries/Config.class.php line:1185 function:fileperms(arg[0] = ./config.inc.php) - Frame[1]: file:/var/www/phpmyadmin/libraries/common.inc.php line:580 function:checkPermissions() - Frame[2]: file:/var/www/phpmyadmin/index.php line:12 function:require_once(arg[0] = /var/www/phpmyadmin/libraries/common.inc.php) - -./libraries/Config.class.php(#1185) - Warning: fileperms(): stat failed for ./config.inc.php - Frame[0]: file:/var/www/phpmyadmin/libraries/Config.class.php line:1185 function:fileperms(arg[0] = ./config.inc.php) - Frame[1]: file:/var/www/phpmyadmin/libraries/common.inc.php line:580 function:checkPermissions() - Frame[2]: file:/var/www/phpmyadmin/index.php line:12 function:require_once(arg[0] = /var/www/phpmyadmin/libraries/common.inc.php) - -./libraries/Config.class.php(#1185) - Warning: fileperms(): stat failed for ./config.inc.php - Frame[0]: file:/var/www/phpmyadmin/libraries/Config.class.php line:1185 function:fileperms(arg[0] = ./config.inc.php) - Frame[1]: file:/var/www/phpmyadmin/libraries/common.inc.php line:580 function:checkPermissions() - Frame[2]: file:/var/www/phpmyadmin/index.php line:12 function:require_once(arg[0] = /var/www/phpmyadmin/libraries/common.inc.php) - -./libraries/Config.class.php(#1185) - Warning: fileperms(): stat failed for ./config.inc.php - Frame[0]: file:/var/www/phpmyadmin/libraries/Config.class.php line:1185 function:fileperms(arg[0] = ./config.inc.php) - Frame[1]: file:/var/www/phpmyadmin/libraries/common.inc.php line:580 function:checkPermissions() - Frame[2]: file:/var/www/phpmyadmin/index.php line:12 function:require_once(arg[0] = /var/www/phpmyadmin/libraries/common.inc.php) \ No newline at end of file From 1ba7140be587a1d2f660441f0a7e8fbec746e644 Mon Sep 17 00:00:00 2001 From: Dhananjay Nakrani Date: Tue, 27 May 2014 23:43:42 +0530 Subject: [PATCH 10/35] Send only(without HTML) error message string. Signed-off-by: Dhananjay Nakrani --- libraries/Message.class.php | 10 ++++++++++ libraries/error_report.lib.php | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/libraries/Message.class.php b/libraries/Message.class.php index 4132faa555..b95b2e6b0f 100644 --- a/libraries/Message.class.php +++ b/libraries/Message.class.php @@ -655,6 +655,16 @@ class PMA_Message return $message; } + /** + * Returns only message string without image & other HTML. + * @return: $message string + */ + public function getOnlyMessage() + { + return $this->message; + } + + /** * returns PMA_Message::$string * diff --git a/libraries/error_report.lib.php b/libraries/error_report.lib.php index 5b1a390faf..0920c0dfeb 100644 --- a/libraries/error_report.lib.php +++ b/libraries/error_report.lib.php @@ -101,7 +101,7 @@ function PMA_getReportData($exception_type = 'js') "lineNum" => $errorObj->getLine(), "file" => $errorObj->getFile(), "type" => $errorObj->getType(), - "msg" => $errorObj->getMessage(), + "msg" => $errorObj->getOnlyMessage(), "stackTrace" => $errorObj->getBacktraceDisplay(5) ); From 6d04bc17bc8d44a06de7cf4d10243b5424d0a310 Mon Sep 17 00:00:00 2001 From: Dhananjay Nakrani Date: Wed, 28 May 2014 09:28:51 +0530 Subject: [PATCH 11/35] Send only backtrace (not displayBacktrace). Change getBacktrace to return first 'X' frames. Send stackhash too. Signed-off-by: Dhananjay Nakrani --- libraries/Error.class.php | 10 +++++++--- libraries/error_report.lib.php | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/libraries/Error.class.php b/libraries/Error.class.php index fd4a2fc83c..4c943f0d28 100644 --- a/libraries/Error.class.php +++ b/libraries/Error.class.php @@ -188,12 +188,16 @@ class PMA_Error extends PMA_Message } /** - * returns PMA_Error::$_backtrace - * + * returns PMA_Error::$_backtrace for first $count frames + * pass $count = -1 to get full backtrace. The same can be done by not passing $count at all. * @return array PMA_Error::$_backtrace */ - public function getBacktrace() + public function getBacktrace($count = -1) { + if($count != -1) { + return array_slice($this->backtrace, 0, $count); + + } return $this->backtrace; } diff --git a/libraries/error_report.lib.php b/libraries/error_report.lib.php index 0920c0dfeb..001e4d04b2 100644 --- a/libraries/error_report.lib.php +++ b/libraries/error_report.lib.php @@ -102,7 +102,8 @@ function PMA_getReportData($exception_type = 'js') "file" => $errorObj->getFile(), "type" => $errorObj->getType(), "msg" => $errorObj->getOnlyMessage(), - "stackTrace" => $errorObj->getBacktraceDisplay(5) + "stackTrace" => $errorObj->getBacktrace(5), + "stackhash" => $errorObj->getHash() ); } From 7393745b680f86c1b64d0fc7d0286269ddc53292 Mon Sep 17 00:00:00 2001 From: Dhananjay Nakrani Date: Tue, 3 Jun 2014 09:31:45 +0530 Subject: [PATCH 12/35] Fix failing existing PHPUnit tests. Signed-off-by: Dhananjay Nakrani --- test/classes/PMA_Error_Handler_test.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/classes/PMA_Error_Handler_test.php b/test/classes/PMA_Error_Handler_test.php index 9a271c7737..1dac61d4c1 100644 --- a/test/classes/PMA_Error_Handler_test.php +++ b/test/classes/PMA_Error_Handler_test.php @@ -107,7 +107,7 @@ class PMA_Error_Handler_Test extends PHPUnit_Framework_TestCase * @param string $output_show expected output if showing of errors is * enabled * @param string $output_hide expected output if showing of errors is - * disabled + * disabled and 'sendErrorReports' is set to 'never' * * @return void * @@ -116,6 +116,8 @@ class PMA_Error_Handler_Test extends PHPUnit_Framework_TestCase public function testGetDispErrorsForDisplayFalse( $errno, $errstr, $errfile, $errline, $output_show, $output_hide ) { + // TODO: Add other test cases for all combination of 'sendErrorReports' + $GLOBALS['cfg']['SendErrorReports'] = 'never'; $GLOBALS['cfg']['Error_Handler']['gather'] = true; $GLOBALS['cfg']['Error_Handler']['display'] = false; From ed564f4d6324e404e0e67a1964bc6f1376ddd2bd Mon Sep 17 00:00:00 2001 From: Dhananjay Nakrani Date: Tue, 3 Jun 2014 22:24:46 +0530 Subject: [PATCH 13/35] Remove unnecessary code. A deliberate error & local error-reporting-server URL. Signed-off-by: Dhananjay Nakrani --- index.php | 3 --- libraries/error_report.lib.php | 3 +-- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/index.php b/index.php index c533e7a33a..3714066f2d 100644 --- a/index.php +++ b/index.php @@ -663,9 +663,6 @@ function PMA_printListItem($name, $listId = null, $url = null, echo ''; } -echo $sdh; require_once 'libraries/common_error_reporting.inc.php'; - - ?> diff --git a/libraries/error_report.lib.php b/libraries/error_report.lib.php index 001e4d04b2..4f5fd06904 100644 --- a/libraries/error_report.lib.php +++ b/libraries/error_report.lib.php @@ -27,8 +27,7 @@ if (is_readable('js/line_counts.php')) { /** * the url where to submit reports to */ -// define('SUBMISSION_URL', "http://reports.phpmyadmin.net/incidents/create"); -define('SUBMISSION_URL', "http://127.0.0.1/error-reporting-server/incidents/create"); +define('SUBMISSION_URL', "http://reports.phpmyadmin.net/incidents/create"); /** * returns the pretty printed error report data collected from the From d4bddddd93e22274b49d2ea1e0687af32dfc0225 Mon Sep 17 00:00:00 2001 From: Dhananjay Nakrani Date: Tue, 3 Jun 2014 22:50:57 +0530 Subject: [PATCH 14/35] Improve Error Message. Signed-off-by: Dhananjay Nakrani --- error_report.php | 1 + 1 file changed, 1 insertion(+) diff --git a/error_report.php b/error_report.php index ec7161a7d0..c5c05c02ff 100644 --- a/error_report.php +++ b/error_report.php @@ -92,6 +92,7 @@ if (isset($_REQUEST['exception_type']) if($success) { $errSubmitMsg = PMA_Message::error( __('Thank You for subitting error report!!') + . '
' . __('Report has been succesfully submitted.') ); } else { From e9d5523795ef1964b1bc0573e66374ade29b610f Mon Sep 17 00:00:00 2001 From: Dhananjay Nakrani Date: Tue, 3 Jun 2014 23:39:56 +0530 Subject: [PATCH 15/35] Include error reporting script at the end of all the 'relevant' scripts. Signed-off-by: Dhananjay Nakrani --- browse_foreigners.php | 5 +++++ chk_rel.php | 4 ++++ db_create.php | 5 +++++ db_datadict.php | 4 ++++ db_events.php | 4 ++++ db_export.php | 4 ++++ db_import.php | 4 ++++ db_operations.php | 4 ++++ db_printview.php | 5 +++++ db_qbe.php | 5 +++++ db_routines.php | 4 ++++ db_search.php | 5 +++++ db_sql.php | 4 ++++ db_structure.php | 4 ++++ db_tracking.php | 4 ++++ db_triggers.php | 4 ++++ error_report.php | 6 +++++- export.php | 5 +++++ file_echo.php | 5 +++++ gis_data_editor.php | 5 +++++ import.php | 5 +++++ import_status.php | 5 +++++ index.php | 3 +++ navigation.php | 5 +++++ phpinfo.php | 5 +++++ pmd_display_field.php | 5 +++++ pmd_general.php | 5 +++++ pmd_pdf.php | 5 +++++ pmd_relation_new.php | 5 +++++ pmd_relation_upd.php | 4 ++++ pmd_save_pos.php | 5 +++++ prefs_forms.php | 5 +++++ prefs_manage.php | 7 +++++++ querywindow.php | 7 +++++++ schema_edit.php | 4 ++++ schema_export.php | 7 +++++++ server_binlog.php | 5 +++++ server_collations.php | 5 +++++ server_databases.php | 4 ++++ server_engines.php | 5 +++++ server_export.php | 4 ++++ server_import.php | 4 ++++ server_plugins.php | 5 +++++ server_privileges.php | 4 ++++ server_replication.php | 5 +++++ server_sql.php | 4 ++++ server_status.php | 5 +++++ server_status_advisor.php | 8 ++++++-- server_status_monitor.php | 6 ++++++ server_status_queries.php | 6 ++++++ server_status_variables.php | 5 +++++ server_user_groups.php | 5 +++++ server_variables.php | 5 +++++ sql.php | 4 ++++ tbl_addfield.php | 5 +++++ tbl_change.php | 5 +++++ tbl_chart.php | 5 +++++ tbl_create.php | 5 +++++ tbl_export.php | 5 +++++ tbl_find_replace.php | 5 +++++ tbl_get_field.php | 5 +++++ tbl_gis_visualization.php | 4 ++++ tbl_import.php | 4 ++++ tbl_indexes.php | 5 +++++ tbl_move_copy.php | 5 +++++ tbl_operations.php | 4 ++++ tbl_printview.php | 5 +++++ tbl_relation.php | 5 +++++ tbl_replace.php | 6 ++++++ tbl_row_action.php | 5 +++++ tbl_select.php | 5 +++++ tbl_sql.php | 4 ++++ tbl_structure.php | 5 +++++ tbl_tracking.php | 4 ++++ tbl_zoom_select.php | 5 +++++ themes.php | 4 ++++ transformation_overview.php | 7 +++++++ transformation_wrapper.php | 5 +++++ url.php | 6 ++++++ user_password.php | 5 +++++ view_create.php | 7 +++++++ view_operations.php | 6 ++++++ 82 files changed, 399 insertions(+), 3 deletions(-) diff --git a/browse_foreigners.php b/browse_foreigners.php index daeaf47efe..acb725bac1 100644 --- a/browse_foreigners.php +++ b/browse_foreigners.php @@ -58,4 +58,9 @@ $html = PMA_getHtmlForRelationalFieldSelection( ); $response->addHtml($html); + +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/chk_rel.php b/chk_rel.php index 915e8b24b4..bb211692cb 100644 --- a/chk_rel.php +++ b/chk_rel.php @@ -12,4 +12,8 @@ $response->addHTML( PMA_getRelationsParamDiagnostic(PMA_getRelationsParam()) ); +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/db_create.php b/db_create.php index 85443a466e..c82fcfac66 100644 --- a/db_create.php +++ b/db_create.php @@ -133,4 +133,9 @@ if (! $result) { include_once '' . $cfg['DefaultTabDatabase']; } } + +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/db_datadict.php b/db_datadict.php index 43d4c154c7..e59cb73fe7 100644 --- a/db_datadict.php +++ b/db_datadict.php @@ -254,4 +254,8 @@ foreach ($tables as $table) { */ echo PMA_Util::getButton(); +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/db_events.php b/db_events.php index 917778bc35..8a3a1e039f 100644 --- a/db_events.php +++ b/db_events.php @@ -23,4 +23,8 @@ require_once 'libraries/rte/rte_events.lib.php'; $_PMA_RTE = 'EVN'; require_once 'libraries/rte/rte_main.inc.php'; +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/db_export.php b/db_export.php index 5313e0e022..12c9669d9f 100644 --- a/db_export.php +++ b/db_export.php @@ -91,4 +91,8 @@ $multi_values .= '
'; $export_type = 'database'; require_once 'libraries/display_export.inc.php'; +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/db_import.php b/db_import.php index 70425b2183..ab0793d5c9 100644 --- a/db_import.php +++ b/db_import.php @@ -22,4 +22,8 @@ require 'libraries/db_info.inc.php'; $import_type = 'database'; require 'libraries/display_import.inc.php'; +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/db_operations.php b/db_operations.php index eec625bd5f..1facee9a2b 100644 --- a/db_operations.php +++ b/db_operations.php @@ -297,4 +297,8 @@ if ($cfgRelation['pdfwork'] && $num_tables > 0) { $response->addHTML(PMA_getHtmlForExportRelationalSchemaView($url_query)); } // end if +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/db_printview.php b/db_printview.php index 137bdaaf78..e359ad2a3d 100644 --- a/db_printview.php +++ b/db_printview.php @@ -177,4 +177,9 @@ if ($num_tables == 0) { echo PMA_Util::getButton(); echo "
\n"; + +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/db_qbe.php b/db_qbe.php index 641bed304c..2589ee1444 100644 --- a/db_qbe.php +++ b/db_qbe.php @@ -130,4 +130,9 @@ if ($cfgRelation['designerwork']) { } $response->addHTML($db_qbe->getSelectionForm($cfgRelation)); + +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/db_routines.php b/db_routines.php index a58d4c0a21..904cd55d3f 100644 --- a/db_routines.php +++ b/db_routines.php @@ -24,4 +24,8 @@ require_once 'libraries/rte/rte_routines.lib.php'; $_PMA_RTE = 'RTN'; require_once 'libraries/rte/rte_main.inc.php'; +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/db_search.php b/db_search.php index 364ff521f6..5fbb1cb208 100644 --- a/db_search.php +++ b/db_search.php @@ -60,4 +60,9 @@ $response->addHTML( ); $response->addHTML($db_search->getSelectionForm()); $response->addHTML($db_search->getResultDivs()); + +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/db_sql.php b/db_sql.php index 67bbbb59d6..1f25b6be58 100644 --- a/db_sql.php +++ b/db_sql.php @@ -41,4 +41,8 @@ $response->addHTML( ) ); +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/db_structure.php b/db_structure.php index 7b6eedb6f4..226e47fb5b 100644 --- a/db_structure.php +++ b/db_structure.php @@ -349,4 +349,8 @@ if (empty($db_is_system_schema)) { $response->addHTML($content); } // end if (Create Table dialog) +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/db_tracking.php b/db_tracking.php index e5fe7111d4..3013bb05d9 100644 --- a/db_tracking.php +++ b/db_tracking.php @@ -251,4 +251,8 @@ if (count($data['ddlog']) > 0) { echo PMA_Util::getMessage(__('Database Log'), $log); } +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/db_triggers.php b/db_triggers.php index d1a2a8c6b2..98f8c4f251 100644 --- a/db_triggers.php +++ b/db_triggers.php @@ -22,4 +22,8 @@ require_once 'libraries/rte/rte_triggers.lib.php'; $_PMA_RTE = 'TRI'; require_once 'libraries/rte/rte_main.inc.php'; +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/error_report.php b/error_report.php index c5c05c02ff..91dd8c3820 100644 --- a/error_report.php +++ b/error_report.php @@ -139,4 +139,8 @@ if (isset($_REQUEST['exception_type']) die('Oops, something went wrong!!'); } -require_once 'libraries/common_error_reporting.inc.php'; \ No newline at end of file +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; +?> diff --git a/export.php b/export.php index 215d494032..e7777e9862 100644 --- a/export.php +++ b/export.php @@ -438,5 +438,10 @@ if (!defined('TESTSUITE')) { } else { echo PMA_getHtmlForDisplayedExportFooter($back_button); } // end if + + /** + * Include error reporting script. + */ + require_once 'libraries/common_error_reporting.inc.php'; } ?> diff --git a/file_echo.php b/file_echo.php index d910b74e28..7d9d0d99d2 100644 --- a/file_echo.php +++ b/file_echo.php @@ -68,4 +68,9 @@ if (isset($_REQUEST['filename']) && isset($_REQUEST['image'])) { } echo file_get_contents($_FILES['file']['tmp_name']); } + +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/gis_data_editor.php b/gis_data_editor.php index 546f700fb7..109b61aef8 100644 --- a/gis_data_editor.php +++ b/gis_data_editor.php @@ -421,4 +421,9 @@ echo ''; PMA_Response::getInstance()->addJSON('gis_editor', ob_get_contents()); ob_end_clean(); + +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/import.php b/import.php index a96b159a83..01adde2a4e 100644 --- a/import.php +++ b/import.php @@ -669,4 +669,9 @@ if ($go_sql) { $active_page = $goto; include '' . $goto; } + +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/import_status.php b/import_status.php index 45e11fcd31..13b841cf5d 100644 --- a/import_status.php +++ b/import_status.php @@ -98,4 +98,9 @@ if (isset($_GET["message"]) && $_GET["message"]) { } else { PMA_importAjaxStatus($_GET["id"]); } + +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/index.php b/index.php index 3714066f2d..1c1683be03 100644 --- a/index.php +++ b/index.php @@ -664,5 +664,8 @@ function PMA_printListItem($name, $listId = null, $url = null, } +/** + * Include error reporting script. + */ require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/navigation.php b/navigation.php index 2c35311e50..c3f9337682 100644 --- a/navigation.php +++ b/navigation.php @@ -68,4 +68,9 @@ if ($cfgRelation['navwork']) { // Do the magic $response->addJSON('message', $navigation->getDisplay()); + +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/phpinfo.php b/phpinfo.php index 5854ff4c9e..680868387d 100644 --- a/phpinfo.php +++ b/phpinfo.php @@ -18,4 +18,9 @@ PMA_Response::getInstance()->disable(); if ($GLOBALS['cfg']['ShowPhpInfo']) { phpinfo(); } + +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/pmd_display_field.php b/pmd_display_field.php index 8efe96f057..25eda516cb 100644 --- a/pmd_display_field.php +++ b/pmd_display_field.php @@ -56,6 +56,11 @@ if ($cfgRelation['displaywork']) { } } // end if +/** + * Include error reporting script. Include before it "dies". + */ +require_once 'libraries/common_error_reporting.inc.php'; + header("Content-Type: text/xml; charset=utf-8"); header("Cache-Control: no-cache"); die("' . '
'; + +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/pmd_pdf.php b/pmd_pdf.php index 11982528c0..17d5da68d4 100644 --- a/pmd_pdf.php +++ b/pmd_pdf.php @@ -156,4 +156,9 @@ echo ''; echo '
'; echo ''; echo ''; + +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/pmd_relation_new.php b/pmd_relation_new.php index 134450b445..0b9e5bd361 100644 --- a/pmd_relation_new.php +++ b/pmd_relation_new.php @@ -130,4 +130,9 @@ function PMD_Return_new($b,$ret) '" F2="' . urlencode($F2) . '">'); } + +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/pmd_relation_upd.php b/pmd_relation_upd.php index 0cb6b3535f..59823a416e 100644 --- a/pmd_relation_upd.php +++ b/pmd_relation_upd.php @@ -66,4 +66,8 @@ if ($try_to_delete_internal_relation) { } PMA_returnUpd(1, __('Relation deleted')); +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/pmd_save_pos.php b/pmd_save_pos.php index 026440b6b4..6edeb2e443 100644 --- a/pmd_save_pos.php +++ b/pmd_save_pos.php @@ -84,4 +84,9 @@ if (! empty($die_save_pos)) { echo ''; } + +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/prefs_forms.php b/prefs_forms.php index 2cc37bfa8e..2c559cff50 100644 --- a/prefs_forms.php +++ b/prefs_forms.php @@ -89,4 +89,9 @@ if ($form_display->hasErrors()) { display(true, true); + +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/prefs_manage.php b/prefs_manage.php index b79e2d6d6d..29b569a371 100644 --- a/prefs_manage.php +++ b/prefs_manage.php @@ -346,3 +346,10 @@ echo '

' . __('Reset') . '

'
+ + \ No newline at end of file diff --git a/querywindow.php b/querywindow.php index 5090e3d14d..5653ab3376 100644 --- a/querywindow.php +++ b/querywindow.php @@ -205,3 +205,10 @@ echo ''; echo ''; echo ''; + +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; + +?> \ No newline at end of file diff --git a/schema_edit.php b/schema_edit.php index 210756a1c1..69a7094019 100644 --- a/schema_edit.php +++ b/schema_edit.php @@ -126,4 +126,8 @@ if ($cfgRelation['pdfwork']) { } // end if } // end if ($cfgRelation['pdfwork']) +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/schema_export.php b/schema_export.php index e150db190d..4044409a38 100644 --- a/schema_export.php +++ b/schema_export.php @@ -72,3 +72,10 @@ if (isset($_REQUEST['do'])) { $user_schema->setAction($_REQUEST['do']); $user_schema->processUserChoice(); } + +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; + +?> \ No newline at end of file diff --git a/server_binlog.php b/server_binlog.php index 1ff1924267..599734aada 100644 --- a/server_binlog.php +++ b/server_binlog.php @@ -49,6 +49,11 @@ $response->addHTML(PMA_getHtmlForSubPageHeader('binlog')); $response->addHTML(PMA_getLogSelector($binary_logs, $url_params)); $response->addHTML(PMA_getLogInfo($url_params)); +/** + * Include error reporting script. Before exit. + */ +require_once 'libraries/common_error_reporting.inc.php'; + exit; ?> diff --git a/server_collations.php b/server_collations.php index b1b9c71a09..2f6402b20c 100644 --- a/server_collations.php +++ b/server_collations.php @@ -36,4 +36,9 @@ $response->addHTML( ) ); +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; + ?> diff --git a/server_databases.php b/server_databases.php index 2ee0c2b580..5bb65fcd7b 100644 --- a/server_databases.php +++ b/server_databases.php @@ -115,4 +115,8 @@ unset($databases_count); $response->addHTML($html); +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/server_engines.php b/server_engines.php index 12320498a5..868a22e059 100644 --- a/server_engines.php +++ b/server_engines.php @@ -29,6 +29,11 @@ $response->addHTML(PMA_getHtmlForSubPageHeader('engines')); */ $response->addHTML(PMA_getHtmlForServerEngines()); +/** + * Include error reporting script. Before exit. + */ +require_once 'libraries/common_error_reporting.inc.php'; + exit; ?> diff --git a/server_export.php b/server_export.php index c0bffdb3e1..ab319a4d14 100644 --- a/server_export.php +++ b/server_export.php @@ -26,4 +26,8 @@ $multi_values = PMA_getHtmlForExportSelectOptions($select_item); $export_type = 'server'; require_once 'libraries/display_export.inc.php'; +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/server_import.php b/server_import.php index 83d27cf7c1..ce6d11c763 100644 --- a/server_import.php +++ b/server_import.php @@ -24,4 +24,8 @@ require 'libraries/server_common.inc.php'; $import_type = 'server'; require 'libraries/display_import.inc.php'; +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/server_plugins.php b/server_plugins.php index 089bfd1d7f..b08c438de4 100644 --- a/server_plugins.php +++ b/server_plugins.php @@ -54,6 +54,11 @@ ksort($plugins); $response->addHTML(PMA_getHtmlForSubPageHeader('plugins')); $response->addHTML(PMA_getPluginAndModuleInfo($plugins, $modules)); +/** + * Include error reporting script. Before exit. + */ +require_once 'libraries/common_error_reporting.inc.php'; + exit; ?> diff --git a/server_privileges.php b/server_privileges.php index d061a042f1..893e6ea621 100644 --- a/server_privileges.php +++ b/server_privileges.php @@ -408,4 +408,8 @@ if ((isset($_REQUEST['viewing_mode']) && $_REQUEST['viewing_mode'] == 'server') $response->addHTML(''); } +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/server_replication.php b/server_replication.php index 9f1f2ae6f7..907ca4e4f8 100644 --- a/server_replication.php +++ b/server_replication.php @@ -80,4 +80,9 @@ if (! isset($_REQUEST['repl_clear_scr'])) { if (isset($_REQUEST['sl_configure'])) { $response->addHTML(PMA_getHtmlForReplicationChangeMaster("slave_changemaster")); } + +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/server_sql.php b/server_sql.php index 1d505e4305..0784cbd7b0 100644 --- a/server_sql.php +++ b/server_sql.php @@ -28,4 +28,8 @@ require_once 'libraries/sql_query_form.lib.php'; */ $response->addHTML(PMA_getHtmlForSqlQueryForm()); +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/server_status.php b/server_status.php index 7bee6558f6..c42fd3124f 100644 --- a/server_status.php +++ b/server_status.php @@ -51,5 +51,10 @@ $response->addHTML($ServerStatusData->getMenuHtml()); $response->addHTML(PMA_getHtmlForServerStatus($ServerStatusData)); $response->addHTML(''); +/** + * Include error reporting script. Before exit. + */ +require_once 'libraries/common_error_reporting.inc.php'; + exit; ?> diff --git a/server_status_advisor.php b/server_status_advisor.php index 6f882033cc..932ecfead1 100644 --- a/server_status_advisor.php +++ b/server_status_advisor.php @@ -32,8 +32,12 @@ $response->addHTML('
'); $response->addHTML($ServerStatusData->getMenuHtml()); $response->addHTML(PMA_getHtmlForAdvisor()); $response->addHTML('
'); + +/** + * Include error reporting script. Before exit. + */ +require_once 'libraries/common_error_reporting.inc.php'; + exit; - - ?> diff --git a/server_status_monitor.php b/server_status_monitor.php index 958bed2066..96217d9480 100644 --- a/server_status_monitor.php +++ b/server_status_monitor.php @@ -110,6 +110,12 @@ $response->addHTML($ServerStatusData->getMenuHtml()); $response->addHTML(PMA_getHtmlForMonitor($ServerStatusData)); $response->addHTML(PMA_getHtmlForClientSideDataAndLinks($ServerStatusData)); $response->addHTML(''); + +/** + * Include error reporting script. Before exit. + */ +require_once 'libraries/common_error_reporting.inc.php'; + exit; ?> diff --git a/server_status_queries.php b/server_status_queries.php index b895843292..f0868fd948 100644 --- a/server_status_queries.php +++ b/server_status_queries.php @@ -48,6 +48,12 @@ $response->addHTML('
'); $response->addHTML($ServerStatusData->getMenuHtml()); $response->addHTML(PMA_getHtmlForQueryStatistics($ServerStatusData)); $response->addHTML('
'); + +/** + * Include error reporting script. Before exit. + */ +require_once 'libraries/common_error_reporting.inc.php'; + exit; ?> diff --git a/server_status_variables.php b/server_status_variables.php index fe93501e1c..cacc65b786 100644 --- a/server_status_variables.php +++ b/server_status_variables.php @@ -51,6 +51,11 @@ $response->addHTML(PMA_getHtmlForLinkSuggestions($ServerStatusData)); $response->addHTML(PMA_getHtmlForVariablesList($ServerStatusData)); $response->addHTML(''); +/** + * Include error reporting script. Before exit. + */ +require_once 'libraries/common_error_reporting.inc.php'; + exit; ?> diff --git a/server_user_groups.php b/server_user_groups.php index 7236a91615..3d2fee8666 100644 --- a/server_user_groups.php +++ b/server_user_groups.php @@ -61,4 +61,9 @@ if (isset($_REQUEST['addUserGroup'])) { } $response->addHTML(''); + +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; ?> \ No newline at end of file diff --git a/server_variables.php b/server_variables.php index b287777206..4a4454e9af 100644 --- a/server_variables.php +++ b/server_variables.php @@ -55,6 +55,11 @@ $response->addHtml(PMA_getHtmlForLinkTemplates()); */ $response->addHtml(PMA_getHtmlForServerVariables($variable_doc_links)); +/** + * Include error reporting script. Before exit. + */ +require_once 'libraries/common_error_reporting.inc.php'; + exit; ?> diff --git a/sql.php b/sql.php index 7c67629d25..38b0435955 100644 --- a/sql.php +++ b/sql.php @@ -198,4 +198,8 @@ PMA_executeQueryAndSendQueryResponse( isset($complete_query) ? $complete_query : null ); +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/tbl_addfield.php b/tbl_addfield.php index e679bd5ca3..9386e0e974 100644 --- a/tbl_addfield.php +++ b/tbl_addfield.php @@ -114,4 +114,9 @@ if ($abort == false) { $action = 'tbl_addfield.php'; include_once 'libraries/tbl_columns_definition_form.inc.php'; } + +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/tbl_change.php b/tbl_change.php index dee996ca73..048a3cdd09 100644 --- a/tbl_change.php +++ b/tbl_change.php @@ -212,4 +212,9 @@ if ($insert_mode) { } $response->addHTML($html_output); + +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/tbl_chart.php b/tbl_chart.php index f5a6264d33..dccad6cbd6 100644 --- a/tbl_chart.php +++ b/tbl_chart.php @@ -136,4 +136,9 @@ $htmlString = PMA_getHtmlForTableChartDisplay( ); $response->addHTML($htmlString); + +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/tbl_create.php b/tbl_create.php index 70b1488386..eaa5e99e63 100644 --- a/tbl_create.php +++ b/tbl_create.php @@ -99,4 +99,9 @@ $GLOBAL['table'] = ''; */ require 'libraries/tbl_columns_definition_form.inc.php'; +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; + ?> diff --git a/tbl_export.php b/tbl_export.php index f49b7eff5e..db330b807c 100644 --- a/tbl_export.php +++ b/tbl_export.php @@ -84,4 +84,9 @@ if (! empty($sql_query)) { $export_type = 'table'; require_once 'libraries/display_export.inc.php'; + +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/tbl_find_replace.php b/tbl_find_replace.php index 92f3e079fd..add58d5340 100644 --- a/tbl_find_replace.php +++ b/tbl_find_replace.php @@ -60,4 +60,9 @@ $err_url = $goto . '?' . PMA_URL_getCommon($db, $table); $htmlOutput .= $table_search->getSelectionForm($goto); $response->addHTML($htmlOutput); +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; + ?> diff --git a/tbl_get_field.php b/tbl_get_field.php index 3c9a867117..641e4a41b8 100644 --- a/tbl_get_field.php +++ b/tbl_get_field.php @@ -52,4 +52,9 @@ PMA_downloadHeader( strlen($result) ); echo $result; + +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/tbl_gis_visualization.php b/tbl_gis_visualization.php index c64dd7c701..e7bcbd5c04 100644 --- a/tbl_gis_visualization.php +++ b/tbl_gis_visualization.php @@ -116,4 +116,8 @@ $html = PMA_getHtmlForGisVisualization( $response->addHTML($html); +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/tbl_import.php b/tbl_import.php index fc642d86ea..568c745dfa 100644 --- a/tbl_import.php +++ b/tbl_import.php @@ -27,4 +27,8 @@ require_once 'libraries/tbl_info.inc.php'; $import_type = 'table'; require_once 'libraries/display_import.inc.php'; +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/tbl_indexes.php b/tbl_indexes.php index e095ded833..a82b49957d 100644 --- a/tbl_indexes.php +++ b/tbl_indexes.php @@ -45,4 +45,9 @@ $response->addHTML($html); $header = $response->getHeader(); $scripts = $header->getScripts(); $scripts->addFile('indexes.js'); + +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/tbl_move_copy.php b/tbl_move_copy.php index 402da2efcb..4cd41e8918 100644 --- a/tbl_move_copy.php +++ b/tbl_move_copy.php @@ -101,4 +101,9 @@ if ($GLOBALS['is_ajax_request'] == true) { */ $_message = $message; unset($message); + +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/tbl_operations.php b/tbl_operations.php index 87108620e5..bc6b61c4b9 100644 --- a/tbl_operations.php +++ b/tbl_operations.php @@ -405,4 +405,8 @@ if ($cfgRelation['relwork'] && ! $is_innodb) { $response->addHTML(''); +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/tbl_printview.php b/tbl_printview.php index fd500eaf46..6567d87886 100644 --- a/tbl_printview.php +++ b/tbl_printview.php @@ -69,5 +69,10 @@ $response->addHTML( */ $response->addHTML(PMA_getHtmlForPrintViewFooter()); +/** + * Include error reporting script. Before exiting. + */ +require_once 'libraries/common_error_reporting.inc.php'; + exit; ?> diff --git a/tbl_relation.php b/tbl_relation.php index 9be5f6260c..5405408c4e 100644 --- a/tbl_relation.php +++ b/tbl_relation.php @@ -157,4 +157,9 @@ if (PMA_Util::isForeignKeySupported($tbl_storage_engine)) { } // Render HTML output PMA_Response::getInstance()->addHTML($html_output); + +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/tbl_replace.php b/tbl_replace.php index fae9eb2cb8..0ab5ef2259 100644 --- a/tbl_replace.php +++ b/tbl_replace.php @@ -403,6 +403,12 @@ if (isset($_REQUEST['after_insert']) && 'new_insert' == $_REQUEST['after_insert' * Load target page. */ require '' . PMA_securePath($goto_include); + +/** + * Include error reporting script. Before exiting. + */ +require_once 'libraries/common_error_reporting.inc.php'; + exit; ?> diff --git a/tbl_row_action.php b/tbl_row_action.php index 51a1889e38..38b1e1aee5 100644 --- a/tbl_row_action.php +++ b/tbl_row_action.php @@ -139,4 +139,9 @@ if (!empty($submit_mult)) { ); } } + +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/tbl_select.php b/tbl_select.php index 49cd391ce9..1535b4745a 100644 --- a/tbl_select.php +++ b/tbl_select.php @@ -70,4 +70,9 @@ if (! isset($_POST['columnsToDisplay']) && ! isset($_POST['displayAllColumns'])) null, null ); } + +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/tbl_sql.php b/tbl_sql.php index 0035840199..03c2d53d82 100644 --- a/tbl_sql.php +++ b/tbl_sql.php @@ -48,4 +48,8 @@ $response->addHTML( ) ); +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/tbl_structure.php b/tbl_structure.php index b40c57dabc..30af308a0e 100644 --- a/tbl_structure.php +++ b/tbl_structure.php @@ -161,4 +161,9 @@ $hidden_titles = PMA_getHiddenTitlesArray(); //display table structure require_once 'libraries/display_structure.inc.php'; + +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/tbl_tracking.php b/tbl_tracking.php index 2abd935c73..07d56662c5 100644 --- a/tbl_tracking.php +++ b/tbl_tracking.php @@ -150,4 +150,8 @@ $html .= '
'; $response = PMA_Response::getInstance(); $response->addHTML($html); +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/tbl_zoom_select.php b/tbl_zoom_select.php index 7f4ceea329..0f09273959 100644 --- a/tbl_zoom_select.php +++ b/tbl_zoom_select.php @@ -160,4 +160,9 @@ if (isset($_POST['zoom_submit']) //Displays form for point data and scatter plot $response->addHTML($table_search->getZoomResultsForm($goto, $data)); } + +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/themes.php b/themes.php index aed65f97dd..4735973f68 100644 --- a/themes.php +++ b/themes.php @@ -29,4 +29,8 @@ $output .= $_SESSION['PMA_Theme_Manager']->getPrintPreviews(); $response->addHTML($output); +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/transformation_overview.php b/transformation_overview.php index 119436e3c0..6a8a2b9565 100644 --- a/transformation_overview.php +++ b/transformation_overview.php @@ -56,3 +56,10 @@ foreach ($types['transformation'] as $key => $transform) { ?> + + \ No newline at end of file diff --git a/transformation_wrapper.php b/transformation_wrapper.php index ac0b04973d..d939e4a42f 100644 --- a/transformation_wrapper.php +++ b/transformation_wrapper.php @@ -145,4 +145,9 @@ if (! isset($_REQUEST['resize'])) { ImageDestroy($srcImage); ImageDestroy($destImage); } + +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/url.php b/url.php index 71efc9fb6b..24bd839a1b 100644 --- a/url.php +++ b/url.php @@ -30,5 +30,11 @@ if (! PMA_isValid($_GET['url']) // Display redirecting msg on screen. printf(__('Taking you to %s.'), htmlspecialchars($_GET['url'])); } + +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; + die(); ?> diff --git a/user_password.php b/user_password.php index 17f1eca105..e47c5581ae 100644 --- a/user_password.php +++ b/user_password.php @@ -197,4 +197,9 @@ function PMA_changePassDisplayPage($message, $sql_query) . '' . __('Back') . ''; exit; } + +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/view_create.php b/view_create.php index d59eb9c39b..8fbc679e05 100644 --- a/view_create.php +++ b/view_create.php @@ -284,3 +284,10 @@ $htmlString .= '' . ''; echo $htmlString; + +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; + +?> \ No newline at end of file diff --git a/view_operations.php b/view_operations.php index 7616dbb119..45a8c3f26a 100644 --- a/view_operations.php +++ b/view_operations.php @@ -136,3 +136,9 @@ echo PMA_getDeleteDataOrTableLink( echo ''; echo ''; echo ''; + +/** + * Include error reporting script. + */ +require_once 'libraries/common_error_reporting.inc.php'; +?> \ No newline at end of file From 86b3f352a9e7a7281b692cf3526957844977ce27 Mon Sep 17 00:00:00 2001 From: Dhananjay Nakrani Date: Thu, 5 Jun 2014 20:34:21 +0530 Subject: [PATCH 16/35] Stop false alarms (displaying prompts-reporting form and reporting for 'false' (user warnings) errors). Signed-off-by: Dhananjay Nakrani --- error_report.php | 98 ++++++++++++++++--------------- libraries/Error_Handler.class.php | 19 +++++- libraries/Response.class.php | 2 +- libraries/error_report.lib.php | 8 ++- 4 files changed, 76 insertions(+), 51 deletions(-) diff --git a/error_report.php b/error_report.php index 91dd8c3820..20c6f9772b 100644 --- a/error_report.php +++ b/error_report.php @@ -80,57 +80,59 @@ if (isset($_REQUEST['exception_type']) && $_REQUEST['send_error_report'] == '1' ) { $reportData = PMA_getReportData('php'); - $server_response = PMA_sendErrorReport($reportData); - if ($server_response === false) { - $success = false; - } else { - $decoded_response = json_decode($server_response, true); - $success = !empty($decoded_response) ? $decoded_response["success"] : false; - } + if ($reportData) { + $server_response = PMA_sendErrorReport($reportData); + if ($server_response === false) { + $success = false; + } else { + $decoded_response = json_decode($server_response, true); + $success = !empty($decoded_response) ? $decoded_response["success"] : false; + } - if($GLOBALS['cfg']['SendErrorReports'] == 'ask'){ - if($success) { - $errSubmitMsg = PMA_Message::error( - __('Thank You for subitting error report!!') - . '
' - . __('Report has been succesfully submitted.') - ); - } else { - $errSubmitMsg = PMA_Message::error( - __('Thank You for subitting error report!!') - . '
' - . __(' Unfortunately submission failed.') - . '
' - . __(' If you experience any problems please submit a bug report manually.') - ); + if($GLOBALS['cfg']['SendErrorReports'] == 'ask'){ + if($success) { + $errSubmitMsg = PMA_Message::error( + __('Thank You for subitting error report!!') + . '
' + . __('Report has been succesfully submitted.') + ); + } else { + $errSubmitMsg = PMA_Message::error( + __('Thank You for subitting error report!!') + . '
' + . __(' Unfortunately submission failed.') + . '
' + . __(' If you experience any problems please submit a bug report manually.') + ); + } + } elseif($GLOBALS['cfg']['SendErrorReports'] == 'always') { + if($success) { + $errSubmitMsg = PMA_Message::error( + __( + 'An error has been detected on the server and an error report has been ' + . 'automatically submitted based on your settings.' + ) + ); + } else { + $errSubmitMsg = PMA_Message::error( + __( + 'An error has been detected and an error report has been ' + . 'generated but failed to be sent.' + ) + . '
' + . __('If you experience any problems please submit a bug report manually.') + ); + } } - } elseif($GLOBALS['cfg']['SendErrorReports'] == 'always') { - if($success) { - $errSubmitMsg = PMA_Message::error( - __( - 'An error has been detected on the server and an error report has been ' - . 'automatically submitted based on your settings.' - ) - ); - } else { - $errSubmitMsg = PMA_Message::error( - __( - 'An error has been detected and an error report has been ' - . 'generated but failed to be sent.' - ) - . '
' - . __('If you experience any problems please submit a bug report manually.') - ); - } - } - if($response->isAjax()) { - $response->addJSON('_errSubmitMsg',$errSubmitMsg); - } else { - $jsCode = 'PMA_ajaxShowMessage("
' - .$errSubmitMsg - .'
", false);'; - $response->getFooter()->getScripts()->addCode($jsCode); + if($response->isAjax()) { + $response->addJSON('_errSubmitMsg',$errSubmitMsg); + } else { + $jsCode = 'PMA_ajaxShowMessage("
' + .$errSubmitMsg + .'
", false);'; + $response->getFooter()->getScripts()->addCode($jsCode); + } } } // clear previous errors & save new ones. diff --git a/libraries/Error_Handler.class.php b/libraries/Error_Handler.class.php index b9d1bcb886..2d73a1ba22 100644 --- a/libraries/Error_Handler.class.php +++ b/libraries/Error_Handler.class.php @@ -309,7 +309,9 @@ class PMA_Error_Handler } else { $retval .= $this->getDispUserErrors(); } - if($GLOBALS['cfg']['SendErrorReports'] == 'ask'){ + if($GLOBALS['cfg']['SendErrorReports'] == 'ask' // preference is 'ask' and + && $this->countErrors() != $this->countUserErrors() // there are 'actual' errors to be reported + ){ // add report button. $retval .= '
' . 'countErrors() != $this->countUserErrors() + ); + } } ?> diff --git a/libraries/Response.class.php b/libraries/Response.class.php index 3c43c23251..c34cf23ddf 100644 --- a/libraries/Response.class.php +++ b/libraries/Response.class.php @@ -316,7 +316,7 @@ class PMA_Response if (strlen($errors)) { $this->addJSON('_errors', $errors); } - $promptPhpErrors = ($GLOBALS['cfg']['SendErrorReports'] != 'never' || $GLOBALS['cfg']['Error_Handler']['display']); + $promptPhpErrors = $GLOBALS['error_handler']->hasErrorsForPrompt(); $this->addJSON('_promptPhpErrors', $promptPhpErrors); if (empty($GLOBALS['error_message'])) { diff --git a/libraries/error_report.lib.php b/libraries/error_report.lib.php index 4f5fd06904..fc3dd1df9e 100644 --- a/libraries/error_report.lib.php +++ b/libraries/error_report.lib.php @@ -52,7 +52,8 @@ function PMA_getPrettyReportData() * returns the error report data collected from the current configuration or * from the request parameters sent by the error reporting js code. * - * @return Array the report + * @return Array/String the report. + * False if there're no 'actual' errors to be reported (case for php errors) */ function PMA_getReportData($exception_type = 'js') { @@ -107,6 +108,11 @@ function PMA_getReportData($exception_type = 'js') } } + + // if there were no 'actual' errors to be submitted. + if($i==0) { + return false; // then return false + } $report ["exception_type"] = 'php'; $report["errors"] = $errors; } From e1ee8d2d9e0a08475fff7201d399992d57f1a1f4 Mon Sep 17 00:00:00 2001 From: Dhananjay Nakrani Date: Sat, 7 Jun 2014 11:49:47 +0530 Subject: [PATCH 17/35] Move error reporting code to a separate function 'PMA_Error_Handler::reportError()'. Hook it in 'PMA_Footer::getErrorMessages()'. Signed-off-by: Dhananjay Nakrani --- libraries/Error_Handler.class.php | 40 +++++++++++++++++++++++++++++++ libraries/Footer.class.php | 6 +++++ 2 files changed, 46 insertions(+) diff --git a/libraries/Error_Handler.class.php b/libraries/Error_Handler.class.php index 2d73a1ba22..12f08c07e4 100644 --- a/libraries/Error_Handler.class.php +++ b/libraries/Error_Handler.class.php @@ -469,5 +469,45 @@ class PMA_Error_Handler && $this->countErrors() != $this->countUserErrors() ); } + + /** + * Function to report all the collected php errors. + * Must be called at the end of each script by the $GLOBALS['error_handler'] only. + * + * @return: void + */ + public function reportError() + { + if (!$this->hasErrors()) { + return; + } + // Delete all the prev_errors in session & store new prev_errors in session + $this->savePreviousErrors(); + $response = PMA_Response::getInstance(); + $jsCode = ''; + if ($GLOBALS['cfg']['SendErrorReports'] == 'always') { + //send the error reports directly + $_REQUEST['exception_type'] = 'php'; + $_REQUEST['send_error_report'] = '1'; + include_once 'error_report.php'; + + // js code to appropriate focusing, + $jsCode = '$("html, body").animate({ + scrollTop:$(document).height() + }, "slow");'; + } elseif ($GLOBALS['cfg']['SendErrorReports'] == 'ask') { + //ask user whether to submit errors or not. + if (!$response->isAjax()) { + // js code to show appropriate msgs & focusing, + $jsCode = 'PMA_ajaxShowMessage(PMA_messages["phpErrorsFound"], 2000);' + . '$("html, body").animate({ + scrollTop:$(document).height() + }, "slow");'; + } + } + // The errors are already sent from the resnpose. + // Just focus on errors division upon load event. + $response->getFooter()->getScripts()->addCode($jsCode); + } } ?> diff --git a/libraries/Footer.class.php b/libraries/Footer.class.php index 095552e73c..a97e619875 100644 --- a/libraries/Footer.class.php +++ b/libraries/Footer.class.php @@ -209,6 +209,12 @@ class PMA_Footer $retval .= $GLOBALS['error_handler']->getDispErrors(); $retval .= ''; } + + /** + * Report php errors + */ + $GLOBALS['error_handler']->reportError(); + return $retval; } From 9a1fb901d048d72ec2ab7660de7e839e253cb3b8 Mon Sep 17 00:00:00 2001 From: Dhananjay Nakrani Date: Sat, 7 Jun 2014 15:50:13 +0530 Subject: [PATCH 18/35] Remove included 'common_error_reporting.php' script and its inclusion from all the scripts. Signed-off-by: Dhananjay Nakrani --- browse_foreigners.php | 4 -- chk_rel.php | 4 -- db_create.php | 4 -- db_datadict.php | 4 -- db_events.php | 4 -- db_export.php | 4 -- db_import.php | 4 -- db_operations.php | 4 -- db_printview.php | 4 -- db_qbe.php | 4 -- db_routines.php | 4 -- db_search.php | 4 -- db_sql.php | 4 -- db_structure.php | 4 -- db_tracking.php | 4 -- db_triggers.php | 4 -- error_report.php | 4 -- export.php | 5 --- file_echo.php | 4 -- gis_data_editor.php | 4 -- import.php | 4 -- import_status.php | 4 -- index.php | 5 --- libraries/common_error_reporting.inc.php | 55 ------------------------ navigation.php | 4 -- phpinfo.php | 4 -- pmd_display_field.php | 5 --- pmd_general.php | 4 -- pmd_pdf.php | 4 -- pmd_relation_new.php | 4 -- pmd_relation_upd.php | 4 -- pmd_save_pos.php | 4 -- prefs_forms.php | 4 -- prefs_manage.php | 7 --- querywindow.php | 7 +-- schema_edit.php | 4 -- schema_export.php | 7 +-- server_binlog.php | 5 --- server_collations.php | 5 --- server_databases.php | 4 -- server_engines.php | 5 --- server_export.php | 4 -- server_import.php | 4 -- server_plugins.php | 5 --- server_privileges.php | 4 -- server_replication.php | 4 -- server_sql.php | 4 -- server_status.php | 5 --- server_status_advisor.php | 5 --- server_status_monitor.php | 5 --- server_status_queries.php | 5 --- server_status_variables.php | 5 --- server_user_groups.php | 4 -- server_variables.php | 5 --- sql.php | 4 -- tbl_addfield.php | 4 -- tbl_change.php | 4 -- tbl_chart.php | 4 -- tbl_create.php | 5 --- tbl_export.php | 4 -- tbl_find_replace.php | 5 --- tbl_get_field.php | 4 -- tbl_gis_visualization.php | 4 -- tbl_import.php | 4 -- tbl_indexes.php | 4 -- tbl_move_copy.php | 4 -- tbl_operations.php | 4 -- tbl_printview.php | 5 --- tbl_relation.php | 4 -- tbl_replace.php | 5 --- tbl_row_action.php | 4 -- tbl_select.php | 4 -- tbl_sql.php | 4 -- tbl_structure.php | 4 -- tbl_tracking.php | 4 -- tbl_zoom_select.php | 4 -- themes.php | 4 -- transformation_overview.php | 7 --- transformation_wrapper.php | 4 -- url.php | 5 --- user_password.php | 4 -- view_create.php | 5 --- view_operations.php | 4 -- 83 files changed, 2 insertions(+), 412 deletions(-) delete mode 100644 libraries/common_error_reporting.inc.php diff --git a/browse_foreigners.php b/browse_foreigners.php index acb725bac1..36fa329145 100644 --- a/browse_foreigners.php +++ b/browse_foreigners.php @@ -59,8 +59,4 @@ $html = PMA_getHtmlForRelationalFieldSelection( $response->addHtml($html); -/** - * Include error reporting script. - */ -require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/chk_rel.php b/chk_rel.php index bb211692cb..915e8b24b4 100644 --- a/chk_rel.php +++ b/chk_rel.php @@ -12,8 +12,4 @@ $response->addHTML( PMA_getRelationsParamDiagnostic(PMA_getRelationsParam()) ); -/** - * Include error reporting script. - */ -require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/db_create.php b/db_create.php index c82fcfac66..f829139fdb 100644 --- a/db_create.php +++ b/db_create.php @@ -134,8 +134,4 @@ if (! $result) { } } -/** - * Include error reporting script. - */ -require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/db_datadict.php b/db_datadict.php index e59cb73fe7..43d4c154c7 100644 --- a/db_datadict.php +++ b/db_datadict.php @@ -254,8 +254,4 @@ foreach ($tables as $table) { */ echo PMA_Util::getButton(); -/** - * Include error reporting script. - */ -require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/db_events.php b/db_events.php index 8a3a1e039f..917778bc35 100644 --- a/db_events.php +++ b/db_events.php @@ -23,8 +23,4 @@ require_once 'libraries/rte/rte_events.lib.php'; $_PMA_RTE = 'EVN'; require_once 'libraries/rte/rte_main.inc.php'; -/** - * Include error reporting script. - */ -require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/db_export.php b/db_export.php index 12c9669d9f..5313e0e022 100644 --- a/db_export.php +++ b/db_export.php @@ -91,8 +91,4 @@ $multi_values .= ''; $export_type = 'database'; require_once 'libraries/display_export.inc.php'; -/** - * Include error reporting script. - */ -require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/db_import.php b/db_import.php index ab0793d5c9..70425b2183 100644 --- a/db_import.php +++ b/db_import.php @@ -22,8 +22,4 @@ require 'libraries/db_info.inc.php'; $import_type = 'database'; require 'libraries/display_import.inc.php'; -/** - * Include error reporting script. - */ -require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/db_operations.php b/db_operations.php index 1facee9a2b..eec625bd5f 100644 --- a/db_operations.php +++ b/db_operations.php @@ -297,8 +297,4 @@ if ($cfgRelation['pdfwork'] && $num_tables > 0) { $response->addHTML(PMA_getHtmlForExportRelationalSchemaView($url_query)); } // end if -/** - * Include error reporting script. - */ -require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/db_printview.php b/db_printview.php index e359ad2a3d..c124fbc1f7 100644 --- a/db_printview.php +++ b/db_printview.php @@ -178,8 +178,4 @@ echo PMA_Util::getButton(); echo "
\n"; -/** - * Include error reporting script. - */ -require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/db_qbe.php b/db_qbe.php index 2589ee1444..c58c865ba7 100644 --- a/db_qbe.php +++ b/db_qbe.php @@ -131,8 +131,4 @@ if ($cfgRelation['designerwork']) { $response->addHTML($db_qbe->getSelectionForm($cfgRelation)); -/** - * Include error reporting script. - */ -require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/db_routines.php b/db_routines.php index 904cd55d3f..a58d4c0a21 100644 --- a/db_routines.php +++ b/db_routines.php @@ -24,8 +24,4 @@ require_once 'libraries/rte/rte_routines.lib.php'; $_PMA_RTE = 'RTN'; require_once 'libraries/rte/rte_main.inc.php'; -/** - * Include error reporting script. - */ -require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/db_search.php b/db_search.php index 5fbb1cb208..17237eb000 100644 --- a/db_search.php +++ b/db_search.php @@ -61,8 +61,4 @@ $response->addHTML( $response->addHTML($db_search->getSelectionForm()); $response->addHTML($db_search->getResultDivs()); -/** - * Include error reporting script. - */ -require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/db_sql.php b/db_sql.php index 1f25b6be58..67bbbb59d6 100644 --- a/db_sql.php +++ b/db_sql.php @@ -41,8 +41,4 @@ $response->addHTML( ) ); -/** - * Include error reporting script. - */ -require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/db_structure.php b/db_structure.php index 226e47fb5b..7b6eedb6f4 100644 --- a/db_structure.php +++ b/db_structure.php @@ -349,8 +349,4 @@ if (empty($db_is_system_schema)) { $response->addHTML($content); } // end if (Create Table dialog) -/** - * Include error reporting script. - */ -require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/db_tracking.php b/db_tracking.php index 3013bb05d9..e5fe7111d4 100644 --- a/db_tracking.php +++ b/db_tracking.php @@ -251,8 +251,4 @@ if (count($data['ddlog']) > 0) { echo PMA_Util::getMessage(__('Database Log'), $log); } -/** - * Include error reporting script. - */ -require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/db_triggers.php b/db_triggers.php index 98f8c4f251..d1a2a8c6b2 100644 --- a/db_triggers.php +++ b/db_triggers.php @@ -22,8 +22,4 @@ require_once 'libraries/rte/rte_triggers.lib.php'; $_PMA_RTE = 'TRI'; require_once 'libraries/rte/rte_main.inc.php'; -/** - * Include error reporting script. - */ -require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/error_report.php b/error_report.php index 20c6f9772b..6a3b672517 100644 --- a/error_report.php +++ b/error_report.php @@ -141,8 +141,4 @@ if (isset($_REQUEST['exception_type']) die('Oops, something went wrong!!'); } -/** - * Include error reporting script. - */ -require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/export.php b/export.php index e7777e9862..215d494032 100644 --- a/export.php +++ b/export.php @@ -438,10 +438,5 @@ if (!defined('TESTSUITE')) { } else { echo PMA_getHtmlForDisplayedExportFooter($back_button); } // end if - - /** - * Include error reporting script. - */ - require_once 'libraries/common_error_reporting.inc.php'; } ?> diff --git a/file_echo.php b/file_echo.php index 7d9d0d99d2..1d8c569d84 100644 --- a/file_echo.php +++ b/file_echo.php @@ -69,8 +69,4 @@ if (isset($_REQUEST['filename']) && isset($_REQUEST['image'])) { echo file_get_contents($_FILES['file']['tmp_name']); } -/** - * Include error reporting script. - */ -require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/gis_data_editor.php b/gis_data_editor.php index 109b61aef8..6ece3213d5 100644 --- a/gis_data_editor.php +++ b/gis_data_editor.php @@ -422,8 +422,4 @@ echo ''; PMA_Response::getInstance()->addJSON('gis_editor', ob_get_contents()); ob_end_clean(); -/** - * Include error reporting script. - */ -require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/import.php b/import.php index 01adde2a4e..67e19e684d 100644 --- a/import.php +++ b/import.php @@ -670,8 +670,4 @@ if ($go_sql) { include '' . $goto; } -/** - * Include error reporting script. - */ -require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/import_status.php b/import_status.php index 13b841cf5d..43dcd07ee8 100644 --- a/import_status.php +++ b/import_status.php @@ -99,8 +99,4 @@ if (isset($_GET["message"]) && $_GET["message"]) { PMA_importAjaxStatus($_GET["id"]); } -/** - * Include error reporting script. - */ -require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/index.php b/index.php index 1c1683be03..50af41073f 100644 --- a/index.php +++ b/index.php @@ -663,9 +663,4 @@ function PMA_printListItem($name, $listId = null, $url = null, echo ''; } - -/** - * Include error reporting script. - */ -require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/libraries/common_error_reporting.inc.php b/libraries/common_error_reporting.inc.php deleted file mode 100644 index 0227ae74d1..0000000000 --- a/libraries/common_error_reporting.inc.php +++ /dev/null @@ -1,55 +0,0 @@ -hasErrors()) { - // Delete all the prev_errors in session & store new prev_errors in session - $GLOBALS['error_handler']->savePreviousErrors(); - - if($GLOBALS['cfg']['SendErrorReports'] == 'always'){ - //send the error reports directly - - $_REQUEST['exception_type'] = 'php'; - $_REQUEST['send_error_report'] = '1'; - require_once('error_report.php'); - - // The errors are already sent. Just focus on errors division upon load event. - $jsCode = '$("html, body").animate({scrollTop:$(document).height()}, "slow");'; - $response = PMA_Response::getInstance(); - $response->getFooter()->getScripts()->addCode($jsCode); - } - elseif($GLOBALS['cfg']['SendErrorReports'] == 'ask') { - //ask user whether to submit errors or not. - if($response->isAjax()) { - // Send the errors in '_error' param. That is Already done in PMA_Response::_ajaxResponse(). - } - else { - // The errors are already sent. Just focus on errors division upon load event. - $jsCode = 'PMA_ajaxShowMessage(PMA_messages["phpErrorsFound"], 2000);' - . '$("html, body").animate({scrollTop:$(document).height()}, "slow");'; - - $response = PMA_Response::getInstance(); - $response->getFooter()->getScripts()->addCode($jsCode); - } - - } - else { - //$GLOBALS['cfg']['SendErrorReports'] set to 'never'. Do not submit error reports. - - } -} -?> diff --git a/navigation.php b/navigation.php index c3f9337682..a30b725af8 100644 --- a/navigation.php +++ b/navigation.php @@ -69,8 +69,4 @@ if ($cfgRelation['navwork']) { // Do the magic $response->addJSON('message', $navigation->getDisplay()); -/** - * Include error reporting script. - */ -require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/phpinfo.php b/phpinfo.php index 680868387d..f9e415987f 100644 --- a/phpinfo.php +++ b/phpinfo.php @@ -19,8 +19,4 @@ if ($GLOBALS['cfg']['ShowPhpInfo']) { phpinfo(); } -/** - * Include error reporting script. - */ -require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/pmd_display_field.php b/pmd_display_field.php index 25eda516cb..8efe96f057 100644 --- a/pmd_display_field.php +++ b/pmd_display_field.php @@ -56,11 +56,6 @@ if ($cfgRelation['displaywork']) { } } // end if -/** - * Include error reporting script. Include before it "dies". - */ -require_once 'libraries/common_error_reporting.inc.php'; - header("Content-Type: text/xml; charset=utf-8"); header("Cache-Control: no-cache"); die("' . '
'; -/** - * Include error reporting script. - */ -require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/pmd_pdf.php b/pmd_pdf.php index 17d5da68d4..d4f64c938e 100644 --- a/pmd_pdf.php +++ b/pmd_pdf.php @@ -157,8 +157,4 @@ echo ''; echo ''; echo ''; -/** - * Include error reporting script. - */ -require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/pmd_relation_new.php b/pmd_relation_new.php index 0b9e5bd361..2f58909021 100644 --- a/pmd_relation_new.php +++ b/pmd_relation_new.php @@ -131,8 +131,4 @@ function PMD_Return_new($b,$ret) '">
'); } -/** - * Include error reporting script. - */ -require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/pmd_relation_upd.php b/pmd_relation_upd.php index 59823a416e..0cb6b3535f 100644 --- a/pmd_relation_upd.php +++ b/pmd_relation_upd.php @@ -66,8 +66,4 @@ if ($try_to_delete_internal_relation) { } PMA_returnUpd(1, __('Relation deleted')); -/** - * Include error reporting script. - */ -require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/pmd_save_pos.php b/pmd_save_pos.php index 6edeb2e443..faf601cd37 100644 --- a/pmd_save_pos.php +++ b/pmd_save_pos.php @@ -85,8 +85,4 @@ if (! empty($die_save_pos)) { . __('Modifications have been saved') . '">'; } -/** - * Include error reporting script. - */ -require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/prefs_forms.php b/prefs_forms.php index 2c559cff50..1001098979 100644 --- a/prefs_forms.php +++ b/prefs_forms.php @@ -90,8 +90,4 @@ if ($form_display->hasErrors()) { } $form_display->display(true, true); -/** - * Include error reporting script. - */ -require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/prefs_manage.php b/prefs_manage.php index 29b569a371..b79e2d6d6d 100644 --- a/prefs_manage.php +++ b/prefs_manage.php @@ -346,10 +346,3 @@ echo '

' . __('Reset') . '

'
- - \ No newline at end of file diff --git a/querywindow.php b/querywindow.php index 5653ab3376..c7ae7a9548 100644 --- a/querywindow.php +++ b/querywindow.php @@ -206,9 +206,4 @@ echo ' diff --git a/server_sql.php b/server_sql.php index 0784cbd7b0..1d505e4305 100644 --- a/server_sql.php +++ b/server_sql.php @@ -28,8 +28,4 @@ require_once 'libraries/sql_query_form.lib.php'; */ $response->addHTML(PMA_getHtmlForSqlQueryForm()); -/** - * Include error reporting script. - */ -require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/server_status.php b/server_status.php index c42fd3124f..7bee6558f6 100644 --- a/server_status.php +++ b/server_status.php @@ -51,10 +51,5 @@ $response->addHTML($ServerStatusData->getMenuHtml()); $response->addHTML(PMA_getHtmlForServerStatus($ServerStatusData)); $response->addHTML(''); -/** - * Include error reporting script. Before exit. - */ -require_once 'libraries/common_error_reporting.inc.php'; - exit; ?> diff --git a/server_status_advisor.php b/server_status_advisor.php index 932ecfead1..0d6d3b94d0 100644 --- a/server_status_advisor.php +++ b/server_status_advisor.php @@ -33,11 +33,6 @@ $response->addHTML($ServerStatusData->getMenuHtml()); $response->addHTML(PMA_getHtmlForAdvisor()); $response->addHTML(''); -/** - * Include error reporting script. Before exit. - */ -require_once 'libraries/common_error_reporting.inc.php'; - exit; ?> diff --git a/server_status_monitor.php b/server_status_monitor.php index 96217d9480..679b25fafc 100644 --- a/server_status_monitor.php +++ b/server_status_monitor.php @@ -111,11 +111,6 @@ $response->addHTML(PMA_getHtmlForMonitor($ServerStatusData)); $response->addHTML(PMA_getHtmlForClientSideDataAndLinks($ServerStatusData)); $response->addHTML(''); -/** - * Include error reporting script. Before exit. - */ -require_once 'libraries/common_error_reporting.inc.php'; - exit; ?> diff --git a/server_status_queries.php b/server_status_queries.php index f0868fd948..3360d36e19 100644 --- a/server_status_queries.php +++ b/server_status_queries.php @@ -49,11 +49,6 @@ $response->addHTML($ServerStatusData->getMenuHtml()); $response->addHTML(PMA_getHtmlForQueryStatistics($ServerStatusData)); $response->addHTML(''); -/** - * Include error reporting script. Before exit. - */ -require_once 'libraries/common_error_reporting.inc.php'; - exit; ?> diff --git a/server_status_variables.php b/server_status_variables.php index cacc65b786..fe93501e1c 100644 --- a/server_status_variables.php +++ b/server_status_variables.php @@ -51,11 +51,6 @@ $response->addHTML(PMA_getHtmlForLinkSuggestions($ServerStatusData)); $response->addHTML(PMA_getHtmlForVariablesList($ServerStatusData)); $response->addHTML(''); -/** - * Include error reporting script. Before exit. - */ -require_once 'libraries/common_error_reporting.inc.php'; - exit; ?> diff --git a/server_user_groups.php b/server_user_groups.php index 3d2fee8666..531f20a856 100644 --- a/server_user_groups.php +++ b/server_user_groups.php @@ -62,8 +62,4 @@ if (isset($_REQUEST['addUserGroup'])) { $response->addHTML(''); -/** - * Include error reporting script. - */ -require_once 'libraries/common_error_reporting.inc.php'; ?> \ No newline at end of file diff --git a/server_variables.php b/server_variables.php index 4a4454e9af..b287777206 100644 --- a/server_variables.php +++ b/server_variables.php @@ -55,11 +55,6 @@ $response->addHtml(PMA_getHtmlForLinkTemplates()); */ $response->addHtml(PMA_getHtmlForServerVariables($variable_doc_links)); -/** - * Include error reporting script. Before exit. - */ -require_once 'libraries/common_error_reporting.inc.php'; - exit; ?> diff --git a/sql.php b/sql.php index 38b0435955..7c67629d25 100644 --- a/sql.php +++ b/sql.php @@ -198,8 +198,4 @@ PMA_executeQueryAndSendQueryResponse( isset($complete_query) ? $complete_query : null ); -/** - * Include error reporting script. - */ -require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/tbl_addfield.php b/tbl_addfield.php index 9386e0e974..f93b765935 100644 --- a/tbl_addfield.php +++ b/tbl_addfield.php @@ -115,8 +115,4 @@ if ($abort == false) { include_once 'libraries/tbl_columns_definition_form.inc.php'; } -/** - * Include error reporting script. - */ -require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/tbl_change.php b/tbl_change.php index 048a3cdd09..572390a869 100644 --- a/tbl_change.php +++ b/tbl_change.php @@ -213,8 +213,4 @@ if ($insert_mode) { $response->addHTML($html_output); -/** - * Include error reporting script. - */ -require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/tbl_chart.php b/tbl_chart.php index dccad6cbd6..842ca5fb7d 100644 --- a/tbl_chart.php +++ b/tbl_chart.php @@ -137,8 +137,4 @@ $htmlString = PMA_getHtmlForTableChartDisplay( $response->addHTML($htmlString); -/** - * Include error reporting script. - */ -require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/tbl_create.php b/tbl_create.php index eaa5e99e63..70b1488386 100644 --- a/tbl_create.php +++ b/tbl_create.php @@ -99,9 +99,4 @@ $GLOBAL['table'] = ''; */ require 'libraries/tbl_columns_definition_form.inc.php'; -/** - * Include error reporting script. - */ -require_once 'libraries/common_error_reporting.inc.php'; - ?> diff --git a/tbl_export.php b/tbl_export.php index db330b807c..b5bca4d885 100644 --- a/tbl_export.php +++ b/tbl_export.php @@ -85,8 +85,4 @@ if (! empty($sql_query)) { $export_type = 'table'; require_once 'libraries/display_export.inc.php'; -/** - * Include error reporting script. - */ -require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/tbl_find_replace.php b/tbl_find_replace.php index add58d5340..92f3e079fd 100644 --- a/tbl_find_replace.php +++ b/tbl_find_replace.php @@ -60,9 +60,4 @@ $err_url = $goto . '?' . PMA_URL_getCommon($db, $table); $htmlOutput .= $table_search->getSelectionForm($goto); $response->addHTML($htmlOutput); -/** - * Include error reporting script. - */ -require_once 'libraries/common_error_reporting.inc.php'; - ?> diff --git a/tbl_get_field.php b/tbl_get_field.php index 641e4a41b8..42ec09c7f1 100644 --- a/tbl_get_field.php +++ b/tbl_get_field.php @@ -53,8 +53,4 @@ PMA_downloadHeader( ); echo $result; -/** - * Include error reporting script. - */ -require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/tbl_gis_visualization.php b/tbl_gis_visualization.php index e7bcbd5c04..c64dd7c701 100644 --- a/tbl_gis_visualization.php +++ b/tbl_gis_visualization.php @@ -116,8 +116,4 @@ $html = PMA_getHtmlForGisVisualization( $response->addHTML($html); -/** - * Include error reporting script. - */ -require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/tbl_import.php b/tbl_import.php index 568c745dfa..fc642d86ea 100644 --- a/tbl_import.php +++ b/tbl_import.php @@ -27,8 +27,4 @@ require_once 'libraries/tbl_info.inc.php'; $import_type = 'table'; require_once 'libraries/display_import.inc.php'; -/** - * Include error reporting script. - */ -require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/tbl_indexes.php b/tbl_indexes.php index a82b49957d..145e4aaf51 100644 --- a/tbl_indexes.php +++ b/tbl_indexes.php @@ -46,8 +46,4 @@ $header = $response->getHeader(); $scripts = $header->getScripts(); $scripts->addFile('indexes.js'); -/** - * Include error reporting script. - */ -require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/tbl_move_copy.php b/tbl_move_copy.php index 4cd41e8918..140d93e8cc 100644 --- a/tbl_move_copy.php +++ b/tbl_move_copy.php @@ -102,8 +102,4 @@ if ($GLOBALS['is_ajax_request'] == true) { $_message = $message; unset($message); -/** - * Include error reporting script. - */ -require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/tbl_operations.php b/tbl_operations.php index bc6b61c4b9..87108620e5 100644 --- a/tbl_operations.php +++ b/tbl_operations.php @@ -405,8 +405,4 @@ if ($cfgRelation['relwork'] && ! $is_innodb) { $response->addHTML(''); -/** - * Include error reporting script. - */ -require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/tbl_printview.php b/tbl_printview.php index 6567d87886..fd500eaf46 100644 --- a/tbl_printview.php +++ b/tbl_printview.php @@ -69,10 +69,5 @@ $response->addHTML( */ $response->addHTML(PMA_getHtmlForPrintViewFooter()); -/** - * Include error reporting script. Before exiting. - */ -require_once 'libraries/common_error_reporting.inc.php'; - exit; ?> diff --git a/tbl_relation.php b/tbl_relation.php index 5405408c4e..1ed7645164 100644 --- a/tbl_relation.php +++ b/tbl_relation.php @@ -158,8 +158,4 @@ if (PMA_Util::isForeignKeySupported($tbl_storage_engine)) { // Render HTML output PMA_Response::getInstance()->addHTML($html_output); -/** - * Include error reporting script. - */ -require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/tbl_replace.php b/tbl_replace.php index 0ab5ef2259..390ec0f34e 100644 --- a/tbl_replace.php +++ b/tbl_replace.php @@ -404,11 +404,6 @@ if (isset($_REQUEST['after_insert']) && 'new_insert' == $_REQUEST['after_insert' */ require '' . PMA_securePath($goto_include); -/** - * Include error reporting script. Before exiting. - */ -require_once 'libraries/common_error_reporting.inc.php'; - exit; ?> diff --git a/tbl_row_action.php b/tbl_row_action.php index 38b1e1aee5..e34eeb5469 100644 --- a/tbl_row_action.php +++ b/tbl_row_action.php @@ -140,8 +140,4 @@ if (!empty($submit_mult)) { } } -/** - * Include error reporting script. - */ -require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/tbl_select.php b/tbl_select.php index 1535b4745a..7843f1d170 100644 --- a/tbl_select.php +++ b/tbl_select.php @@ -71,8 +71,4 @@ if (! isset($_POST['columnsToDisplay']) && ! isset($_POST['displayAllColumns'])) ); } -/** - * Include error reporting script. - */ -require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/tbl_sql.php b/tbl_sql.php index 03c2d53d82..0035840199 100644 --- a/tbl_sql.php +++ b/tbl_sql.php @@ -48,8 +48,4 @@ $response->addHTML( ) ); -/** - * Include error reporting script. - */ -require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/tbl_structure.php b/tbl_structure.php index 30af308a0e..c226851084 100644 --- a/tbl_structure.php +++ b/tbl_structure.php @@ -162,8 +162,4 @@ $hidden_titles = PMA_getHiddenTitlesArray(); //display table structure require_once 'libraries/display_structure.inc.php'; -/** - * Include error reporting script. - */ -require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/tbl_tracking.php b/tbl_tracking.php index 07d56662c5..2abd935c73 100644 --- a/tbl_tracking.php +++ b/tbl_tracking.php @@ -150,8 +150,4 @@ $html .= '
'; $response = PMA_Response::getInstance(); $response->addHTML($html); -/** - * Include error reporting script. - */ -require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/tbl_zoom_select.php b/tbl_zoom_select.php index 0f09273959..80d0e2e925 100644 --- a/tbl_zoom_select.php +++ b/tbl_zoom_select.php @@ -161,8 +161,4 @@ if (isset($_POST['zoom_submit']) $response->addHTML($table_search->getZoomResultsForm($goto, $data)); } -/** - * Include error reporting script. - */ -require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/themes.php b/themes.php index 4735973f68..aed65f97dd 100644 --- a/themes.php +++ b/themes.php @@ -29,8 +29,4 @@ $output .= $_SESSION['PMA_Theme_Manager']->getPrintPreviews(); $response->addHTML($output); -/** - * Include error reporting script. - */ -require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/transformation_overview.php b/transformation_overview.php index 6a8a2b9565..119436e3c0 100644 --- a/transformation_overview.php +++ b/transformation_overview.php @@ -56,10 +56,3 @@ foreach ($types['transformation'] as $key => $transform) { ?> - - \ No newline at end of file diff --git a/transformation_wrapper.php b/transformation_wrapper.php index d939e4a42f..263c905678 100644 --- a/transformation_wrapper.php +++ b/transformation_wrapper.php @@ -146,8 +146,4 @@ if (! isset($_REQUEST['resize'])) { ImageDestroy($destImage); } -/** - * Include error reporting script. - */ -require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/url.php b/url.php index 24bd839a1b..5835409a7d 100644 --- a/url.php +++ b/url.php @@ -31,10 +31,5 @@ if (! PMA_isValid($_GET['url']) printf(__('Taking you to %s.'), htmlspecialchars($_GET['url'])); } -/** - * Include error reporting script. - */ -require_once 'libraries/common_error_reporting.inc.php'; - die(); ?> diff --git a/user_password.php b/user_password.php index e47c5581ae..aa006aeac7 100644 --- a/user_password.php +++ b/user_password.php @@ -198,8 +198,4 @@ function PMA_changePassDisplayPage($message, $sql_query) exit; } -/** - * Include error reporting script. - */ -require_once 'libraries/common_error_reporting.inc.php'; ?> diff --git a/view_create.php b/view_create.php index 8fbc679e05..75565b751b 100644 --- a/view_create.php +++ b/view_create.php @@ -285,9 +285,4 @@ $htmlString .= '' echo $htmlString; -/** - * Include error reporting script. - */ -require_once 'libraries/common_error_reporting.inc.php'; - ?> \ No newline at end of file diff --git a/view_operations.php b/view_operations.php index 45a8c3f26a..0e7970d882 100644 --- a/view_operations.php +++ b/view_operations.php @@ -137,8 +137,4 @@ echo ''; echo ''; echo ''; -/** - * Include error reporting script. - */ -require_once 'libraries/common_error_reporting.inc.php'; ?> \ No newline at end of file From 0b9439a246c4be55794d65bc589bb78b10ef4a5a Mon Sep 17 00:00:00 2001 From: Dhananjay Nakrani Date: Sat, 7 Jun 2014 18:40:54 +0530 Subject: [PATCH 19/35] Make automatic php error report submission ('sendErrorReport'='always') aysnchronous. Stop infinite auto error reporting loop. Signed-off-by: Dhananjay Nakrani --- error_report.php | 26 ++++++++++++++++++++- js/ajax.js | 11 +++++++-- libraries/Error_Handler.class.php | 39 +++++++++++++++++++------------ libraries/error_report.lib.php | 5 ++++ 4 files changed, 63 insertions(+), 18 deletions(-) diff --git a/error_report.php b/error_report.php index 6a3b672517..00f443cbf1 100644 --- a/error_report.php +++ b/error_report.php @@ -79,8 +79,32 @@ if (isset($_REQUEST['exception_type']) if (isset($_REQUEST['send_error_report']) && $_REQUEST['send_error_report'] == '1' ) { + /** + * Prevent inifnite error submission. + * Happens in case error submissions fails. + * If reporting is done in some time interval, just clear them & clear json data too. + */ + if (isset($_SESSION['prev_error_subm_time']) + && isset($_SESSION['error_subm_count']) + && $_SESSION['error_subm_count'] >= 3 // allow maximum 4 attempts + && ($_SESSION['prev_error_subm_time']-time()) <= 3000 // in 3 seconds + ) { + $_SESSION['error_subm_count'] = 0; + $_SESSION['prev_errors'] = ''; + $response = PMA_Response::getInstance(); + $response->addJSON('_stopErrorReportLoop', '1'); + } else { + $_SESSION['prev_error_subm_time'] = time(); + $_SESSION['error_subm_count'] = ( + (isset($_SESSION['error_subm_count'])) + ? ($_SESSION['error_subm_count']+1) + : (0) + ); + } + $reportData = PMA_getReportData('php'); - if ($reportData) { + // report if and only if there were 'actual' errors. + if($reportData) { $server_response = PMA_sendErrorReport($reportData); if ($server_response === false) { $success = false; diff --git a/js/ajax.js b/js/ajax.js index 005b32b334..0afc9de03f 100644 --- a/js/ajax.js +++ b/js/ajax.js @@ -397,8 +397,15 @@ var AJAX = { $('
', {id : 'pma_errors'}) .insertAfter('#selflink') .append(data._errors); - if(data._promptPhpErrors){ - msg = msg + PMA_messages['phpErrorsFound']; + // In case of 'sendErrorReport'='always' + // submit the hidden error reporting form. + if (data._sendErrorAlways == '1' + && data._stopErrorReportLoop != '1' + ) { + $("#pma_report_errors_form").submit(); + } else if (data._promptPhpErrors) { + // otherwise just prompt user if it is set so. + msg = msg + PMA_messages['phpErrorsFound']; // scroll to bottom where all the erros are displayed. $('html, body').animate({scrollTop:$(document).height()}, 'slow'); } diff --git a/libraries/Error_Handler.class.php b/libraries/Error_Handler.class.php index 12f08c07e4..52bed5370a 100644 --- a/libraries/Error_Handler.class.php +++ b/libraries/Error_Handler.class.php @@ -309,11 +309,16 @@ class PMA_Error_Handler } else { $retval .= $this->getDispUserErrors(); } - if($GLOBALS['cfg']['SendErrorReports'] == 'ask' // preference is 'ask' and + if($GLOBALS['cfg']['SendErrorReports'] != 'never' // preference is not 'never' and && $this->countErrors() != $this->countUserErrors() // there are 'actual' errors to be reported ){ // add report button. - $retval .= '
' + $retval .= '' @@ -324,10 +329,12 @@ class PMA_Error_Handler . '" id="pma_report_errors" style="float: right; margin: 20px;">' . '
'; - // add ignore buttons - $retval .=''; + if ($GLOBALS['cfg']['SendErrorReports'] == 'ask') { + // add ignore buttons + $retval .=''; + } $retval .=''; @@ -486,15 +493,17 @@ class PMA_Error_Handler $response = PMA_Response::getInstance(); $jsCode = ''; if ($GLOBALS['cfg']['SendErrorReports'] == 'always') { - //send the error reports directly - $_REQUEST['exception_type'] = 'php'; - $_REQUEST['send_error_report'] = '1'; - include_once 'error_report.php'; - - // js code to appropriate focusing, - $jsCode = '$("html, body").animate({ - scrollTop:$(document).height() - }, "slow");'; + if ($response->isAjax()) { + // set flag for automatic report submission. + $response->addJSON('_sendErrorAlways', '1'); + } else { + // send the error reports asynchronously & without asking user + $jsCode .= '$("#pma_report_errors_form").submit();'; + // js code to appropriate focusing, + $jsCode .= '$("html, body").animate({ + scrollTop:$(document).height() + }, "slow");'; + } } elseif ($GLOBALS['cfg']['SendErrorReports'] == 'ask') { //ask user whether to submit errors or not. if (!$response->isAjax()) { diff --git a/libraries/error_report.lib.php b/libraries/error_report.lib.php index fc3dd1df9e..46b314ee78 100644 --- a/libraries/error_report.lib.php +++ b/libraries/error_report.lib.php @@ -95,6 +95,11 @@ function PMA_getReportData($exception_type = 'js') $errors = array(); // create php error report $i=0; + if (!isset($_SESSION['prev_errors']) + || $_SESSION['prev_errors'] == '' + ) { + return false; + } foreach($_SESSION['prev_errors'] as $errorObj ) { if ($errorObj->getLine() && $errorObj->getType() && $errorObj->getNumber() != E_USER_WARNING) { $errors[$i++] = array( From c83457fb8a2ed9fc54dfd10193bd97bacab255e3 Mon Sep 17 00:00:00 2001 From: Dhananjay Nakrani Date: Sat, 7 Jun 2014 21:15:53 +0530 Subject: [PATCH 20/35] Display appropriate msg while automatically submitting php error report. Signed-off-by: Dhananjay Nakrani --- js/ajax.js | 1 + js/messages.php | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/js/ajax.js b/js/ajax.js index 0afc9de03f..4a016739d2 100644 --- a/js/ajax.js +++ b/js/ajax.js @@ -403,6 +403,7 @@ var AJAX = { && data._stopErrorReportLoop != '1' ) { $("#pma_report_errors_form").submit(); + PMA_ajaxShowMessage(PMA_messages['phpErrorsBeingSubmitted'], false); } else if (data._promptPhpErrors) { // otherwise just prompt user if it is set so. msg = msg + PMA_messages['phpErrorsFound']; diff --git a/js/messages.php b/js/messages.php index 1d284696bc..9fd159726c 100644 --- a/js/messages.php +++ b/js/messages.php @@ -438,6 +438,13 @@ $js_messages['phpErrorsFound'] = '
' . '" onclick="PMA_ignorePhpErrors(false)" style="float: right; margin: 20px;">' . '
'; +$js_messages['phpErrorsBeingSubmitted'] = '
' + . __('Some errors have been detected on the server!!') + . '
' + . __('As per your settings, they are being submitted currently.') + . __(' Please be patient.') + . '
'; + echo "var PMA_messages = new Array();\n"; foreach ($js_messages as $name => $js_message) { PMA_printJsValue("PMA_messages['" . $name . "']", $js_message); From e37616adbaecc93128dd31d57764abf140ee18dc Mon Sep 17 00:00:00 2001 From: Dhananjay Nakrani Date: Sun, 8 Jun 2014 16:18:34 +0530 Subject: [PATCH 21/35] Fix coding style issues. Signed-off-by: Dhananjay Nakrani --- error_report.php | 166 +++++++++++++++--------------- js/ajax.js | 2 +- libraries/Error.class.php | 9 +- libraries/Error_Handler.class.php | 60 +++++++---- libraries/Message.class.php | 5 +- libraries/error_report.lib.php | 23 +++-- 6 files changed, 144 insertions(+), 121 deletions(-) diff --git a/error_report.php b/error_report.php index 00f443cbf1..ca81dd7721 100644 --- a/error_report.php +++ b/error_report.php @@ -12,7 +12,7 @@ $response = PMA_Response::getInstance(); if (isset($_REQUEST['exception_type']) && $_REQUEST['exception_type'] == 'js' - ) { +) { if (isset($_REQUEST['send_error_report']) && $_REQUEST['send_error_report'] == true ) { @@ -73,94 +73,94 @@ if (isset($_REQUEST['exception_type']) } else { $response->addHTML(PMA_getErrorReportForm()); } -}elseif (isset($_REQUEST['exception_type']) - && $_REQUEST['exception_type'] == 'php' +} elseif (isset($_REQUEST['exception_type']) + && $_REQUEST['exception_type'] == 'php' +) { + if (isset($_REQUEST['send_error_report']) + && $_REQUEST['send_error_report'] == '1' + ) { + /** + * Prevent inifnite error submission. + * Happens in case error submissions fails. + * If reporting is done in some time interval, just clear them & clear json data too. + */ + if (isset($_SESSION['prev_error_subm_time']) + && isset($_SESSION['error_subm_count']) + && $_SESSION['error_subm_count'] >= 3 // allow maximum 4 attempts + && ($_SESSION['prev_error_subm_time']-time()) <= 3000 // in 3 seconds ) { - if (isset($_REQUEST['send_error_report']) - && $_REQUEST['send_error_report'] == '1' - ) { - /** - * Prevent inifnite error submission. - * Happens in case error submissions fails. - * If reporting is done in some time interval, just clear them & clear json data too. - */ - if (isset($_SESSION['prev_error_subm_time']) - && isset($_SESSION['error_subm_count']) - && $_SESSION['error_subm_count'] >= 3 // allow maximum 4 attempts - && ($_SESSION['prev_error_subm_time']-time()) <= 3000 // in 3 seconds - ) { - $_SESSION['error_subm_count'] = 0; - $_SESSION['prev_errors'] = ''; - $response = PMA_Response::getInstance(); - $response->addJSON('_stopErrorReportLoop', '1'); + $_SESSION['error_subm_count'] = 0; + $_SESSION['prev_errors'] = ''; + $response = PMA_Response::getInstance(); + $response->addJSON('_stopErrorReportLoop', '1'); + } else { + $_SESSION['prev_error_subm_time'] = time(); + $_SESSION['error_subm_count'] = ( + (isset($_SESSION['error_subm_count'])) + ? ($_SESSION['error_subm_count']+1) + : (0) + ); + } + + $reportData = PMA_getReportData('php'); + // report if and only if there were 'actual' errors. + if ($reportData) { + $server_response = PMA_sendErrorReport($reportData); + if ($server_response === false) { + $success = false; } else { - $_SESSION['prev_error_subm_time'] = time(); - $_SESSION['error_subm_count'] = ( - (isset($_SESSION['error_subm_count'])) - ? ($_SESSION['error_subm_count']+1) - : (0) - ); + $decoded_response = json_decode($server_response, true); + $success = !empty($decoded_response) ? $decoded_response["success"] : false; + } + + if ($GLOBALS['cfg']['SendErrorReports'] == 'ask') { + if ($success) { + $errSubmitMsg = PMA_Message::error( + __('Thank You for subitting error report!!') + . '
' + . __('Report has been succesfully submitted.') + ); + } else { + $errSubmitMsg = PMA_Message::error( + __('Thank You for subitting error report!!') + . '
' + . __(' Unfortunately submission failed.') + . '
' + . __(' If you experience any problems please submit a bug report manually.') + ); + } + } elseif ($GLOBALS['cfg']['SendErrorReports'] == 'always') { + if ($success) { + $errSubmitMsg = PMA_Message::error( + __( + 'An error has been detected on the server and an error report has been ' + . 'automatically submitted based on your settings.' + ) + ); + } else { + $errSubmitMsg = PMA_Message::error( + __( + 'An error has been detected and an error report has been ' + . 'generated but failed to be sent.' + ) + . '
' + . __('If you experience any problems please submit a bug report manually.') + ); + } } - $reportData = PMA_getReportData('php'); - // report if and only if there were 'actual' errors. - if($reportData) { - $server_response = PMA_sendErrorReport($reportData); - if ($server_response === false) { - $success = false; - } else { - $decoded_response = json_decode($server_response, true); - $success = !empty($decoded_response) ? $decoded_response["success"] : false; - } - - if($GLOBALS['cfg']['SendErrorReports'] == 'ask'){ - if($success) { - $errSubmitMsg = PMA_Message::error( - __('Thank You for subitting error report!!') - . '
' - . __('Report has been succesfully submitted.') - ); - } else { - $errSubmitMsg = PMA_Message::error( - __('Thank You for subitting error report!!') - . '
' - . __(' Unfortunately submission failed.') - . '
' - . __(' If you experience any problems please submit a bug report manually.') - ); - } - } elseif($GLOBALS['cfg']['SendErrorReports'] == 'always') { - if($success) { - $errSubmitMsg = PMA_Message::error( - __( - 'An error has been detected on the server and an error report has been ' - . 'automatically submitted based on your settings.' - ) - ); - } else { - $errSubmitMsg = PMA_Message::error( - __( - 'An error has been detected and an error report has been ' - . 'generated but failed to be sent.' - ) - . '
' - . __('If you experience any problems please submit a bug report manually.') - ); - } - } - - if($response->isAjax()) { - $response->addJSON('_errSubmitMsg',$errSubmitMsg); - } else { - $jsCode = 'PMA_ajaxShowMessage("
' - .$errSubmitMsg - .'
", false);'; - $response->getFooter()->getScripts()->addCode($jsCode); - } + if ($response->isAjax()) { + $response->addJSON('_errSubmitMsg', $errSubmitMsg); + } else { + $jsCode = 'PMA_ajaxShowMessage("
' + . $errSubmitMsg + . '
", false);'; + $response->getFooter()->getScripts()->addCode($jsCode); } } - // clear previous errors & save new ones. - $GLOBALS['error_handler']->savePreviousErrors(); + } + // clear previous errors & save new ones. + $GLOBALS['error_handler']->savePreviousErrors(); } else { die('Oops, something went wrong!!'); } diff --git a/js/ajax.js b/js/ajax.js index 4a016739d2..39a05cb87c 100644 --- a/js/ajax.js +++ b/js/ajax.js @@ -388,7 +388,7 @@ var AJAX = { } $('#pma_errors').remove(); - + var msg = ''; if(data._errSubmitMsg){ msg = data._errSubmitMsg; diff --git a/libraries/Error.class.php b/libraries/Error.class.php index 4c943f0d28..842af8c66e 100644 --- a/libraries/Error.class.php +++ b/libraries/Error.class.php @@ -189,14 +189,17 @@ class PMA_Error extends PMA_Message /** * returns PMA_Error::$_backtrace for first $count frames - * pass $count = -1 to get full backtrace. The same can be done by not passing $count at all. + * pass $count = -1 to get full backtrace. + * The same can be done by not passing $count at all. + * + * @param integer $count Number of stack frames. + * * @return array PMA_Error::$_backtrace */ public function getBacktrace($count = -1) { - if($count != -1) { + if ($count != -1) { return array_slice($this->backtrace, 0, $count); - } return $this->backtrace; } diff --git a/libraries/Error_Handler.class.php b/libraries/Error_Handler.class.php index 52bed5370a..08ff7425cb 100644 --- a/libraries/Error_Handler.class.php +++ b/libraries/Error_Handler.class.php @@ -95,8 +95,10 @@ class PMA_Error_Handler } /** - * returns the errorsoccured in the current run only. Does not include the errors save din the SESSION + * returns the errors occured in the current run only. + * Does not include the errors save din the SESSION * + * @return array of current errors */ public function getCurrentErrors() { @@ -293,7 +295,7 @@ class PMA_Error_Handler // display errors if SendErrorReports is set to 'ask'. if ($GLOBALS['cfg']['SendErrorReports'] != 'never' || $GLOBALS['cfg']['Error_Handler']['display'] - ) { + ) { foreach ($this->getErrors() as $error) { if ($error instanceof PMA_Error) { if (! $error->isDisplayed()) { @@ -309,11 +311,14 @@ class PMA_Error_Handler } else { $retval .= $this->getDispUserErrors(); } - if($GLOBALS['cfg']['SendErrorReports'] != 'never' // preference is not 'never' and - && $this->countErrors() != $this->countUserErrors() // there are 'actual' errors to be reported - ){ + // if preference is not 'never' and + // there are 'actual' errors to be reported + if ($GLOBALS['cfg']['SendErrorReports'] != 'never' + && $this->countErrors() != $this->countUserErrors() + ) { // add report button. - $retval .= '
'; + $retval .= ''; } - $retval .=''; + $retval .= ''; } return $retval; } @@ -433,7 +442,7 @@ class PMA_Error_Handler { if ($GLOBALS['cfg']['SendErrorReports'] != 'never' || $GLOBALS['cfg']['Error_Handler']['display'] - ) { + ) { return $this->countErrors(); } else { return $this->countUserErrors(); @@ -454,7 +463,8 @@ class PMA_Error_Handler * Deletes prevsiously stored errors in SESSION. * Saves current errors in session as previous errros. * Required to save current errors in case 'ask' - * + * + * @return void */ public function savePreviousErrors() { @@ -464,25 +474,30 @@ class PMA_Error_Handler /** * Function to check if there are any errors to be prompted. - * Needed because user warnings raised are also collected by global error handler. - * This dishtingushes between the actual errors and user errors raised to warn user. + * Needed because user warnings raised are + * also collected by global error handler. + * This dishtingushes between the actual errors + * and user errors raised to warn user. * *@return boolean: true if there are errors to be "prompted", false otherwise */ public function hasErrorsForPrompt() { return ( - ($GLOBALS['cfg']['SendErrorReports'] != 'never' || $GLOBALS['cfg']['Error_Handler']['display']) - && $this->countErrors() != $this->countUserErrors() - ); + ($GLOBALS['cfg']['SendErrorReports'] != 'never' + || $GLOBALS['cfg']['Error_Handler']['display']) + && $this->countErrors() != $this->countUserErrors() + ); } /** * Function to report all the collected php errors. - * Must be called at the end of each script by the $GLOBALS['error_handler'] only. + * Must be called at the end of each script + * by the $GLOBALS['error_handler'] only. * - * @return: void + * @return void */ + public function reportError() { if (!$this->hasErrors()) { @@ -508,7 +523,8 @@ class PMA_Error_Handler //ask user whether to submit errors or not. if (!$response->isAjax()) { // js code to show appropriate msgs & focusing, - $jsCode = 'PMA_ajaxShowMessage(PMA_messages["phpErrorsFound"], 2000);' + $jsCode = 'PMA_ajaxShowMessage(PMA_messages["phpErrorsFound"], ' + . ' 2000);' . '$("html, body").animate({ scrollTop:$(document).height() }, "slow");'; diff --git a/libraries/Message.class.php b/libraries/Message.class.php index b95b2e6b0f..6bffe87b7c 100644 --- a/libraries/Message.class.php +++ b/libraries/Message.class.php @@ -656,8 +656,9 @@ class PMA_Message } /** - * Returns only message string without image & other HTML. - * @return: $message string + * Returns only message string without image & other HTML. + * + * @return $message string */ public function getOnlyMessage() { diff --git a/libraries/error_report.lib.php b/libraries/error_report.lib.php index 46b314ee78..12a9140166 100644 --- a/libraries/error_report.lib.php +++ b/libraries/error_report.lib.php @@ -52,7 +52,9 @@ function PMA_getPrettyReportData() * returns the error report data collected from the current configuration or * from the request parameters sent by the error reporting js code. * - * @return Array/String the report. + * @param string $exception_type whether exception is 'js' or 'php' + * + * @return Array/String the report. * False if there're no 'actual' errors to be reported (case for php errors) */ function PMA_getReportData($exception_type = 'js') @@ -72,7 +74,7 @@ function PMA_getReportData($exception_type = 'js') "php_version" => phpversion() ); - if($exception_type == 'js') { + if ($exception_type == 'js') { if (empty($_REQUEST['exception'])) { return ''; } @@ -90,8 +92,7 @@ function PMA_getReportData($exception_type = 'js') if (! empty($_REQUEST['description'])) { $report['steps'] = $_REQUEST['description']; } - } - elseif($exception_type == 'php'){ + } elseif ($exception_type == 'php') { $errors = array(); // create php error report $i=0; @@ -100,8 +101,11 @@ function PMA_getReportData($exception_type = 'js') ) { return false; } - foreach($_SESSION['prev_errors'] as $errorObj ) { - if ($errorObj->getLine() && $errorObj->getType() && $errorObj->getNumber() != E_USER_WARNING) { + foreach ($_SESSION['prev_errors'] as $errorObj) { + if ($errorObj->getLine() + && $errorObj->getType() + && $errorObj->getNumber() != E_USER_WARNING + ) { $errors[$i++] = array( "lineNum" => $errorObj->getLine(), "file" => $errorObj->getFile(), @@ -114,14 +118,13 @@ function PMA_getReportData($exception_type = 'js') } } - // if there were no 'actual' errors to be submitted. - if($i==0) { + // if there were no 'actual' errors to be submitted. + if ($i==0) { return false; // then return false } $report ["exception_type"] = 'php'; $report["errors"] = $errors; - } - else{ + } else { return false; } From 006f041c070089730713341b5bbb554efb0d3f08 Mon Sep 17 00:00:00 2001 From: Dhananjay Nakrani Date: Tue, 10 Jun 2014 21:53:50 +0530 Subject: [PATCH 22/35] Stop one more 'false alarm', case of non-AJAX request. Signed-off-by: Dhananjay Nakrani --- libraries/Error_Handler.class.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libraries/Error_Handler.class.php b/libraries/Error_Handler.class.php index 08ff7425cb..51c17a213c 100644 --- a/libraries/Error_Handler.class.php +++ b/libraries/Error_Handler.class.php @@ -500,7 +500,11 @@ class PMA_Error_Handler public function reportError() { - if (!$this->hasErrors()) { + // if there're no actual errors, + if (!$this->hasErrors() + || $this->countErrors() == $this->countUserErrors() + ) { + // then simply return. return; } // Delete all the prev_errors in session & store new prev_errors in session From d01323886b207a877fd6ab4f5cd6577aa6ff7b37 Mon Sep 17 00:00:00 2001 From: Dhananjay Nakrani Date: Tue, 10 Jun 2014 21:57:39 +0530 Subject: [PATCH 23/35] Display error automatically being submitted message in non-AJAX case too. Signed-off-by: Dhananjay Nakrani --- libraries/Error_Handler.class.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/Error_Handler.class.php b/libraries/Error_Handler.class.php index 51c17a213c..8e7e14d0ad 100644 --- a/libraries/Error_Handler.class.php +++ b/libraries/Error_Handler.class.php @@ -517,7 +517,8 @@ class PMA_Error_Handler $response->addJSON('_sendErrorAlways', '1'); } else { // send the error reports asynchronously & without asking user - $jsCode .= '$("#pma_report_errors_form").submit();'; + $jsCode .= '$("#pma_report_errors_form").submit();' + . 'PMA_ajaxShowMessage(PMA_messages["phpErrorsBeingSubmitted"], false);'; // js code to appropriate focusing, $jsCode .= '$("html, body").animate({ scrollTop:$(document).height() From 30d1a03ab625c1de17c87ad2a9cbb4aa0d9b3d55 Mon Sep 17 00:00:00 2001 From: Dhananjay Nakrani Date: Tue, 10 Jun 2014 22:50:20 +0530 Subject: [PATCH 24/35] Rename function to a sensible name. Signed-off-by: Dhananjay Nakrani --- libraries/Error_Handler.class.php | 2 +- libraries/Footer.class.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/Error_Handler.class.php b/libraries/Error_Handler.class.php index 8e7e14d0ad..0d34dc972c 100644 --- a/libraries/Error_Handler.class.php +++ b/libraries/Error_Handler.class.php @@ -498,7 +498,7 @@ class PMA_Error_Handler * @return void */ - public function reportError() + public function reportErrors() { // if there're no actual errors, if (!$this->hasErrors() diff --git a/libraries/Footer.class.php b/libraries/Footer.class.php index a97e619875..a114d5e2f4 100644 --- a/libraries/Footer.class.php +++ b/libraries/Footer.class.php @@ -213,7 +213,7 @@ class PMA_Footer /** * Report php errors */ - $GLOBALS['error_handler']->reportError(); + $GLOBALS['error_handler']->reportErrors(); return $retval; } From bc76f04ce73965bd8dfd2dd8022588d0ebf62cbf Mon Sep 17 00:00:00 2001 From: Dhananjay Nakrani Date: Tue, 10 Jun 2014 22:59:30 +0530 Subject: [PATCH 25/35] Remove trailing whitespaces. Signed-off-by: Dhananjay Nakrani --- error_report.php | 8 ++++---- js/functions.js | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/error_report.php b/error_report.php index ca81dd7721..719756ca96 100644 --- a/error_report.php +++ b/error_report.php @@ -10,7 +10,7 @@ require_once 'libraries/error_report.lib.php'; $response = PMA_Response::getInstance(); -if (isset($_REQUEST['exception_type']) +if (isset($_REQUEST['exception_type']) && $_REQUEST['exception_type'] == 'js' ) { if (isset($_REQUEST['send_error_report']) @@ -73,14 +73,14 @@ if (isset($_REQUEST['exception_type']) } else { $response->addHTML(PMA_getErrorReportForm()); } -} elseif (isset($_REQUEST['exception_type']) +} elseif (isset($_REQUEST['exception_type']) && $_REQUEST['exception_type'] == 'php' ) { if (isset($_REQUEST['send_error_report']) && $_REQUEST['send_error_report'] == '1' ) { /** - * Prevent inifnite error submission. + * Prevent inifnite error submission. * Happens in case error submissions fails. * If reporting is done in some time interval, just clear them & clear json data too. */ @@ -112,7 +112,7 @@ if (isset($_REQUEST['exception_type']) $decoded_response = json_decode($server_response, true); $success = !empty($decoded_response) ? $decoded_response["success"] : false; } - + if ($GLOBALS['cfg']['SendErrorReports'] == 'ask') { if ($success) { $errSubmitMsg = PMA_Message::error( diff --git a/js/functions.js b/js/functions.js index c5e8975d44..7f9a86694c 100644 --- a/js/functions.js +++ b/js/functions.js @@ -4384,15 +4384,15 @@ function PMA_previewSQL($form) * Ignore the displayed php errors. * Simply removes the displayed errors. * - * @param clearPrevErrors whether to clear errors stored + * @param clearPrevErrors whether to clear errors stored * in $_SESSION['prev_errors'] at server * */ function PMA_ignorePhpErrors(clearPrevErrors){ - if (typeof(clearPrevErrors) === "undefined" + if (typeof(clearPrevErrors) === "undefined" || clearPrevErrors === null - ) { - str = false; + ) { + str = false; } // send AJAX request to error_report.php with send_error_report=0, exception_type=php & token. // It clears the prev_errors stored in session. From caaacefcbebb79116ae7d8b2cb43fe8f08207d18 Mon Sep 17 00:00:00 2001 From: Dhananjay Nakrani Date: Wed, 11 Jun 2014 00:01:52 +0530 Subject: [PATCH 26/35] Move inline JS to 'binded' JS. Signed-off-by: Dhananjay Nakrani --- js/ajax.js | 16 ++++++++++++++++ js/messages.php | 8 ++++---- libraries/Error_Handler.class.php | 20 +++++++++++++++----- 3 files changed, 35 insertions(+), 9 deletions(-) diff --git a/js/ajax.js b/js/ajax.js index 39a05cb87c..5af4affcde 100644 --- a/js/ajax.js +++ b/js/ajax.js @@ -397,6 +397,15 @@ var AJAX = { $('
', {id : 'pma_errors'}) .insertAfter('#selflink') .append(data._errors); + // bind for php error reporting forms (bottom) + $("#pma_ignore_errors_bottom").bind("click", + function() { + PMA_ignorePhpErrors() + }); + $("#pma_ignore_all_errors_bottom").bind("click", + function() { + PMA_ignorePhpErrors(false) + }); // In case of 'sendErrorReport'='always' // submit the hidden error reporting form. if (data._sendErrorAlways == '1' @@ -412,6 +421,13 @@ var AJAX = { } } PMA_ajaxShowMessage(msg, false); + // bind for php error reporting forms (popup) + $("#pma_ignore_errors_popup").bind("click", function() { + PMA_ignorePhpErrors() + }); + $("#pma_ignore_all_errors_popup").bind("click", function() { + PMA_ignorePhpErrors(false) + }); if (typeof AJAX._callback === 'function') { AJAX._callback.call(); diff --git a/js/messages.php b/js/messages.php index 9fd159726c..59146e83bc 100644 --- a/js/messages.php +++ b/js/messages.php @@ -430,12 +430,12 @@ $js_messages['phpErrorsFound'] = '
' . __('Warning: Some errors have been detected on the server!!') . '
' . __('Please look at the bottom of this window.') - . '' - . '' + . '' + . '" style="float: right; margin: 20px;">' . '
'; $js_messages['phpErrorsBeingSubmitted'] = '
' diff --git a/libraries/Error_Handler.class.php b/libraries/Error_Handler.class.php index 0d34dc972c..5eca90caba 100644 --- a/libraries/Error_Handler.class.php +++ b/libraries/Error_Handler.class.php @@ -338,14 +338,12 @@ class PMA_Error_Handler // add ignore buttons $retval .= ''; } $retval .= ''; } return $retval; @@ -527,9 +525,21 @@ class PMA_Error_Handler } elseif ($GLOBALS['cfg']['SendErrorReports'] == 'ask') { //ask user whether to submit errors or not. if (!$response->isAjax()) { - // js code to show appropriate msgs & focusing, + // js code to show appropriate msgs, event binding & focusing. $jsCode = 'PMA_ajaxShowMessage(PMA_messages["phpErrorsFound"], ' . ' 2000);' + . '$("#pma_ignore_errors_popup").bind("click", function() { + PMA_ignorePhpErrors() + });' + . '$("#pma_ignore_all_errors_popup").bind("click", function() { + PMA_ignorePhpErrors(false) + });' + . '$("#pma_ignore_errors_bottom").bind("click", function() { + PMA_ignorePhpErrors() + });' + . '$("#pma_ignore_all_errors_bottom").bind("click", function() { + PMA_ignorePhpErrors(false) + });' . '$("html, body").animate({ scrollTop:$(document).height() }, "slow");'; From b2e31644410328690807a23bd63eb66cff1e034b Mon Sep 17 00:00:00 2001 From: Dhananjay Nakrani Date: Wed, 11 Jun 2014 15:55:36 +0530 Subject: [PATCH 27/35] Make return values of PMA_getReportData() consistent. Signed-off-by: Dhananjay Nakrani --- error_report.php | 2 +- libraries/error_report.lib.php | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/error_report.php b/error_report.php index 719756ca96..9a4cddf53c 100644 --- a/error_report.php +++ b/error_report.php @@ -104,7 +104,7 @@ if (isset($_REQUEST['exception_type']) $reportData = PMA_getReportData('php'); // report if and only if there were 'actual' errors. - if ($reportData) { + if (count($reportData) > 0) { $server_response = PMA_sendErrorReport($reportData); if ($server_response === false) { $success = false; diff --git a/libraries/error_report.lib.php b/libraries/error_report.lib.php index 12a9140166..c227efacdd 100644 --- a/libraries/error_report.lib.php +++ b/libraries/error_report.lib.php @@ -54,8 +54,7 @@ function PMA_getPrettyReportData() * * @param string $exception_type whether exception is 'js' or 'php' * - * @return Array/String the report. - * False if there're no 'actual' errors to be reported (case for php errors) + * @return Array error report if success, Empty Array otherwise */ function PMA_getReportData($exception_type = 'js') { @@ -76,7 +75,7 @@ function PMA_getReportData($exception_type = 'js') if ($exception_type == 'js') { if (empty($_REQUEST['exception'])) { - return ''; + return array(); } $exception = $_REQUEST['exception']; $exception["stack"] = PMA_translateStacktrace($exception["stack"]); @@ -99,7 +98,7 @@ function PMA_getReportData($exception_type = 'js') if (!isset($_SESSION['prev_errors']) || $_SESSION['prev_errors'] == '' ) { - return false; + return array(); } foreach ($_SESSION['prev_errors'] as $errorObj) { if ($errorObj->getLine() @@ -120,12 +119,12 @@ function PMA_getReportData($exception_type = 'js') // if there were no 'actual' errors to be submitted. if ($i==0) { - return false; // then return false + return array(); // then return empty array } $report ["exception_type"] = 'php'; $report["errors"] = $errors; } else { - return false; + return array(); } return $report; From bfef3e80dffe2149258d135ba0f94e798704e522 Mon Sep 17 00:00:00 2001 From: Dhananjay Nakrani Date: Wed, 11 Jun 2014 16:28:21 +0530 Subject: [PATCH 28/35] Remove unnecessarily added empty lines. Signed-off-by: Dhananjay Nakrani --- browse_foreigners.php | 1 - db_create.php | 1 - db_printview.php | 1 - db_qbe.php | 1 - db_search.php | 1 - file_echo.php | 1 - gis_data_editor.php | 1 - import.php | 1 - import_status.php | 1 - index.php | 1 - navigation.php | 1 - phpinfo.php | 1 - pmd_general.php | 1 - pmd_pdf.php | 1 - pmd_relation_new.php | 1 - pmd_save_pos.php | 1 - prefs_forms.php | 1 - querywindow.php | 1 - schema_export.php | 1 - server_replication.php | 1 - server_status_monitor.php | 1 - server_status_queries.php | 1 - server_user_groups.php | 1 - tbl_addfield.php | 1 - tbl_change.php | 1 - tbl_chart.php | 1 - tbl_export.php | 1 - tbl_get_field.php | 1 - tbl_indexes.php | 1 - tbl_move_copy.php | 1 - tbl_relation.php | 1 - tbl_replace.php | 1 - tbl_row_action.php | 1 - tbl_select.php | 1 - tbl_structure.php | 1 - tbl_zoom_select.php | 1 - transformation_wrapper.php | 1 - url.php | 1 - user_password.php | 1 - view_create.php | 3 +-- view_operations.php | 3 +-- 41 files changed, 2 insertions(+), 43 deletions(-) diff --git a/browse_foreigners.php b/browse_foreigners.php index 36fa329145..daeaf47efe 100644 --- a/browse_foreigners.php +++ b/browse_foreigners.php @@ -58,5 +58,4 @@ $html = PMA_getHtmlForRelationalFieldSelection( ); $response->addHtml($html); - ?> diff --git a/db_create.php b/db_create.php index f829139fdb..85443a466e 100644 --- a/db_create.php +++ b/db_create.php @@ -133,5 +133,4 @@ if (! $result) { include_once '' . $cfg['DefaultTabDatabase']; } } - ?> diff --git a/db_printview.php b/db_printview.php index c124fbc1f7..137bdaaf78 100644 --- a/db_printview.php +++ b/db_printview.php @@ -177,5 +177,4 @@ if ($num_tables == 0) { echo PMA_Util::getButton(); echo "
\n"; - ?> diff --git a/db_qbe.php b/db_qbe.php index c58c865ba7..641bed304c 100644 --- a/db_qbe.php +++ b/db_qbe.php @@ -130,5 +130,4 @@ if ($cfgRelation['designerwork']) { } $response->addHTML($db_qbe->getSelectionForm($cfgRelation)); - ?> diff --git a/db_search.php b/db_search.php index 17237eb000..364ff521f6 100644 --- a/db_search.php +++ b/db_search.php @@ -60,5 +60,4 @@ $response->addHTML( ); $response->addHTML($db_search->getSelectionForm()); $response->addHTML($db_search->getResultDivs()); - ?> diff --git a/file_echo.php b/file_echo.php index 1d8c569d84..d910b74e28 100644 --- a/file_echo.php +++ b/file_echo.php @@ -68,5 +68,4 @@ if (isset($_REQUEST['filename']) && isset($_REQUEST['image'])) { } echo file_get_contents($_FILES['file']['tmp_name']); } - ?> diff --git a/gis_data_editor.php b/gis_data_editor.php index 6ece3213d5..546f700fb7 100644 --- a/gis_data_editor.php +++ b/gis_data_editor.php @@ -421,5 +421,4 @@ echo ''; PMA_Response::getInstance()->addJSON('gis_editor', ob_get_contents()); ob_end_clean(); - ?> diff --git a/import.php b/import.php index 67e19e684d..a96b159a83 100644 --- a/import.php +++ b/import.php @@ -669,5 +669,4 @@ if ($go_sql) { $active_page = $goto; include '' . $goto; } - ?> diff --git a/import_status.php b/import_status.php index 43dcd07ee8..45e11fcd31 100644 --- a/import_status.php +++ b/import_status.php @@ -98,5 +98,4 @@ if (isset($_GET["message"]) && $_GET["message"]) { } else { PMA_importAjaxStatus($_GET["id"]); } - ?> diff --git a/index.php b/index.php index 50af41073f..c23250e1dc 100644 --- a/index.php +++ b/index.php @@ -662,5 +662,4 @@ function PMA_printListItem($name, $listId = null, $url = null, } echo ''; } - ?> diff --git a/navigation.php b/navigation.php index a30b725af8..2c35311e50 100644 --- a/navigation.php +++ b/navigation.php @@ -68,5 +68,4 @@ if ($cfgRelation['navwork']) { // Do the magic $response->addJSON('message', $navigation->getDisplay()); - ?> diff --git a/phpinfo.php b/phpinfo.php index f9e415987f..5854ff4c9e 100644 --- a/phpinfo.php +++ b/phpinfo.php @@ -18,5 +18,4 @@ PMA_Response::getInstance()->disable(); if ($GLOBALS['cfg']['ShowPhpInfo']) { phpinfo(); } - ?> diff --git a/pmd_general.php b/pmd_general.php index fd87da586a..e6100c96b3 100644 --- a/pmd_general.php +++ b/pmd_general.php @@ -935,5 +935,4 @@ echo '' . '
'; - ?> diff --git a/pmd_pdf.php b/pmd_pdf.php index d4f64c938e..11982528c0 100644 --- a/pmd_pdf.php +++ b/pmd_pdf.php @@ -156,5 +156,4 @@ echo ''; echo '
'; echo ''; echo '
'; - ?> diff --git a/pmd_relation_new.php b/pmd_relation_new.php index 2f58909021..134450b445 100644 --- a/pmd_relation_new.php +++ b/pmd_relation_new.php @@ -130,5 +130,4 @@ function PMD_Return_new($b,$ret) '" F2="' . urlencode($F2) . '">'); } - ?> diff --git a/pmd_save_pos.php b/pmd_save_pos.php index faf601cd37..026440b6b4 100644 --- a/pmd_save_pos.php +++ b/pmd_save_pos.php @@ -84,5 +84,4 @@ if (! empty($die_save_pos)) { echo ''; } - ?> diff --git a/prefs_forms.php b/prefs_forms.php index 1001098979..2cc37bfa8e 100644 --- a/prefs_forms.php +++ b/prefs_forms.php @@ -89,5 +89,4 @@ if ($form_display->hasErrors()) { display(true, true); - ?> diff --git a/querywindow.php b/querywindow.php index c7ae7a9548..f14f600e66 100644 --- a/querywindow.php +++ b/querywindow.php @@ -205,5 +205,4 @@ echo ''; echo ''; echo ''; - ?> diff --git a/schema_export.php b/schema_export.php index 3bff640b2e..aba067345b 100644 --- a/schema_export.php +++ b/schema_export.php @@ -72,5 +72,4 @@ if (isset($_REQUEST['do'])) { $user_schema->setAction($_REQUEST['do']); $user_schema->processUserChoice(); } - ?> diff --git a/server_replication.php b/server_replication.php index f660598ed6..9f1f2ae6f7 100644 --- a/server_replication.php +++ b/server_replication.php @@ -80,5 +80,4 @@ if (! isset($_REQUEST['repl_clear_scr'])) { if (isset($_REQUEST['sl_configure'])) { $response->addHTML(PMA_getHtmlForReplicationChangeMaster("slave_changemaster")); } - ?> diff --git a/server_status_monitor.php b/server_status_monitor.php index 679b25fafc..958bed2066 100644 --- a/server_status_monitor.php +++ b/server_status_monitor.php @@ -110,7 +110,6 @@ $response->addHTML($ServerStatusData->getMenuHtml()); $response->addHTML(PMA_getHtmlForMonitor($ServerStatusData)); $response->addHTML(PMA_getHtmlForClientSideDataAndLinks($ServerStatusData)); $response->addHTML(''); - exit; ?> diff --git a/server_status_queries.php b/server_status_queries.php index 3360d36e19..b895843292 100644 --- a/server_status_queries.php +++ b/server_status_queries.php @@ -48,7 +48,6 @@ $response->addHTML('
'); $response->addHTML($ServerStatusData->getMenuHtml()); $response->addHTML(PMA_getHtmlForQueryStatistics($ServerStatusData)); $response->addHTML('
'); - exit; ?> diff --git a/server_user_groups.php b/server_user_groups.php index 531f20a856..7236a91615 100644 --- a/server_user_groups.php +++ b/server_user_groups.php @@ -61,5 +61,4 @@ if (isset($_REQUEST['addUserGroup'])) { } $response->addHTML(''); - ?> \ No newline at end of file diff --git a/tbl_addfield.php b/tbl_addfield.php index f93b765935..e679bd5ca3 100644 --- a/tbl_addfield.php +++ b/tbl_addfield.php @@ -114,5 +114,4 @@ if ($abort == false) { $action = 'tbl_addfield.php'; include_once 'libraries/tbl_columns_definition_form.inc.php'; } - ?> diff --git a/tbl_change.php b/tbl_change.php index 572390a869..dee996ca73 100644 --- a/tbl_change.php +++ b/tbl_change.php @@ -212,5 +212,4 @@ if ($insert_mode) { } $response->addHTML($html_output); - ?> diff --git a/tbl_chart.php b/tbl_chart.php index 842ca5fb7d..f5a6264d33 100644 --- a/tbl_chart.php +++ b/tbl_chart.php @@ -136,5 +136,4 @@ $htmlString = PMA_getHtmlForTableChartDisplay( ); $response->addHTML($htmlString); - ?> diff --git a/tbl_export.php b/tbl_export.php index b5bca4d885..f49b7eff5e 100644 --- a/tbl_export.php +++ b/tbl_export.php @@ -84,5 +84,4 @@ if (! empty($sql_query)) { $export_type = 'table'; require_once 'libraries/display_export.inc.php'; - ?> diff --git a/tbl_get_field.php b/tbl_get_field.php index 42ec09c7f1..3c9a867117 100644 --- a/tbl_get_field.php +++ b/tbl_get_field.php @@ -52,5 +52,4 @@ PMA_downloadHeader( strlen($result) ); echo $result; - ?> diff --git a/tbl_indexes.php b/tbl_indexes.php index 145e4aaf51..e095ded833 100644 --- a/tbl_indexes.php +++ b/tbl_indexes.php @@ -45,5 +45,4 @@ $response->addHTML($html); $header = $response->getHeader(); $scripts = $header->getScripts(); $scripts->addFile('indexes.js'); - ?> diff --git a/tbl_move_copy.php b/tbl_move_copy.php index 140d93e8cc..402da2efcb 100644 --- a/tbl_move_copy.php +++ b/tbl_move_copy.php @@ -101,5 +101,4 @@ if ($GLOBALS['is_ajax_request'] == true) { */ $_message = $message; unset($message); - ?> diff --git a/tbl_relation.php b/tbl_relation.php index 1ed7645164..9be5f6260c 100644 --- a/tbl_relation.php +++ b/tbl_relation.php @@ -157,5 +157,4 @@ if (PMA_Util::isForeignKeySupported($tbl_storage_engine)) { } // Render HTML output PMA_Response::getInstance()->addHTML($html_output); - ?> diff --git a/tbl_replace.php b/tbl_replace.php index 390ec0f34e..fae9eb2cb8 100644 --- a/tbl_replace.php +++ b/tbl_replace.php @@ -403,7 +403,6 @@ if (isset($_REQUEST['after_insert']) && 'new_insert' == $_REQUEST['after_insert' * Load target page. */ require '' . PMA_securePath($goto_include); - exit; ?> diff --git a/tbl_row_action.php b/tbl_row_action.php index e34eeb5469..51a1889e38 100644 --- a/tbl_row_action.php +++ b/tbl_row_action.php @@ -139,5 +139,4 @@ if (!empty($submit_mult)) { ); } } - ?> diff --git a/tbl_select.php b/tbl_select.php index 7843f1d170..49cd391ce9 100644 --- a/tbl_select.php +++ b/tbl_select.php @@ -70,5 +70,4 @@ if (! isset($_POST['columnsToDisplay']) && ! isset($_POST['displayAllColumns'])) null, null ); } - ?> diff --git a/tbl_structure.php b/tbl_structure.php index c226851084..b40c57dabc 100644 --- a/tbl_structure.php +++ b/tbl_structure.php @@ -161,5 +161,4 @@ $hidden_titles = PMA_getHiddenTitlesArray(); //display table structure require_once 'libraries/display_structure.inc.php'; - ?> diff --git a/tbl_zoom_select.php b/tbl_zoom_select.php index 80d0e2e925..7f4ceea329 100644 --- a/tbl_zoom_select.php +++ b/tbl_zoom_select.php @@ -160,5 +160,4 @@ if (isset($_POST['zoom_submit']) //Displays form for point data and scatter plot $response->addHTML($table_search->getZoomResultsForm($goto, $data)); } - ?> diff --git a/transformation_wrapper.php b/transformation_wrapper.php index 263c905678..ac0b04973d 100644 --- a/transformation_wrapper.php +++ b/transformation_wrapper.php @@ -145,5 +145,4 @@ if (! isset($_REQUEST['resize'])) { ImageDestroy($srcImage); ImageDestroy($destImage); } - ?> diff --git a/url.php b/url.php index 5835409a7d..71efc9fb6b 100644 --- a/url.php +++ b/url.php @@ -30,6 +30,5 @@ if (! PMA_isValid($_GET['url']) // Display redirecting msg on screen. printf(__('Taking you to %s.'), htmlspecialchars($_GET['url'])); } - die(); ?> diff --git a/user_password.php b/user_password.php index aa006aeac7..17f1eca105 100644 --- a/user_password.php +++ b/user_password.php @@ -197,5 +197,4 @@ function PMA_changePassDisplayPage($message, $sql_query) . '' . __('Back') . ''; exit; } - ?> diff --git a/view_create.php b/view_create.php index 75565b751b..2c8a410793 100644 --- a/view_create.php +++ b/view_create.php @@ -284,5 +284,4 @@ $htmlString .= '' . ''; echo $htmlString; - -?> \ No newline at end of file +?> diff --git a/view_operations.php b/view_operations.php index 0e7970d882..153249a3df 100644 --- a/view_operations.php +++ b/view_operations.php @@ -136,5 +136,4 @@ echo PMA_getDeleteDataOrTableLink( echo ''; echo ''; echo ''; - -?> \ No newline at end of file +?> From b621ab927711a31cc02626c4d65f6c0be58b40e4 Mon Sep 17 00:00:00 2001 From: Dhananjay Nakrani Date: Thu, 12 Jun 2014 12:04:49 +0530 Subject: [PATCH 29/35] Merge paths for 'php'& 'js' error reporting. Signed-off-by: Dhananjay Nakrani --- error_report.php | 204 +++++++++++++++++++---------------------------- 1 file changed, 83 insertions(+), 121 deletions(-) diff --git a/error_report.php b/error_report.php index 9a4cddf53c..6c373aafb4 100644 --- a/error_report.php +++ b/error_report.php @@ -8,77 +8,19 @@ require_once 'libraries/common.inc.php'; require_once 'libraries/error_report.lib.php'; +if (!isset($_REQUEST['exception_type']) + ||!in_array($_REQUEST['exception_type'], array('js', 'php')) +) { + die('Oops, something went wrong!!'); +} + $response = PMA_Response::getInstance(); -if (isset($_REQUEST['exception_type']) - && $_REQUEST['exception_type'] == 'js' +if (isset($_REQUEST['send_error_report']) + && ($_REQUEST['send_error_report'] == true + || $_REQUEST['send_error_report'] == '1') ) { - if (isset($_REQUEST['send_error_report']) - && $_REQUEST['send_error_report'] == true - ) { - $server_response = PMA_sendErrorReport(PMA_getReportData()); - - if ($server_response === false) { - $success = false; - } else { - $decoded_response = json_decode($server_response, true); - $success = !empty($decoded_response) ? $decoded_response["success"] : false; - } - - /* Message to show to the user */ - if ($success) { - if (isset($_REQUEST['automatic']) - && $_REQUEST['automatic'] === "true" - ) { - $message = __( - 'An error has been detected and an error report has been ' - . 'automatically submitted based on your settings.' - ); - } else { - $message = __('Thank you for submitting this report.'); - } - } else { - $message = __( - 'An error has been detected and an error report has been ' - . 'generated but failed to be sent.' - ) - . ' ' - . __( - 'If you experience any ' - . 'problems please submit a bug report manually.' - ); - } - $message .= ' ' . __('You may want to refresh the page.'); - - /* Create message object */ - if ($success) { - $message = PMA_Message::notice($message); - } else { - $message = PMA_Message::error($message); - } - - /* Add message to JSON response */ - $response->addJSON('message', $message); - - /* Persist always send settings */ - if (! isset($_REQUEST['automatic']) - && $_REQUEST['automatic'] !== "true" - && isset($_REQUEST['always_send']) - && $_REQUEST['always_send'] === "true" - ) { - PMA_persistOption("SendErrorReports", "always", "ask"); - } - } elseif (! empty($_REQUEST['get_settings'])) { - $response->addJSON('report_setting', $GLOBALS['cfg']['SendErrorReports']); - } else { - $response->addHTML(PMA_getErrorReportForm()); - } -} elseif (isset($_REQUEST['exception_type']) - && $_REQUEST['exception_type'] == 'php' -) { - if (isset($_REQUEST['send_error_report']) - && $_REQUEST['send_error_report'] == '1' - ) { + if ($_REQUEST['exception_type'] == 'php') { /** * Prevent inifnite error submission. * Happens in case error submissions fails. @@ -101,68 +43,88 @@ if (isset($_REQUEST['exception_type']) : (0) ); } + } + $reportData = PMA_getReportData($_REQUEST['exception_type']); + // report if and only if there were 'actual' errors. + if (count($reportData) > 0) { + $server_response = PMA_sendErrorReport($reportData); + if ($server_response === false) { + $success = false; + } else { + $decoded_response = json_decode($server_response, true); + $success = !empty($decoded_response) ? $decoded_response["success"] : false; + } - $reportData = PMA_getReportData('php'); - // report if and only if there were 'actual' errors. - if (count($reportData) > 0) { - $server_response = PMA_sendErrorReport($reportData); - if ($server_response === false) { - $success = false; + /* Message to show to the user */ + if ($success) { + if ((isset($_REQUEST['automatic']) + && $_REQUEST['automatic'] === "true") + || $GLOBALS['cfg']['SendErrorReports'] == 'always' + ) { + $msg = __( + 'An error has been detected and an error report has been ' + . 'automatically submitted based on your settings.' + ); } else { - $decoded_response = json_decode($server_response, true); - $success = !empty($decoded_response) ? $decoded_response["success"] : false; + $msg = __('Thank you for submitting this report.'); } + } else { + $msg = __( + 'An error has been detected and an error report has been ' + . 'generated but failed to be sent.' + ) + . ' ' + . __( + 'If you experience any ' + . 'problems please submit a bug report manually.' + ); + } + $msg .= ' ' . __('You may want to refresh the page.'); - if ($GLOBALS['cfg']['SendErrorReports'] == 'ask') { - if ($success) { - $errSubmitMsg = PMA_Message::error( - __('Thank You for subitting error report!!') - . '
' - . __('Report has been succesfully submitted.') - ); - } else { - $errSubmitMsg = PMA_Message::error( - __('Thank You for subitting error report!!') - . '
' - . __(' Unfortunately submission failed.') - . '
' - . __(' If you experience any problems please submit a bug report manually.') - ); - } - } elseif ($GLOBALS['cfg']['SendErrorReports'] == 'always') { - if ($success) { - $errSubmitMsg = PMA_Message::error( - __( - 'An error has been detected on the server and an error report has been ' - . 'automatically submitted based on your settings.' - ) - ); - } else { - $errSubmitMsg = PMA_Message::error( - __( - 'An error has been detected and an error report has been ' - . 'generated but failed to be sent.' - ) - . '
' - . __('If you experience any problems please submit a bug report manually.') - ); - } - } + /* Create message object */ + if ($success) { + $msg = PMA_Message::notice($msg); + } else { + $msg = PMA_Message::error($msg); + } - if ($response->isAjax()) { - $response->addJSON('_errSubmitMsg', $errSubmitMsg); + /* Add message to response */ + if ($response->isAjax()) { + if ($_REQUEST['exception_type'] == 'js') { + $response->addJSON('message', $msg); } else { - $jsCode = 'PMA_ajaxShowMessage("
' - . $errSubmitMsg - . '
", false);'; - $response->getFooter()->getScripts()->addCode($jsCode); + $response->addJSON('_errSubmitMsg', $msg); } + } elseif ($_REQUEST['exception_type'] == 'php') { + $jsCode = 'PMA_ajaxShowMessage("
' + . $msg + . '
", false);'; + $response->getFooter()->getScripts()->addCode($jsCode); + } + + if ($_REQUEST['exception_type'] == 'php') { + // clear previous errors & save new ones. + $GLOBALS['error_handler']->savePreviousErrors(); + } + + /* Persist always send settings */ + if ($_REQUEST['exception_type'] == 'js' + && ! isset($_REQUEST['automatic']) + && $_REQUEST['automatic'] !== "true" + && isset($_REQUEST['always_send']) + && $_REQUEST['always_send'] === "true" + ) { + PMA_persistOption("SendErrorReports", "always", "ask"); } } - // clear previous errors & save new ones. - $GLOBALS['error_handler']->savePreviousErrors(); +} elseif (! empty($_REQUEST['get_settings'])) { + $response->addJSON('report_setting', $GLOBALS['cfg']['SendErrorReports']); } else { - die('Oops, something went wrong!!'); + if ($_REQUEST['exception_type'] == 'js') { + $response->addHTML(PMA_getErrorReportForm()); + } else { + // clear previous errors & save new ones. + $GLOBALS['error_handler']->savePreviousErrors(); + } } - ?> From 627873f1466a1940cea6362410c724812407b78f Mon Sep 17 00:00:00 2001 From: Dhananjay Nakrani Date: Thu, 12 Jun 2014 16:55:01 +0530 Subject: [PATCH 30/35] Enable 'Send error reports automatically next time' option in php error reporting form. Signed-off-by: Dhananjay Nakrani --- error_report.php | 6 ++---- libraries/Error_Handler.class.php | 5 +++++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/error_report.php b/error_report.php index 6c373aafb4..ac74510dab 100644 --- a/error_report.php +++ b/error_report.php @@ -7,6 +7,7 @@ */ require_once 'libraries/common.inc.php'; require_once 'libraries/error_report.lib.php'; +require_once 'libraries/user_preferences.lib.php'; if (!isset($_REQUEST['exception_type']) ||!in_array($_REQUEST['exception_type'], array('js', 'php')) @@ -108,10 +109,7 @@ if (isset($_REQUEST['send_error_report']) } /* Persist always send settings */ - if ($_REQUEST['exception_type'] == 'js' - && ! isset($_REQUEST['automatic']) - && $_REQUEST['automatic'] !== "true" - && isset($_REQUEST['always_send']) + if (isset($_REQUEST['always_send']) && $_REQUEST['always_send'] === "true" ) { PMA_persistOption("SendErrorReports", "always", "ask"); diff --git a/libraries/Error_Handler.class.php b/libraries/Error_Handler.class.php index 5eca90caba..620087ebf7 100644 --- a/libraries/Error_Handler.class.php +++ b/libraries/Error_Handler.class.php @@ -332,6 +332,11 @@ class PMA_Error_Handler . '' + . '' + . '' . ''; if ($GLOBALS['cfg']['SendErrorReports'] == 'ask') { From c00d1d5ef6339e8b6854789d8ddc7d1b94b41873 Mon Sep 17 00:00:00 2001 From: Dhananjay Nakrani Date: Thu, 12 Jun 2014 17:59:14 +0530 Subject: [PATCH 31/35] Change hardcoded indexing to dynamic one. Signed-off-by: Dhananjay Nakrani --- libraries/error_report.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/error_report.lib.php b/libraries/error_report.lib.php index c227efacdd..c9c3b2bb10 100644 --- a/libraries/error_report.lib.php +++ b/libraries/error_report.lib.php @@ -68,7 +68,7 @@ function PMA_getReportData($exception_type = 'js') "user_agent_string" => $_SERVER['HTTP_USER_AGENT'], "locale" => $_COOKIE['pma_lang'], "configuration_storage" => - empty($GLOBALS['cfg']['Servers'][1]['pmadb']) ? "disabled" : + is_null(PMA_getRelationsParam()['db']) ? "disabled" : "enabled", "php_version" => phpversion() ); From 8b09aa7f7640f0f0fb84fc82214367235234205e Mon Sep 17 00:00:00 2001 From: Dhananjay Nakrani Date: Thu, 12 Jun 2014 18:42:34 +0530 Subject: [PATCH 32/35] Make Syntax compatible with php-5.3 Signed-off-by: Dhananjay Nakrani --- libraries/error_report.lib.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/error_report.lib.php b/libraries/error_report.lib.php index c9c3b2bb10..d2279f1c24 100644 --- a/libraries/error_report.lib.php +++ b/libraries/error_report.lib.php @@ -58,6 +58,7 @@ function PMA_getPrettyReportData() */ function PMA_getReportData($exception_type = 'js') { + $relParams = PMA_getRelationsParam(); // common params for both, php & js execptions $report = array( "pma_version" => PMA_VERSION, @@ -68,7 +69,7 @@ function PMA_getReportData($exception_type = 'js') "user_agent_string" => $_SERVER['HTTP_USER_AGENT'], "locale" => $_COOKIE['pma_lang'], "configuration_storage" => - is_null(PMA_getRelationsParam()['db']) ? "disabled" : + is_null($relParams['db']) ? "disabled" : "enabled", "php_version" => phpversion() ); From 68de01a99e1e0837b9a82f80342f2e883c37d09e Mon Sep 17 00:00:00 2001 From: Dhananjay Nakrani Date: Thu, 12 Jun 2014 21:52:07 +0530 Subject: [PATCH 33/35] Minor Interface improvements. Scroll down & show 'working' icon. Signed-off-by: Dhananjay Nakrani --- js/ajax.js | 1 + js/messages.php | 3 +++ 2 files changed, 4 insertions(+) diff --git a/js/ajax.js b/js/ajax.js index 5af4affcde..f739e49c87 100644 --- a/js/ajax.js +++ b/js/ajax.js @@ -413,6 +413,7 @@ var AJAX = { ) { $("#pma_report_errors_form").submit(); PMA_ajaxShowMessage(PMA_messages['phpErrorsBeingSubmitted'], false); + $('html, body').animate({scrollTop:$(document).height()}, 'slow'); } else if (data._promptPhpErrors) { // otherwise just prompt user if it is set so. msg = msg + PMA_messages['phpErrorsFound']; diff --git a/js/messages.php b/js/messages.php index 59146e83bc..e0448b964b 100644 --- a/js/messages.php +++ b/js/messages.php @@ -443,6 +443,9 @@ $js_messages['phpErrorsBeingSubmitted'] = '
' . '
' . __('As per your settings, they are being submitted currently.') . __(' Please be patient.') + . '
' + . 'ajax clock' . '
'; echo "var PMA_messages = new Array();\n"; From e65b678386afaa758dcaadf5571fb566e4b57a64 Mon Sep 17 00:00:00 2001 From: Dhananjay Nakrani Date: Sat, 14 Jun 2014 10:01:54 +0530 Subject: [PATCH 34/35] Add test cases for'PMA_Error::getBacktrace()'. Signed-off-by: Dhananjay Nakrani --- test/classes/PMA_Error_test.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test/classes/PMA_Error_test.php b/test/classes/PMA_Error_test.php index a789706348..8940ee973e 100644 --- a/test/classes/PMA_Error_test.php +++ b/test/classes/PMA_Error_test.php @@ -152,4 +152,19 @@ class PMA_Error_Test extends PHPUnit_Framework_TestCase { $this->assertEquals('Warning: Compile Error', $this->object->getTitle()); } + + /** + * Test for getBacktrace + * + * @return void + */ + public function testGetBacktrace() + { + $this->object->setBacktrace(array('bt1','bt2','bt3','bt4')); + // case: full backtrace + $this->assertEquals(array('bt1','bt2','bt3','bt4'), $this->object->getBacktrace()); + + // case: first 2 frames + $this->assertEquals(array('bt1','bt2'), $this->object->getBacktrace(2)); + } } From 83d63d23ea7c2aa7cfe032fe1d29229954e9598c Mon Sep 17 00:00:00 2001 From: Dhananjay Nakrani Date: Sat, 14 Jun 2014 21:41:09 +0530 Subject: [PATCH 35/35] Fix coding style issues. Signed-off-by: Dhananjay Nakrani --- error_report.php | 14 ++++++---- js/ajax.js | 46 +++++++++++++++---------------- js/messages.php | 5 ++-- libraries/Error_Handler.class.php | 18 +++++++----- 4 files changed, 45 insertions(+), 38 deletions(-) diff --git a/error_report.php b/error_report.php index ac74510dab..756fa2f4a0 100644 --- a/error_report.php +++ b/error_report.php @@ -19,18 +19,19 @@ $response = PMA_Response::getInstance(); if (isset($_REQUEST['send_error_report']) && ($_REQUEST['send_error_report'] == true - || $_REQUEST['send_error_report'] == '1') + || $_REQUEST['send_error_report'] == '1') ) { if ($_REQUEST['exception_type'] == 'php') { /** * Prevent inifnite error submission. * Happens in case error submissions fails. - * If reporting is done in some time interval, just clear them & clear json data too. + * If reporting is done in some time interval, + * just clear them & clear json data too. */ if (isset($_SESSION['prev_error_subm_time']) && isset($_SESSION['error_subm_count']) - && $_SESSION['error_subm_count'] >= 3 // allow maximum 4 attempts - && ($_SESSION['prev_error_subm_time']-time()) <= 3000 // in 3 seconds + && $_SESSION['error_subm_count'] >= 3 + && ($_SESSION['prev_error_subm_time']-time()) <= 3000 ) { $_SESSION['error_subm_count'] = 0; $_SESSION['prev_errors'] = ''; @@ -53,13 +54,14 @@ if (isset($_REQUEST['send_error_report']) $success = false; } else { $decoded_response = json_decode($server_response, true); - $success = !empty($decoded_response) ? $decoded_response["success"] : false; + $success = !empty($decoded_response) ? + $decoded_response["success"] : false; } /* Message to show to the user */ if ($success) { if ((isset($_REQUEST['automatic']) - && $_REQUEST['automatic'] === "true") + && $_REQUEST['automatic'] === "true") || $GLOBALS['cfg']['SendErrorReports'] == 'always' ) { $msg = __( diff --git a/js/ajax.js b/js/ajax.js index f739e49c87..e81eb8419c 100644 --- a/js/ajax.js +++ b/js/ajax.js @@ -397,29 +397,29 @@ var AJAX = { $('
', {id : 'pma_errors'}) .insertAfter('#selflink') .append(data._errors); - // bind for php error reporting forms (bottom) - $("#pma_ignore_errors_bottom").bind("click", - function() { - PMA_ignorePhpErrors() - }); - $("#pma_ignore_all_errors_bottom").bind("click", - function() { - PMA_ignorePhpErrors(false) - }); - // In case of 'sendErrorReport'='always' - // submit the hidden error reporting form. - if (data._sendErrorAlways == '1' - && data._stopErrorReportLoop != '1' - ) { - $("#pma_report_errors_form").submit(); - PMA_ajaxShowMessage(PMA_messages['phpErrorsBeingSubmitted'], false); - $('html, body').animate({scrollTop:$(document).height()}, 'slow'); - } else if (data._promptPhpErrors) { - // otherwise just prompt user if it is set so. - msg = msg + PMA_messages['phpErrorsFound']; - // scroll to bottom where all the erros are displayed. - $('html, body').animate({scrollTop:$(document).height()}, 'slow'); - } + // bind for php error reporting forms (bottom) + $("#pma_ignore_errors_bottom").bind("click", + function() { + PMA_ignorePhpErrors(); + }); + $("#pma_ignore_all_errors_bottom").bind("click", + function() { + PMA_ignorePhpErrors(false); + }); + // In case of 'sendErrorReport'='always' + // submit the hidden error reporting form. + if (data._sendErrorAlways == '1' + && data._stopErrorReportLoop != '1' + ) { + $("#pma_report_errors_form").submit(); + PMA_ajaxShowMessage(PMA_messages['phpErrorsBeingSubmitted'], false); + $('html, body').animate({scrollTop:$(document).height()}, 'slow'); + } else if (data._promptPhpErrors) { + // otherwise just prompt user if it is set so. + msg = msg + PMA_messages['phpErrorsFound']; + // scroll to bottom where all the erros are displayed. + $('html, body').animate({scrollTop:$(document).height()}, 'slow'); + } } PMA_ajaxShowMessage(msg, false); // bind for php error reporting forms (popup) diff --git a/js/messages.php b/js/messages.php index e0448b964b..a50184b485 100644 --- a/js/messages.php +++ b/js/messages.php @@ -444,8 +444,9 @@ $js_messages['phpErrorsBeingSubmitted'] = '
' . __('As per your settings, they are being submitted currently.') . __(' Please be patient.') . '
' - . 'ajax clock' + . 'ajax clock' . '
'; echo "var PMA_messages = new Array();\n"; diff --git a/libraries/Error_Handler.class.php b/libraries/Error_Handler.class.php index 620087ebf7..7592c322cb 100644 --- a/libraries/Error_Handler.class.php +++ b/libraries/Error_Handler.class.php @@ -521,7 +521,9 @@ class PMA_Error_Handler } else { // send the error reports asynchronously & without asking user $jsCode .= '$("#pma_report_errors_form").submit();' - . 'PMA_ajaxShowMessage(PMA_messages["phpErrorsBeingSubmitted"], false);'; + . 'PMA_ajaxShowMessage( + PMA_messages["phpErrorsBeingSubmitted"], false + );'; // js code to appropriate focusing, $jsCode .= '$("html, body").animate({ scrollTop:$(document).height() @@ -536,15 +538,17 @@ class PMA_Error_Handler . '$("#pma_ignore_errors_popup").bind("click", function() { PMA_ignorePhpErrors() });' - . '$("#pma_ignore_all_errors_popup").bind("click", function() { - PMA_ignorePhpErrors(false) - });' + . '$("#pma_ignore_all_errors_popup").bind("click", + function() { + PMA_ignorePhpErrors(false) + });' . '$("#pma_ignore_errors_bottom").bind("click", function() { PMA_ignorePhpErrors() });' - . '$("#pma_ignore_all_errors_bottom").bind("click", function() { - PMA_ignorePhpErrors(false) - });' + . '$("#pma_ignore_all_errors_bottom").bind("click", + function() { + PMA_ignorePhpErrors(false) + });' . '$("html, body").animate({ scrollTop:$(document).height() }, "slow");';