Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

is_preview was called incorrectly notice on every early get_field() since 6.8.10 (acf_revisions::acf_validate_post_id)

オープン 初心者向け
#1,041 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

@faisalahammad がすでに取り組んでいます。

2026年10月12日 から。

  • #1049 @faisalahammad による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
php
領域
backend

調査の方向性

includes/revisions.php の acf_revisions::acf_validate_post_id() から始め、その acf/validate_post_id hook と早期の preview チェックを確認します。WP_DEBUG を有効にして plugins_loaded の get_field() 呼び出しを再現し、その後、通常の preview 検証を維持したまま、早期の読み取りで is_preview 通知がログに記録されなくなっていることを確認します。

索引モデルが issue の本文から書いたものです。

説明

is_preview was called incorrectly notice on every early get_field() since 6.8.10

Environment
  • ACF PRO 6.8.10
  • WordPress 7.0 (multisite)
  • PHP 8.4
  • WP_DEBUG enabled
Description

Since 6.8.10, any get_field() / get_option()-style ACF read made before WordPress creates the main query triggers a PHP notice:

PHP Notice: Function is_preview was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. (This message was added
in version 3.1.0.) in wp-includes/functions.php on line 6131

The notice fires on every such call, so production logs fill up quickly. It also breaks sites that convert notices to exceptions: with Whoops in development, the request ends in
a 500.

Cause

acf_revisions::acf_validate_post_id() (includes/revisions.php) is hooked to acf/validate_post_id, so it runs on every field read. In 6.8.10 its early bail changed:

- // bail early if no preview in URL
- if ( ! isset( $_GET['preview'] ) ) {
+ // Bail early if not a well-formed WordPress preview context.
+ if ( ! is_preview() ) {
      return $post_id;
  }

is_preview() calls _doing_it_wrong() when the global $wp_query is not set yet. WordPress only creates it in wp-settings.php after plugins_loaded. Reading options while
plugins load (settings, feature flags, service bootstrapping) is a common and legitimate pattern, and before 6.8.10 it produced no notice.

Steps to reproduce
  1. Enable WP_DEBUG and WP_DEBUG_LOG.

  2. Add to any plugin:

    add_action( 'plugins_loaded', function () {
        get_field( 'any_field', 'option' );
    } );
    
  3. Load any front-end page.

Expected

No notice, as in 6.8.9 and earlier.

Actual

The is_preview was called incorrectly notice is logged on every call.

Suggested fix

Before the main query exists, is_preview() returns false anyway, so bailing out without calling it keeps the behavior identical:

global $wp_query;

if ( ! isset( $wp_query ) || ! is_preview() ) {
    return $post_id;
}
Workaround

Right after ACF loads, we replace ACF's callback on acf/validate_post_id with a wrapper. The wrapper calls acf()->revisions->acf_validate_post_id() only when
$GLOBALS['wp_query'] is set.

主要言語
PHP
スター
948
フォーク
198
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

AdvancedCustomFields/acf のほかの issue

AdvancedCustomFields/acf の issue をすべて見る

似ている issue

PHP の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。