Automattic / Automattic/VIP-Coding-Standards
WordPress.WP.AlternativeFunctions.file_system_operations error messages cannot be fixed anymore
- 主要言語
- PHP
- スター
- 261
- フォーク
- 44
- 平均マージ
- 19分
- マージ済み PR(30日)
- 1
説明
## Bug Description
`WordPress.WP.AlternativeFunctions.file_system_operations` error messages are overwritten in the ruleset, e.g.
```
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/
```
However since WPCS 3.0.0 this error can only be fixed by using `WP_Filesystem`. Neither `get_temp_dir()` or `wp_get_upload_dir()` will make the error go away and it's unclear why (unless you debug and find the original error message where it says `WP_Filesystem`)
## Minimal Code Snippet
```php
$f = fopen( get_temp_dir() . '/abc.log' );
```
## Error Code
`WordPress.WP.AlternativeFunctions.file_system_operations_fopen`
## Environment
| Question | Answer
| ------------------------ | -------
| PHP version | 8.3
| VIPCS version | 3.0.0
| WordPressCS version | 3.1.0
## Additional Context (optional)
With `WP_Filesystem`, I think it's unnecessary to overwrite those errors in the first place and these overwrites can all be removed from ruleset.xml
Possibly, errors like `WordPressVIPMinimum.Functions.RestrictedFunctions.file_ops_fputcsv` should be changed to a also only allow `WP_Filesystem` ?
## Tested Against `main` branch?
- [ ] I have verified the issue still exists in the `main` branch of VIPCS.
- [ ] I have verified the issue still exists in the `develop` branch of VIPCS.
コントリビューションガイド
調査の方向性
ruleset.xml の WordPress.WP.AlternativeFunctions.file_system_operations ルールから始め、設定されたメッセージと VIPCS 3.0.0 および WordPressCS 3.1.0 での動作を比較します。提供された fopen() スニペットで問題を再現し、その結果得られるガイダンスを確認します。報告されたエラーに誤解を招く修正方法が含まれなくなり、関連するファイル操作ルールが明示的で一貫した動作を持つことが完了の条件です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- php, wordpress
- 領域
- tooling
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 48/100