Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

New Sniff: wp_get_post_revisions memory issues

Aperta
#468 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
38/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
php

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.

Descrizione

Standard: VIP-Go Type: Enhancement

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' ) );
Lingua principale
PHP
Stelle
261
Fork
44
Merge medio
3g 17h
PR unite (30g)
9

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Automattic/VIP-Coding-Standards

Tutte le issue di Automattic/VIP-Coding-Standards

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.