Automattic / Automattic/VIP-Coding-Standards
New Sniff: wp_get_post_revisions memory issues
- Lingua principale
- PHP
- Stelle
- 261
- Fork
- 44
- Merge medio
- 19m
- PR unite (30g)
- 1
Descrizione
## What problem would the enhancement address for VIP?
`wp_get_post_revisions` can be problematic because it loads the entire post object for each revision. I've seen this in CLI commands and other places, where you might be looping through a set of posts, and then suddenly have to load the entire post objects for every revision a post has. If those revisions are large and numerous - it quickly fails.
Related trac: https://core.trac.wordpress.org/ticket/34560
## Describe the solution you'd like
We should suggest they only get the IDs for the revisions instead of the whole object:
```
wp_get_post_revisions( $post->ID, array( 'fields' => 'ids' ) );
```
## What code should be reported as a violation?
Anything that doesn't have the fields argument, like:
```
wp_get_post_revisions( $post->ID );
```
## What code should *not* be reported as a violation?
Getting the `ids` field or other fields instead of the whole object.
```
wp_get_post_revisions( $post->ID, array( 'fields' => 'ids' ) );
```
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia con gli esempi wp_get_post_revisions che violano la regola e quelli consentiti dell'issue, oltre che con il ticket WordPress Trac collegato. Il lavoro è completato quando vengono segnalate le chiamate senza un argomento fields, mentre non vengono segnalate le chiamate che richiedono ids o un altro valore di fields.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- php
- Ambito
- performance, tooling
- Tipo di issue
- Funzionalità
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 38/100