Suppress filters in get_posts false positive
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 68/100
調査の方向性
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
mainbranch of VIPCS. - I have verified the issue still exists in the
developbranch of VIPCS.
- 主要言語
- PHP
- スター
- 261
- フォーク
- 44
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
Automattic/VIP-Coding-Standards のほかの issue
-
AlwaysReturnInFilter: isInsideIfConditonal() guards the conditions array after reading it対応中かも @tomjn が 3 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
Bug: PreGetPosts warns when the early is_main_query() return is not the first statement in its if対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 76/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 48/100
-
Breaking Change Type: Maintenance
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
Automattic/VIP-Coding-Standards#849 · コメント 1 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
Automattic/VIP-Coding-Standards の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
thephpleague/commonmark#1159 ·
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
awslabs/aidlc-workflows#1879 ·
メンテナーはふだん 1 日以内に返信
-
[Bug] The PHP file that lists DNS records truncates records to 12 characters?対応中かも @sahsanu が今日担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
hestiacp/hestiacp#5769 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
bug customer-reported
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
MagnaCapax/PMSS#1011 ·
メンテナーはふだん 5 日以内に返信
-
Talk Review
難易度 2/5 1〜3時間 初心者へのやさしさ 66/100
socallinuxexpo/scale-drupal#351 ·