Visitar URL original
Extract Functions.ignorePhpErrors() into a module · phpmyadmin/phpmyadmin@729b21b · GitHub
Skip to content

Commit 729b21b

Browse files
committed
Extract Functions.ignorePhpErrors() into a module
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
1 parent cdd2d42 commit 729b21b

4 files changed

Lines changed: 47 additions & 41 deletions

File tree

‎js/src/modules/ajax.js‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import highlightSql from './sql-highlight.js';
66
import { ajaxRemoveMessage, ajaxShowMessage } from './ajax-message.js';
77
import { escapeHtml } from './functions/escape.js';
88
import getImageTag from './functions/getImageTag.js';
9+
import { ignorePhpErrors } from './functions/ignorePhpErrors.js';
910

1011
/**
1112
* This object handles ajax requests for pages. It also
@@ -394,11 +395,11 @@ const AJAX = {
394395
// bind for php error reporting forms (bottom)
395396
$('#pma_ignore_errors_bottom').on('click', function (e) {
396397
e.preventDefault();
397-
Functions.ignorePhpErrors();
398+
ignorePhpErrors();
398399
});
399400
$('#pma_ignore_all_errors_bottom').on('click', function (e) {
400401
e.preventDefault();
401-
Functions.ignorePhpErrors(false);
402+
ignorePhpErrors(false);
402403
});
403404
// In case of 'sendErrorReport'='always'
404405
// submit the hidden error reporting form.
@@ -419,10 +420,10 @@ const AJAX = {
419420
ajaxShowMessage(msg, false);
420421
// bind for php error reporting forms (popup)
421422
$('#pma_ignore_errors_popup').on('click', function () {
422-
Functions.ignorePhpErrors();
423+
ignorePhpErrors();
423424
});
424425
$('#pma_ignore_all_errors_popup').on('click', function () {
425-
Functions.ignorePhpErrors(false);
426+
ignorePhpErrors(false);
426427
});
427428

428429
if (typeof data.success !== 'undefined' && data.success) {
@@ -577,11 +578,11 @@ const AJAX = {
577578
// bind for php error reporting forms (bottom)
578579
$('#pma_ignore_errors_bottom').on('click', function (e) {
579580
e.preventDefault();
580-
Functions.ignorePhpErrors();
581+
ignorePhpErrors();
581582
});
582583
$('#pma_ignore_all_errors_bottom').on('click', function (e) {
583584
e.preventDefault();
584-
Functions.ignorePhpErrors(false);
585+
ignorePhpErrors(false);
585586
});
586587
// In case of 'sendErrorReport'='always'
587588
// submit the hidden error reporting form.
@@ -601,10 +602,10 @@ const AJAX = {
601602
ajaxShowMessage(msg, false);
602603
// bind for php error reporting forms (popup)
603604
$('#pma_ignore_errors_popup').on('click', function () {
604-
Functions.ignorePhpErrors();
605+
ignorePhpErrors();
605606
});
606607
$('#pma_ignore_all_errors_popup').on('click', function () {
607-
Functions.ignorePhpErrors(false);
608+
ignorePhpErrors(false);
608609
});
609610

610611
if (typeof AJAX.callback === 'function') {

‎js/src/modules/functions.js‎

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3564,35 +3564,6 @@ Functions.checkNumberOfFields = function () {
35643564
return true;
35653565
};
35663566

3567-
/**
3568-
* Ignore the displayed php errors.
3569-
* Simply removes the displayed errors.
3570-
*
3571-
* @param clearPrevErrors whether to clear errors stored
3572-
* in $_SESSION['prev_errors'] at server
3573-
*
3574-
*/
3575-
Functions.ignorePhpErrors = function (clearPrevErrors) {
3576-
var clearPrevious = clearPrevErrors;
3577-
if (typeof (clearPrevious) === 'undefined' ||
3578-
clearPrevious === null
3579-
) {
3580-
clearPrevious = false;
3581-
}
3582-
// send AJAX request to /error-report with send_error_report=0, exception_type=php & token.
3583-
// It clears the prev_errors stored in session.
3584-
if (clearPrevious) {
3585-
var $pmaReportErrorsForm = $('#pma_report_errors_form');
3586-
$pmaReportErrorsForm.find('input[name="send_error_report"]').val(0); // change send_error_report to '0'
3587-
$pmaReportErrorsForm.trigger('submit');
3588-
}
3589-
3590-
// remove displayed errors
3591-
var $pmaErrors = $('#pma_errors');
3592-
$pmaErrors.fadeOut('slow');
3593-
$pmaErrors.remove();
3594-
};
3595-
35963567
/**
35973568
* Toggle the Datetimepicker UI if the date value entered
35983569
* by the user in the 'text box' is not going to be accepted
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import $ from 'jquery';
2+
3+
/**
4+
* Ignore the displayed php errors.
5+
* Simply removes the displayed errors.
6+
*
7+
* @param {boolean} clearPrevErrors whether to clear errors stored
8+
* in $_SESSION['prev_errors'] at server
9+
*
10+
*/
11+
function ignorePhpErrors (clearPrevErrors) {
12+
var clearPrevious = clearPrevErrors;
13+
if (typeof (clearPrevious) === 'undefined' ||
14+
clearPrevious === null
15+
) {
16+
clearPrevious = false;
17+
}
18+
// send AJAX request to /error-report with send_error_report=0, exception_type=php & token.
19+
// It clears the prev_errors stored in session.
20+
if (clearPrevious) {
21+
var $pmaReportErrorsForm = $('#pma_report_errors_form');
22+
$pmaReportErrorsForm.find('input[name="send_error_report"]').val(0); // change send_error_report to '0'
23+
$pmaReportErrorsForm.trigger('submit');
24+
}
25+
26+
// remove displayed errors
27+
var $pmaErrors = $('#pma_errors');
28+
$pmaErrors.fadeOut('slow');
29+
$pmaErrors.remove();
30+
}
31+
32+
window.ignorePhpErrors = ignorePhpErrors;
33+
34+
export { ignorePhpErrors };

‎libraries/classes/ErrorHandler.php‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -614,20 +614,20 @@ public function reportErrors(): void
614614
// js code to show appropriate msgs, event binding & focusing.
615615
$jsCode = 'window.ajaxShowMessage(window.Messages.phpErrorsFound);'
616616
. '$("#pma_ignore_errors_popup").on("click", function() {
617-
Functions.ignorePhpErrors()
617+
window.ignorePhpErrors()
618618
});'
619619
. '$("#pma_ignore_all_errors_popup").on("click",
620620
function() {
621-
Functions.ignorePhpErrors(false)
621+
window.ignorePhpErrors(false)
622622
});'
623623
. '$("#pma_ignore_errors_bottom").on("click", function(e) {
624624
e.preventDefault();
625-
Functions.ignorePhpErrors()
625+
window.ignorePhpErrors()
626626
});'
627627
. '$("#pma_ignore_all_errors_bottom").on("click",
628628
function(e) {
629629
e.preventDefault();
630-
Functions.ignorePhpErrors(false)
630+
window.ignorePhpErrors(false)
631631
});'
632632
. '$("html, body").animate({
633633
scrollTop:$(document).height()

0 commit comments

Comments
 (0)