Replace static methods with instance methods
Signed-off-by: Maurício Meneghini Fauth <mauriciofauth@gmail.com>
This commit is contained in:
parent
5efb29d500
commit
56daea7d86
@ -6,6 +6,7 @@
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
use PhpMyAdmin\ErrorReport;
|
||||
use PhpMyAdmin\Message;
|
||||
use PhpMyAdmin\Response;
|
||||
use PhpMyAdmin\UserPreferences;
|
||||
|
||||
@ -19,6 +20,8 @@ if (!isset($_REQUEST['exception_type'])
|
||||
|
||||
$response = Response::getInstance();
|
||||
|
||||
$errorReport = new ErrorReport();
|
||||
|
||||
if (isset($_REQUEST['send_error_report'])
|
||||
&& ($_REQUEST['send_error_report'] == true
|
||||
|| $_REQUEST['send_error_report'] == '1')
|
||||
@ -47,10 +50,10 @@ if (isset($_REQUEST['send_error_report'])
|
||||
);
|
||||
}
|
||||
}
|
||||
$reportData = ErrorReport::getReportData($_REQUEST['exception_type']);
|
||||
$reportData = $errorReport->getReportData($_REQUEST['exception_type']);
|
||||
// report if and only if there were 'actual' errors.
|
||||
if (count($reportData) > 0) {
|
||||
$server_response = ErrorReport::send($reportData);
|
||||
$server_response = $errorReport->send($reportData);
|
||||
if ($server_response === false) {
|
||||
$success = false;
|
||||
} else {
|
||||
@ -87,9 +90,9 @@ if (isset($_REQUEST['send_error_report'])
|
||||
|
||||
/* Create message object */
|
||||
if ($success) {
|
||||
$msg = PhpMyAdmin\Message::notice($msg);
|
||||
$msg = Message::notice($msg);
|
||||
} else {
|
||||
$msg = PhpMyAdmin\Message::error($msg);
|
||||
$msg = Message::error($msg);
|
||||
}
|
||||
|
||||
/* Add message to response */
|
||||
@ -122,7 +125,7 @@ if (isset($_REQUEST['send_error_report'])
|
||||
$response->addJSON('report_setting', $GLOBALS['cfg']['SendErrorReports']);
|
||||
} else {
|
||||
if ($_REQUEST['exception_type'] == 'js') {
|
||||
$response->addHTML(ErrorReport::getForm());
|
||||
$response->addHTML($errorReport->getForm());
|
||||
} else {
|
||||
// clear previous errors & save new ones.
|
||||
$GLOBALS['error_handler']->savePreviousErrors();
|
||||
|
||||
@ -32,9 +32,9 @@ class ErrorReport
|
||||
*
|
||||
* @return String the report
|
||||
*/
|
||||
public static function getPrettyReportData()
|
||||
public function getPrettyReportData()
|
||||
{
|
||||
$report = self::getReportData();
|
||||
$report = $this->getReportData();
|
||||
|
||||
return json_encode($report, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
|
||||
}
|
||||
@ -47,7 +47,7 @@ class ErrorReport
|
||||
*
|
||||
* @return array error report if success, Empty Array otherwise
|
||||
*/
|
||||
public static function getReportData($exception_type = 'js')
|
||||
public function getReportData($exception_type = 'js')
|
||||
{
|
||||
$relParams = Relation::getRelationsParam();
|
||||
// common params for both, php & js exceptions
|
||||
@ -70,8 +70,8 @@ class ErrorReport
|
||||
return array();
|
||||
}
|
||||
$exception = $_REQUEST['exception'];
|
||||
$exception["stack"] = self::translateStacktrace($exception["stack"]);
|
||||
List($uri, $script_name) = self::sanitizeUrl($exception["url"]);
|
||||
$exception["stack"] = $this->translateStacktrace($exception["stack"]);
|
||||
List($uri, $script_name) = $this->sanitizeUrl($exception["url"]);
|
||||
$exception["uri"] = $uri;
|
||||
unset($exception["url"]);
|
||||
|
||||
@ -135,7 +135,7 @@ class ErrorReport
|
||||
*
|
||||
* @return array the uri and script name
|
||||
*/
|
||||
public static function sanitizeUrl($url)
|
||||
public function sanitizeUrl($url)
|
||||
{
|
||||
$components = parse_url($url);
|
||||
if (isset($components["fragment"])
|
||||
@ -177,7 +177,7 @@ class ErrorReport
|
||||
*
|
||||
* @return String the reply of the server
|
||||
*/
|
||||
public static function send(array $report)
|
||||
public function send(array $report)
|
||||
{
|
||||
$httpRequest = new HttpRequest();
|
||||
$response = $httpRequest->create(
|
||||
@ -198,7 +198,7 @@ class ErrorReport
|
||||
*
|
||||
* @return array $stack the modified stack trace
|
||||
*/
|
||||
public static function translateStacktrace(array $stack)
|
||||
public function translateStacktrace(array $stack)
|
||||
{
|
||||
foreach ($stack as &$level) {
|
||||
foreach ($level["context"] as &$line) {
|
||||
@ -207,7 +207,7 @@ class ErrorReport
|
||||
}
|
||||
}
|
||||
unset($level["context"]);
|
||||
List($uri, $script_name) = self::sanitizeUrl($level["url"]);
|
||||
List($uri, $script_name) = $this->sanitizeUrl($level["url"]);
|
||||
$level["uri"] = $uri;
|
||||
$level["scriptname"] = $script_name;
|
||||
unset($level["url"]);
|
||||
@ -222,15 +222,15 @@ class ErrorReport
|
||||
*
|
||||
* @return String the form
|
||||
*/
|
||||
public static function getForm()
|
||||
public function getForm()
|
||||
{
|
||||
$datas = array(
|
||||
'report_data' => self::getPrettyReportData(),
|
||||
'report_data' => $this->getPrettyReportData(),
|
||||
'hidden_inputs' => Url::getHiddenInputs(),
|
||||
'hidden_fields' => null,
|
||||
);
|
||||
|
||||
$reportData = self::getReportData();
|
||||
$reportData = $this->getReportData();
|
||||
if (!empty($reportData)) {
|
||||
$datas['hidden_fields'] = Url::getHiddenFields($reportData);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user