Automattic / Automattic/VIP-Coding-Standards
WordPress.WP.AlternativeFunctions.file_system_operations error messages cannot be fixed anymore
- Lenguaje dominante
- PHP
- Estrellas
- 261
- Forks
- 44
- Merge medio
- 19 min
- PR fusionados (30 d)
- 1
Descripción
## 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.
Guía de contribución
Línea de trabajo
Empieza en ruleset.xml, en las reglas WordPress.WP.AlternativeFunctions.file_system_operations, y compara los mensajes configurados con el comportamiento en VIPCS 3.0.0 y WordPressCS 3.1.0. Reproduce el problema con el fragmento de fopen() proporcionado y verifica las indicaciones resultantes. Se considera terminado cuando los errores notificados ya no contienen instrucciones de corrección engañosas y todas las reglas relacionadas con las operaciones del sistema de archivos tienen un comportamiento explícito y coherente.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- php, wordpress
- Área
- tooling
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 48/100