Automattic / Automattic/VIP-Coding-Standards

Add check for queries made without post_status or post_type

Abierto
#186 0 comentarios 0 reacciones 0 asignados Ver en GitHub
Type: Enhancement
Lenguaje dominante
PHP
Estrellas
261
Forks
44
Merge medio
19 min
PR fusionados (30 d)
1

Descripción

See https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/459.

----

A sniff can be added to flag `get_posts()` and `WP_Query` instances that are made without supplying post_status or post_type. See rationale:

> ## Not defining post_status Or post_type
>
> By default the post_status of a query is set to publish for anonymous users on the front end. It is not set in any WP_ADMIN context including Ajax queries. Queries on the front end for logged in users will also contain an OR statement for private posts created by the logged in user, even if that user is not part of the site. This will reduce the effectiveness of MySQL indexes, specifically the type_status_date index.
>
> The same is true for post_type, if you know that only a certain post_type will match the rest of the query (for example for a taxonomy, meta or just general query) adding the post_type as well as the post_status will help MySQL better utilize the indexes as it’s disposal.

https://vip.wordpress.com/documentation/code-review-what-we-look-for/#not-defining-post_status-or-post_type

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Empieza leyendo el issue enlazado de WordPress-Coding-Standards y las directrices de revisión de código de VIP; después, inspecciona los sniffs existentes de PHP_CodeSniffer del repositorio. Sigue cómo se analizan las llamadas a get_posts() y WP_Query. Se considera terminado cuando la nueva comprobación marque las consultas que omitan post_status o post_type, con un comportamiento coherente con la justificación indicada.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
php
Área
tooling
Tipo de issue
Nueva funcionalidad
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.