Automattic / Automattic/VIP-Coding-Standards
New Sniff: wp_get_post_revisions memory issues
- Lenguaje dominante
- PHP
- Estrellas
- 261
- Forks
- 44
- Merge medio
- 19 min
- PR fusionados (30 d)
- 1
Descripción
## 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' ) );
```
Guía de contribución
Línea de trabajo
Comienza con los ejemplos de wp_get_post_revisions que infringen la regla y los permitidos del issue, y con el ticket enlazado de WordPress Trac. Se considera terminado cuando se informan las llamadas sin un argumento fields, mientras que las llamadas que solicitan ids u otro valor de fields no se informan.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- php
- Área
- performance, tooling
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bien especificado
- Aptitud para principiantes
- 38/100