From fc88e5d5f63c09742ac9debbaaac7664255a6653 Mon Sep 17 00:00:00 2001 From: arshidkv12 Date: Wed, 23 Sep 2026 13:27:07 +0530 Subject: [PATCH 1/2] Code Quality: Remove conditions identified as always false --- src/wp-admin/install.php | 7 ++----- src/wp-includes/template.php | 9 +-------- src/wp-login.php | 4 +--- tests/phpstan/baselines/if.alwaysFalse.neon | 15 --------------- 4 files changed, 4 insertions(+), 31 deletions(-) diff --git a/src/wp-admin/install.php b/src/wp-admin/install.php index 3d5a142b482dd..4a839877cc8b1 100644 --- a/src/wp-admin/install.php +++ b/src/wp-admin/install.php @@ -6,9 +6,7 @@ * @subpackage Administration */ -// Confidence check. -if ( false ) { - ?> +?> @@ -20,8 +18,7 @@

WordPress requires that your web server is running PHP. Your server does not have PHP installed, or PHP is turned off.

- - - - + diff --git a/tests/phpstan/baselines/if.alwaysFalse.neon b/tests/phpstan/baselines/if.alwaysFalse.neon index 6e33ed2a5365c..ed5648f9d7f5e 100644 --- a/tests/phpstan/baselines/if.alwaysFalse.neon +++ b/tests/phpstan/baselines/if.alwaysFalse.neon @@ -18,11 +18,6 @@ parameters: ignoreErrors: - - - message: '#^If condition is always false\.$#' - identifier: if.alwaysFalse - count: 1 - path: ../../../src/wp-admin/install.php - message: '#^If condition is always false\.$#' identifier: if.alwaysFalse @@ -33,13 +28,3 @@ parameters: identifier: if.alwaysFalse count: 1 path: ../../../src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php - - - message: '#^If condition is always false\.$#' - identifier: if.alwaysFalse - count: 1 - path: ../../../src/wp-includes/template.php - - - message: '#^If condition is always false\.$#' - identifier: if.alwaysFalse - count: 1 - path: ../../../src/wp-login.php From f78186f94e8b0ce6faf5be2980d434e583aed3d4 Mon Sep 17 00:00:00 2001 From: arshidkv12 Date: Wed, 23 Sep 2026 14:08:59 +0530 Subject: [PATCH 2/2] Code Quality: Remove conditions identified as always false --- src/wp-includes/template.php | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/wp-includes/template.php b/src/wp-includes/template.php index 5888c402ba089..ebb4188052b4f 100644 --- a/src/wp-includes/template.php +++ b/src/wp-includes/template.php @@ -1033,14 +1033,22 @@ function wp_finalize_template_enhancement_output_buffer( string $output, int $ph $filtered_output = $output; + $handler_state = (object) array( + 'did_just_catch' => false, + ); + $error_log = array(); set_error_handler( - static function ( int $level, string $message, ?string $file = null, ?int $line = null ) use ( &$error_log ) { + static function ( int $level, string $message, ?string $file = null, ?int $line = null ) use ( &$error_log, &$handler_state ) { // Switch a user error to an exception so that it can be caught and the buffer can be returned. if ( E_USER_ERROR === $level ) { throw new Exception( __( 'User error triggered:' ) . ' ' . $message ); } + if ( $handler_state->did_just_catch ) { + $level = E_USER_ERROR; + } + // Capture a reported error to be displayed by appending to the processed output buffer if display_errors is enabled. if ( error_reporting() & $level ) { $error_log[] = compact( 'level', 'message', 'file', 'line' ); @@ -1080,7 +1088,7 @@ static function ( int $level, string $message, ?string $file = null, ?int $line $filtered_output = (string) apply_filters( 'wp_template_enhancement_output_buffer', $filtered_output, $output ); } catch ( Throwable $throwable ) { // Emit to the error log as a warning not as an error to prevent halting execution. - $did_just_catch = true; + $handler_state->did_just_catch = true; trigger_error( sprintf( /* translators: %s is the throwable class name */ @@ -1089,7 +1097,8 @@ static function ( int $level, string $message, ?string $file = null, ?int $line ) . ' ' . $throwable->getMessage(), E_USER_WARNING ); - $did_just_catch = false; + $handler_state->did_just_catch = false; + } try { @@ -1119,7 +1128,7 @@ static function ( int $level, string $message, ?string $file = null, ?int $line do_action( 'wp_finalized_template_enhancement_output_buffer', $filtered_output ); } catch ( Throwable $throwable ) { // Emit to the error log as a warning not as an error to prevent halting execution. - $did_just_catch = true; + $handler_state->did_just_catch = true; trigger_error( sprintf( /* translators: %s is the class name */ @@ -1128,7 +1137,7 @@ static function ( int $level, string $message, ?string $file = null, ?int $line ) . ' ' . $throwable->getMessage(), E_USER_WARNING ); - $did_just_catch = false; + $handler_state->did_just_catch = false; } // Append any errors to be displayed before returning flushing the buffer.