Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

Suppress filters in get_posts false positive

Aberta
#899 0 comentários 0 reações 0 responsáveis Ver no GitHub

@tomjn já está trabalhando nisso.

Desde 1/10/2026.

  • #900 de @tomjn — aberto

Avaliação

Dificuldade
3/5
Tempo estimado
1-2 dias
Facilidade para iniciantes
68/100
Tipo de issue
Bug
Clareza
Razoavelmente clara
Status de atividade
Ativa
Stack de tecnologia
php, wordpress
Domínio
tooling

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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.
Linguagem predominante
PHP
Estrelas
261
Forks
44
Métricas de merge de PRs
Nenhum PR com merge em 30d

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de Automattic/VIP-Coding-Standards

Todas as issues de Automattic/VIP-Coding-Standards

Issues semelhantes

Mais issues de PHP

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.