Skip to content

Commit

Permalink
Improve handling of E_DEPRECATED unhandled errors
Browse files Browse the repository at this point in the history
The check_unhandled_errors_exist() function now returns the (lowest)
error type instead of true, so the caller can capture this information
to trigger a warning instead of a hard failure.

Issue #16890
  • Loading branch information
dregad committed Feb 4, 2014
1 parent 323deb3 commit 26877d2
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions admin/check/check_api.php
Expand Up @@ -63,11 +63,17 @@ function check_error_handler( $p_type, $p_error, $p_file, $p_line, $p_context )

/**
* Check whether any unhandled errors exist
* @return bool|int false if there are no unhandled errors, or the lowest
* unhandled {@see http://php.net/errorfunc.constants Error Type}
*/
function check_unhandled_errors_exist() {
global $g_errors_raised;
if ( count( $g_errors_raised ) > 0 ) {
return true;
$t_type = E_ALL;
foreach( $g_errors_raised as $t_error ) {
$t_type = min( $t_type, $t_error['type'] );
}
return $t_type;
}
return false;
}
Expand Down Expand Up @@ -195,13 +201,18 @@ function check_print_test_row( $p_description, $p_pass, $p_info = null ) {
}
}
echo "</td>\n";
if( $p_pass && !check_unhandled_errors_exist() ) {
check_print_test_result( GOOD );

if( $p_pass && !$t_unhandled ) {
$t_result = GOOD;
} elseif( $t_unhandled == E_DEPRECATED ) {
$t_result = WARN;
} else {
check_print_test_result( BAD );
$t_result = BAD;
}
check_print_test_result( $t_result );
echo "\t</tr>\n";
if( check_unhandled_errors_exist() ) {

if( $t_unhandled ) {
check_print_error_rows();
}
$g_alternate_row = $g_alternate_row === 1 ? 2 : 1;
Expand Down Expand Up @@ -230,15 +241,17 @@ function check_print_test_warn_row( $p_description, $p_pass, $p_info = null ) {
}
}
echo "</td>\n";
if( $p_pass && !check_unhandled_errors_exist() ) {
check_print_test_result( GOOD );
} else if( !check_unhandled_errors_exist() ) {
check_print_test_result( WARN );
if( $p_pass && !$t_unhandled ) {
$t_result = GOOD;
} elseif( !$t_unhandled || $t_unhandled == E_DEPRECATED ) {
$t_result = WARN;
} else {
check_print_test_result( BAD );
$t_result = BAD;
}
check_print_test_result( $t_result );
echo "\t</tr>\n";
if( check_unhandled_errors_exist() ) {

if( $t_unhandled ) {
check_print_error_rows();
}
$g_alternate_row = $g_alternate_row === 1 ? 2 : 1;
Expand Down

0 comments on commit 26877d2

Please sign in to comment.