Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

Suppress filters in get_posts false positive

已關閉
#899 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

@tomjn 已經在處理了。

開始於 2026年10月1日。

  • #900 來自 @tomjn —— 未關閉

評估

難度
3/5
預估耗時
1-2 天
新手友好度
68/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
活躍
技術堆疊
php, wordpress
領域
tooling

研究方向

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.

由索引模型根據 Issue 內容生成。

描述

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.
主要語言
PHP
星號
261
分支
44
平均合併
3 天 9 小時
30 天內合併 PR
10

環境準備

  • 沒有 Dockerfile 或 Docker Compose 檔案
  • 沒有 Pull Request 範本
  • 閱讀貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

Automattic/VIP-Coding-Standards 的其他 Issue

查看 Automattic/VIP-Coding-Standards 的全部 Issue

相似的 Issue

更多 PHP Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。