Skip to content

Commit e2cd6fd

Browse files
authored
Fix: Apply WordPress coding standards (PHPCS)
- Use Yoda conditions - Use single quotes for simple strings - Use array() instead of [] - Remove trailing whitespace - Use E_* constants
1 parent c36f172 commit e2cd6fd

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

src/wp-admin/includes/class-wp-automatic-updater.php

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1540,17 +1540,16 @@ protected function send_plugin_theme_email( $type, $successful_updates, $failed_
15401540
*/
15411541
$email = apply_filters( 'auto_plugin_theme_update_email', $email, $type, $successful_updates, $failed_updates );
15421542

1543-
if ( defined( 'WP_DEBUG' ) && WP_DEBUG && $type === 'fail' ) {
1544-
$transient_key = 'wp_last_fatal_error';
1545-
$fatal_error = get_transient( $transient_key );
1543+
if ( defined( 'WP_DEBUG' ) && WP_DEBUG && 'fail' === $type ) {
1544+
$fatal_error = get_transient( 'wp_last_fatal_error' );
15461545
if ( $fatal_error ) {
1547-
$email['body'] .= "\n\n=== LAST FATAL ERROR (PHP) ===\n";
1548-
$email['body'] .= "" . $fatal_error . "\n";
1546+
$email['body'] .= "\n\n=== LAST FATAL PHP ERROR ===\n";
1547+
$email['body'] .= '' . $fatal_error . "\n";
15491548
$email['body'] .= "========================================\n";
1550-
delete_transient( $transient_key );
1549+
delete_transient( 'wp_last_fatal_error' );
15511550
}
15521551
}
1553-
1552+
15541553
$result = wp_mail( $email['to'], wp_specialchars_decode( $email['subject'] ), $email['body'], $email['headers'] );
15551554

15561555
if ( $result ) {
@@ -1843,8 +1842,8 @@ protected function has_fatal_error() {
18431842
$fatal_error = null;
18441843

18451844
$last_error = error_get_last();
1846-
if ( $last_error && in_array( $last_error['type'], [ E_ERROR, E_PARSE, E_COMPILE_ERROR, E_USER_ERROR ] ) ) {
1847-
$fatal_error = "PHP Fatal error: {$last_error['message']} in {$last_error['file']} on line {$last_error['line']}";
1845+
if ( $last_error && in_array( $last_error['type'], array( E_ERROR, E_PARSE, E_COMPILE_ERROR, E_USER_ERROR ) ) ) {
1846+
$fatal_error = "PHP Fatal error: {$last_error['message']} in {$last_error['file']} on line {$last_error['line']}";
18481847
} else {
18491848
$log_file = WP_CONTENT_DIR . '/debug.log';
18501849
if ( file_exists( $log_file ) && is_readable( $log_file ) ) {
@@ -1855,10 +1854,10 @@ protected function has_fatal_error() {
18551854
while ( $pos > -filesize( $log_file ) ) {
18561855
fseek( $handle, $pos, SEEK_END );
18571856
$char = fgetc( $handle );
1858-
if ( $char === "\n" ) {
1859-
if ( $current_line !== '' ) {
1857+
if ( "\n" === $char ) {
1858+
if ( '' !== $current_line ) {
18601859
$line = strrev( $current_line );
1861-
if ( strpos( $line, 'PHP Fatal error' ) !== false ) {
1860+
if ( false !== strpos( $line, 'PHP Fatal error' ) ) {
18621861
$fatal_error = trim( $line );
18631862
break;
18641863
}
@@ -1869,9 +1868,9 @@ protected function has_fatal_error() {
18691868
}
18701869
$pos--;
18711870
}
1872-
if ( $current_line !== '' && $fatal_error === null ) {
1871+
if ( '' !== $current_line && null === $fatal_error ) {
18731872
$line = strrev( $current_line );
1874-
if ( strpos( $line, 'PHP Fatal error' ) !== false ) {
1873+
if ( false !== strpos( $line, 'PHP Fatal error' ) ) {
18751874
$fatal_error = trim( $line );
18761875
}
18771876
}
@@ -1881,10 +1880,10 @@ protected function has_fatal_error() {
18811880
}
18821881

18831882
if ( $fatal_error ) {
1884-
set_transient( 'wp_last_fatal_error', $fatal_error, 300 );
1883+
set_transient( 'wp_last_fatal_error', $fatal_error, 5 * MINUTE_IN_SECONDS );
18851884
}
18861885
}
1887-
1886+
18881887
delete_transient( $transient );
18891888

18901889
// Only fatal errors will result in a 'type' key.

0 commit comments

Comments
 (0)