Automattic / Automattic/VIP-Coding-Standards

WordPress.WP.AlternativeFunctions.file_system_operations error messages cannot be fixed anymore

Aperta
#823 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
PHP
Stelle
261
Fork
44
Merge medio
19m
PR unite (30g)
1

Descrizione

## 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.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia in ruleset.xml, nelle regole WordPress.WP.AlternativeFunctions.file_system_operations, e confronta i messaggi configurati con il comportamento in VIPCS 3.0.0 e WordPressCS 3.1.0. Riproduci il problema con lo snippet fopen() fornito e verifica le indicazioni risultanti. Il lavoro è completo quando gli errori segnalati non contengono più indicazioni di risoluzione fuorvianti e tutte le regole correlate alle operazioni sul file system hanno un comportamento esplicito e coerente.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
php, wordpress
Ambito
tooling
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
48/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.