Move error report entry point logic to routes file

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
This commit is contained in:
Maurício Meneghini Fauth 2019-11-06 22:32:41 -03:00
parent 271e0033a1
commit 4fabc68f95
6 changed files with 12 additions and 28 deletions

View File

@ -24,7 +24,7 @@ var ErrorReport = {
exception.name = ErrorReport.extractExceptionName(exception);
}
ErrorReport.lastException = exception;
$.post('index.php?route=/error_report', {
$.post('index.php?route=/error-report', {
'ajax_request': true,
'server': CommonParams.get('server'),
'get_settings': true,
@ -42,7 +42,7 @@ var ErrorReport = {
'send_error_report': true,
'automatic': true
});
$.post('index.php?route=/error_report', postData, function (data) {
$.post('index.php?route=/error-report', postData, function (data) {
if (data.success === false) {
// in the case of an error, show the error message returned.
Functions.ajaxShowMessage(data.error, false);
@ -79,7 +79,7 @@ var ErrorReport = {
'description': $('#report_description').val(),
'always_send': $('#always_send_checkbox')[0].checked
});
$.post('index.php?route=/error_report', postData, function (data) {
$.post('index.php?route=/error-report', postData, function (data) {
$dialog.dialog('close');
if (data.success === false) {
// in the case of an error, show the error message returned.
@ -94,7 +94,7 @@ var ErrorReport = {
$(this).dialog('close');
};
$.post('index.php?route=/error_report', reportData, function (data) {
$.post('index.php?route=/error-report', reportData, function (data) {
if (data.success === false) {
// in the case of an error, show the error message returned.
Functions.ajaxShowMessage(data.error, false);

View File

@ -4842,7 +4842,7 @@ Functions.ignorePhpErrors = function (clearPrevErrors) {
) {
clearPrevious = false;
}
// send AJAX request to /error_report with send_error_report=0, exception_type=php & token.
// send AJAX request to /error-report with send_error_report=0, exception_type=php & token.
// It clears the prev_errors stored in session.
if (clearPrevious) {
var $pmaReportErrorsForm = $('#pma_report_errors_form');

View File

@ -353,7 +353,7 @@ class ErrorHandler
&& $this->countErrors() != $this->countUserErrors()
) {
// add report button.
$retval .= '<form method="post" action="' . Url::getFromRoute('/error_report')
$retval .= '<form method="post" action="' . Url::getFromRoute('/error-report')
. '" id="pma_report_errors_form"';
if ($GLOBALS['cfg']['SendErrorReports'] == 'always') {
// in case of 'always', generate 'invisible' form.

View File

@ -1,19 +0,0 @@
<?php
/**
* Handle error report submission
*
* @package PhpMyAdmin
*/
declare(strict_types=1);
use PhpMyAdmin\Controllers\ErrorReportController;
if (! defined('PHPMYADMIN')) {
exit;
}
global $containerBuilder;
/** @var ErrorReportController $controller */
$controller = $containerBuilder->get(ErrorReportController::class);
$controller->index();

View File

@ -13,6 +13,7 @@ use PhpMyAdmin\Controllers\CheckRelationsController;
use PhpMyAdmin\Controllers\Database\DataDictionaryController;
use PhpMyAdmin\Controllers\Database\MultiTableQueryController;
use PhpMyAdmin\Controllers\Database\StructureController;
use PhpMyAdmin\Controllers\ErrorReportController;
use PhpMyAdmin\Controllers\HomeController;
use PhpMyAdmin\Controllers\Server\BinlogController;
use PhpMyAdmin\Controllers\Server\CollationsController;
@ -208,8 +209,10 @@ return function (RouteCollector $routes) use ($containerBuilder, $response) {
require_once ROOT_PATH . 'libraries/entry_points/database/triggers.php';
});
});
$routes->addRoute(['GET', 'POST'], '/error_report', function () {
require_once ROOT_PATH . 'libraries/entry_points/error_report.php';
$routes->addRoute(['GET', 'POST'], '/error-report', function () use ($containerBuilder) {
/** @var ErrorReportController $controller */
$controller = $containerBuilder->get(ErrorReportController::class);
$controller->index();
});
$routes->addRoute(['GET', 'POST'], '/export', function () {
require_once ROOT_PATH . 'libraries/entry_points/export.php';

View File

@ -1,4 +1,4 @@
<form action="{{ url('/error_report') }}" method="post" name="report_frm" id="report_frm"
<form action="{{ url('/error-report') }}" method="post" name="report_frm" id="report_frm"
class="ajax">
<fieldset style="padding-top:0">