Skip to content

Commit

Permalink
Code Modernization: Replace strpos() with str_starts_with() (#34135)
Browse files Browse the repository at this point in the history
Co-authored-by: Brad Jorsch <[email protected]>

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/6932111860
  • Loading branch information
jeherve authored and matticbot committed Nov 20, 2023
1 parent fe7dce9 commit 30f001c
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 5 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 Modernization: Replace usage of strpos() with str_starts_with().
- General: updated PHP requirement to PHP 7.0+
- General: update WordPress version requirements to WordPress 6.3.
- Updated package dependencies.
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 @@ -167,7 +167,7 @@ function wpsc_delete_cache_directory() {
$path = trailingslashit( $path );
$supercachepath = realpath( get_supercache_dir() );

if ( false === wp_cache_confirm_delete( $path ) || 0 !== strpos( $path, $supercachepath ) ) {
if ( false === wp_cache_confirm_delete( $path ) || ! str_starts_with( $path, $supercachepath ) ) {
wp_cache_debug( 'Could not delete directory: ' . $path );
define( 'WPSCDELETEERROR', 'Could not delete directory' );
return false;
Expand Down
2 changes: 1 addition & 1 deletion ossdl-cdn.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ function scossdl_off_rewriter( $match ) {
$include_dirs = scossdl_off_additional_directories();
}

if ( $ossdl_https && 0 === strpos( $match[0], 'https' ) ) {
if ( $ossdl_https && str_starts_with( $match[0], 'https' ) ) {
return $match[0];
}

Expand Down
2 changes: 1 addition & 1 deletion wp-cache-base.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
}

if ( count( $wpsc_path_segs ) > $wpsc_base_count &&
( ! defined( 'PATH_CURRENT_SITE' ) || 0 === strpos( $request_uri, PATH_CURRENT_SITE ) )
( ! defined( 'PATH_CURRENT_SITE' ) || str_starts_with( $request_uri, PATH_CURRENT_SITE ) )
) {
$blogcacheid = $wpsc_path_segs[ $wpsc_base_count ];
}
Expand Down
4 changes: 2 additions & 2 deletions wp-cache-phase2.php
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,7 @@ function get_current_url_supercache_dir( $post_id = 0 ) {
}
} else {
$uri = str_replace( $site_url, '', $permalink );
if ( strpos( $uri, $wp_cache_home_path ) !== 0 ) {
if ( ! str_starts_with( $uri, $wp_cache_home_path ) ) {
$uri = rtrim( $wp_cache_home_path, '/' ) . $uri;
}
}
Expand Down Expand Up @@ -3529,7 +3529,7 @@ function apache_request_headers() {
$headers = array();

foreach ( array_keys( $_SERVER ) as $skey ) {
if ( 0 === strpos( $skey, 'HTTP_' ) ) {
if ( str_starts_with( $skey, 'HTTP_' ) ) {
$header = implode( '-', array_map( 'ucfirst', array_slice( explode( '_', strtolower( $skey ) ), 1 ) ) );
$headers[ $header ] = $_SERVER[ $skey ];
}
Expand Down

0 comments on commit 30f001c

Please sign in to comment.