Skip to content

Commit

Permalink
Phan: functionify and statusify exit() and die() (#41167)
Browse files Browse the repository at this point in the history
* non-CRM: exit → exit( 0 )

* CRM: exit → exit( 0 )

* non-CRM: exit() → exit( 0 )

* CRM: exit() → exit( 0 )

* die → die(0)

* Suppress invalid Phan error on valid tests

* die() → die(0)

* Add changelogs

* Suppress unneeded suppression warnings on PHP 8.2

* Oops

* Rework code to satisfy Phan bug

* Remove redundant exits

* Correct PHPDoc

* Update baseline

* Remove comments

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/12871434613

Upstream-Ref: Automattic/jetpack@d2c7b02
  • Loading branch information
tbradsha authored and matticbot committed Jan 20, 2025
1 parent 967d0c5 commit b8896fc
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
This is an alpha version! The changes listed here are not final.

### Changed
- Code: Use function-style exit() and die() with a default status code of 0.
- Updated package dependencies.

## [2.0.0] - 2025-01-10
Expand Down
2 changes: 1 addition & 1 deletion inc/delete-cache-button.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ function wpsc_admin_bar_delete_cache() {
} else {
wp_safe_redirect( esc_url_raw( home_url( $req_path ) ) );
}
exit;
exit( 0 );
} else {
die( "Oops. Problem with nonce. Please delete cached page from settings page." );
}
Expand Down
8 changes: 4 additions & 4 deletions wp-cache-phase2.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,15 +321,15 @@ function wp_cache_serve_cache_file() {
if ( $remote_mod_time !== null && $remote_mod_time == $local_mod_time ) {
wp_cache_debug( 'wp_cache_serve_cache_file: Send 304 Not Modified header.' );
header( $_SERVER['SERVER_PROTOCOL'] . ' 304 Not Modified' );
exit();
exit( 0 );
} else {
wp_cache_debug( 'wp_cache_serve_cache_file: 304 browser caching not possible as timestamps differ.' );
}
header( 'Last-Modified: ' . $local_mod_time );
}

echo $cachefiledata;
exit();
exit( 0 );
} else {
wp_cache_debug( 'No wp-cache file exists. Must generate a new one.' );
return false;
Expand Down Expand Up @@ -404,7 +404,7 @@ function wp_cache_serve_cache_file() {
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- this is the cached version of the current page. It will have been escaped already.
echo $cache;
wp_cache_debug( 'exit request', 5 );
die();
die( 0 );
}

function wp_cache_get_legacy_cache( $cache_file ) {
Expand Down Expand Up @@ -1259,7 +1259,7 @@ function wpsc_create_debug_log( $filename = '', $username = '' ) {
header( "WWW-Authenticate: Basic realm=\"WP-Super-Cache Debug Log\"" );
header( $_SERVER[ "SERVER_PROTOCOL" ] . " 401 Unauthorized" );
echo "You must login to view the debug log";
exit;
exit( 0 );
}' . PHP_EOL;

$fp = fopen( $cache_path . 'view_' . $wp_cache_debug_log, 'w' );
Expand Down
2 changes: 1 addition & 1 deletion wp-cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -2079,7 +2079,7 @@ function wpsc_config_file_notices() {
function wpsc_dismiss_indexhtml_warning() {
check_ajax_referer( "wpsc-index-dismiss" );
update_site_option( 'wp_super_cache_index_detected', 3 );
die();
die( 0 );
}
add_action( 'wp_ajax_wpsc-index-dismiss', 'wpsc_dismiss_indexhtml_warning' );

Expand Down

0 comments on commit b8896fc

Please sign in to comment.