Skip to content

Commit

Permalink
Merge pull request #646 from Automattic/silence_fclose
Browse files Browse the repository at this point in the history
Silence WordPress.WP.AlternativeFunctions.file_system_read_fclose
  • Loading branch information
rebeccahum authored Apr 6, 2021
2 parents 66bf0a9 + d988322 commit 71e109b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
4 changes: 2 additions & 2 deletions WordPress-VIP-Go/ruleset-test.inc
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ $x = sanitize_key( $_COOKIE['bar'] ); // phpcs:ignore WordPress.Security.Validat
if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && $_SERVER['HTTP_USER_AGENT'] === 'some_value' ) { // Error.
}

// WordPress.WP.AlternativeFunctions.file_system_read_fclose
fclose( $fp ); // Warning + Message.



// WordPress.WP.AlternativeFunctions.file_system_read_fopen
fopen( 'file.txt', 'r' ); // Warning + Message.
Expand Down
4 changes: 0 additions & 4 deletions WordPress-VIP-Go/ruleset-test.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@
41 => 1,
44 => 1,
47 => 1,
60 => 1,
63 => 1,
66 => 1,
85 => 1,
Expand Down Expand Up @@ -293,9 +292,6 @@
56 => [
'Due to server-side caching, server-side based client related logic might not work. We recommend implementing client side logic in JavaScript instead.',
],
60 => [
'File system operations only work on the `/tmp/` and `wp-content/uploads/` directories. To avoid unexpected results, please use helper functions like `get_temp_dir()` or `wp_get_upload_dir()` to get the proper directory path when using functions such as fclose(). For more details, please see: https://docs.wpvip.com/technical-references/vip-go-files-system/local-file-operations/',
],
63 => [
'File system operations only work on the `/tmp/` and `wp-content/uploads/` directories. To avoid unexpected results, please use helper functions like `get_temp_dir()` or `wp_get_upload_dir()` to get the proper directory path when using functions such as fopen(). For more details, please see: https://docs.wpvip.com/technical-references/vip-go-files-system/local-file-operations/',
],
Expand Down
6 changes: 3 additions & 3 deletions WordPress-VIP-Go/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,6 @@
<rule ref="WordPress.WP.AlternativeFunctions.file_system_read_fopen">
<message>File system operations only work on the `/tmp/` and `wp-content/uploads/` directories. To avoid unexpected results, please use helper functions like `get_temp_dir()` or `wp_get_upload_dir()` to get the proper directory path when using functions such as %s(). For more details, please see: https://docs.wpvip.com/technical-references/vip-go-files-system/local-file-operations/</message>
</rule>
<rule ref="WordPress.WP.AlternativeFunctions.file_system_read_fclose">
<message>File system operations only work on the `/tmp/` and `wp-content/uploads/` directories. To avoid unexpected results, please use helper functions like `get_temp_dir()` or `wp_get_upload_dir()` to get the proper directory path when using functions such as %s(). For more details, please see: https://docs.wpvip.com/technical-references/vip-go-files-system/local-file-operations/</message>
</rule>
<rule ref="WordPressVIPMinimum.Performance.FetchingRemoteData.FileGetContentsUnknown">
<message>%s() is uncached. If the function is being used to fetch a remote file (e.g. a URL starting with https://), please use wpcom_vip_file_get_contents() to ensure the results are cached. For more details, please see: https://docs.wpvip.com/technical-references/code-quality-and-best-practices/retrieving-remote-data/</message>
</rule>
Expand Down Expand Up @@ -288,5 +285,8 @@
<rule ref="WordPress.WP.AlternativeFunctions.file_system_read_readfile">
<severity>0</severity>
</rule>
<rule ref="WordPress.WP.AlternativeFunctions.file_system_read_fclose">
<severity>0</severity>
</rule>

</ruleset>

0 comments on commit 71e109b

Please sign in to comment.