Hacktoberfest 2026 : les issues que les mainteneurs ont marquées pour octobre, ouvertes et accessibles aux débutants. Parcourir les issues Hacktoberfest

Suppress filters in get_posts false positive

Fermée
#899 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

@tomjn y travaille déjà.

Depuis le 1/10/2026.

  • #900 par @tomjn — ouverte

Évaluation

Difficulté
3/5
Temps estimé
1-2 jours
Accessibilité débutants
68/100
Type d'issue
Bug
Clarté
Plutôt claire
Activité
Active
Stack technique
php, wordpress
Domaine
tooling

Piste de recherche

Reproduce the warning using the minimal get_posts() snippet against the VIP Coding Standards main branch, then trace how the phpcs:ignore comment is handled alongside suppress_filters. Done means the false-positive warning is no longer reported while the intended meta_key warning remains available.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

Bug Description

This get_posts call generates a warning that you must use suppress_filters set to false for performance reasons, despite that already being the case:

	$post_ids = get_posts( [
		'post_type'        => [ 'post' ],
		'post_status'      => 'publish',
		'fields'           => 'ids',
		'meta_key'         => 'foobar', // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_key
		'suppress_filters' => false,
	] );

My suspicion is that phpcs ignore comment is breaking the parsing of the array somehow.

( Note this is legacy code, we're aware of the meta_key issue )

Minimal Code Snippet

	$post_ids = get_posts( [
		'post_type'        => [ 'post' ],
		'post_status'      => 'publish',
		'fields'           => 'ids',
		'meta_key'         => 'foobar', // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_key
		'suppress_filters' => false,
	] );

Error Code

⚠️ Warning( severity 3 ): get_posts() is uncached unless the "suppress_filters" parameter is set to false. If the suppress_filter parameter is set to false this can be safely ignored. More Info: https://docs.wpvip.com/technical-references/caching/uncached-functions/ (WordPressVIPMinimum.Functions.RestrictedFunctions.get_posts_get_posts).

Environment

This occurred 1st October in the VIP Coding standards bot on a github pull request

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.
Langage dominant
PHP
Étoiles
261
Forks
44
Merge moyen
3 j 9 h
PR mergées (30 j)
10

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de Automattic/VIP-Coding-Standards

Toutes les issues de Automattic/VIP-Coding-Standards

Issues similaires

Plus d'issues PHP

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.