Skip to content

Commit 206d837

Browse files
tbradshamatticbot
authored andcommitted
Phan: Address PhanTypeSuspiciousStringExpression violations (#45182)
Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/17809865143 Upstream-Ref: Automattic/jetpack@9162e67
1 parent 104434b commit 206d837

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

wp-cache-phase2.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1353,6 +1353,9 @@ function wpsc_delete_url_cache( $url ) {
13531353
}
13541354

13551355
// from legolas558 d0t users dot sf dot net at http://www.php.net/is_writable
1356+
/**
1357+
* @param string $path
1358+
*/
13561359
function is_writeable_ACLSafe( $path ) {
13571360

13581361
if (
@@ -1365,7 +1368,7 @@ function is_writeable_ACLSafe( $path ) {
13651368

13661369
// PHP's is_writable does not work with Win32 NTFS
13671370

1368-
if ( $path[ strlen( $path ) - 1 ] == '/' ) { // recursively return a temporary file path
1371+
if ( $path[ strlen( $path ) - 1 ] === '/' ) { // recursively return a temporary file path
13691372
return is_writeable_ACLSafe( $path . uniqid( (string) wp_rand() ) . '.tmp' );
13701373
} elseif ( is_dir( $path ) ) {
13711374
return is_writeable_ACLSafe( $path . '/' . uniqid( (string) wp_rand() ) . '.tmp' );
@@ -1404,7 +1407,7 @@ function wp_cache_setting( $field, $value ) {
14041407
}
14051408

14061409
function wp_cache_replace_line( $old, $new, $my_file ) {
1407-
if ( @is_file( $my_file ) == false ) {
1410+
if ( ! is_string( $my_file ) || @is_file( $my_file ) === false ) { // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
14081411
if ( function_exists( 'set_transient' ) ) {
14091412
set_transient( 'wpsc_config_error', 'config_file_missing', 10 );
14101413
}

wp-cache.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3047,7 +3047,9 @@ function update_cached_mobile_ua_list( $mobile_browsers, $mobile_prefixes = 0, $
30473047

30483048
function wpsc_update_htaccess() {
30493049
extract( wpsc_get_htaccess_info() ); // $document_root, $apache_root, $home_path, $home_root, $home_root_lc, $inst_root, $wprules, $scrules, $condition_rules, $rules, $gziprules
3050+
// @phan-suppress-next-line PhanTypeSuspiciousStringExpression -- $home_path is set via extract()
30503051
wpsc_remove_marker( $home_path.'.htaccess', 'WordPress' ); // remove original WP rules so SuperCache rules go on top
3052+
// @phan-suppress-next-line PhanTypeSuspiciousStringExpression -- $home_path is set via extract()
30513053
if( insert_with_markers( $home_path.'.htaccess', 'WPSuperCache', explode( "\n", $rules ) ) && insert_with_markers( $home_path.'.htaccess', 'WordPress', explode( "\n", $wprules ) ) ) {
30523054
return true;
30533055
} else {
@@ -3060,6 +3062,7 @@ function wpsc_update_htaccess_form( $short_form = true ) {
30603062

30613063
$admin_url = admin_url( 'options-general.php?page=wpsupercache' );
30623064
extract( wpsc_get_htaccess_info() ); // $document_root, $apache_root, $home_path, $home_root, $home_root_lc, $inst_root, $wprules, $scrules, $condition_rules, $rules, $gziprules
3065+
// @phan-suppress-next-line PhanTypeSuspiciousStringExpression -- $home_path is set via extract()
30633066
if( !is_writeable_ACLSafe( $home_path . ".htaccess" ) ) {
30643067
echo "<div style='padding:0 8px;color:#9f6000;background-color:#feefb3;border:1px solid #9f6000;'><h5>" . __( 'Cannot update .htaccess', 'wp-super-cache' ) . "</h5><p>" . sprintf( __( 'The file <code>%s.htaccess</code> cannot be modified by the web server. Please correct this using the chmod command or your ftp client.', 'wp-super-cache' ), $home_path ) . "</p><p>" . __( 'Refresh this page when the file permissions have been modified.' ) . "</p><p>" . sprintf( __( 'Alternatively, you can edit your <code>%s.htaccess</code> file manually and add the following code (before any WordPress rules):', 'wp-super-cache' ), $home_path ) . "</p>";
30653068
echo "<p><pre># BEGIN WPSuperCache\n" . esc_html( $rules ) . "# END WPSuperCache</pre></p></div>";
@@ -3794,6 +3797,7 @@ function wp_cache_disable_plugin( $delete_config_file = true ) {
37943797
}
37953798
}
37963799
extract( wpsc_get_htaccess_info() ); // $document_root, $apache_root, $home_path, $home_root, $home_root_lc, $inst_root, $wprules, $scrules, $condition_rules, $rules, $gziprules
3800+
// @phan-suppress-next-line PhanTypeSuspiciousStringExpression -- $home_path is set via extract()
37973801
if ( $scrules != '' && insert_with_markers( $home_path.'.htaccess', 'WPSuperCache', array() ) ) {
37983802
$wp_rewrite->flush_rules();
37993803
} elseif( $scrules != '' ) {

0 commit comments

Comments
 (0)