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

PHP 8.5: "Using null as an array offset" deprecation in ACF_Data::is() when rendering a block with empty data (local-meta.php is_request)

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

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

2026年10月12日 から。

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

評価

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

調査の方向性

includes/local-meta.php と ACF_Local_Meta::is_request() から始め、報告された呼び出し経路を includes/class-acf-data.php:159 と関連するローカルフィールド関数までたどります。PHP 8.5 とデータが空の ACF ブロックで再現し、フロントエンドとエディターでのレンダリング時に deprecation が発生しなくなることを確認します。

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

説明

Describe the bug
On PHP 8.5, rendering an ACF block that has no saved field data (e.g. a block with no fields of its own that only wraps InnerBlocks) triggers:

Deprecated: Using null as an array offset is deprecated, use an empty string instead in wp-content/plugins/advanced-custom-fields-pro/includes/class-acf-data.php on line 159

It fires once per such block, on the front end and in the block editor.

Cause
ACF_Local_Meta::is_request() calls acf_is_field_key( key( $meta ) ). When the block's data is empty, key( [] ) returns null, which goes through the acf/is_field_key filter → _acf_apply_is_local_field_key() → acf_is_local_field_key( null ) → ACF_Data::is( null ) → isset( $this->data[ null ] ).

Call stack:

includes/class-acf-data.php:159            ACF_Data::is()
includes/local-fields.php:588              acf_is_local_field_key()
includes/local-fields.php:679              _acf_apply_is_local_field_key()
includes/acf-field-functions.php:209       acf_is_field_key()   (apply_filters 'acf/is_field_key')
includes/local-meta.php:90                 ACF_Local_Meta::is_request()
includes/local-meta.php:62                 ACF_Local_Meta::add()
includes/local-meta.php:249                acf_setup_meta()
pro/blocks.php:1131 / 1285                 acf_rendered_block_v3() / acf_render_block()

To Reproduce

  1. PHP 8.5, ACF PRO 6.8.10, WordPress 7.1.3, WP_DEBUG on.
  2. Register an ACF block with no field group (or no saved values) whose template renders <InnerBlocks />.
  3. Insert it into a post; the saved markup has no data attribute, e.g. <!-- wp:my-plugin/feature {"name":"my-plugin/feature","mode":"preview"} -->.
  4. View the post or open it in the editor: the deprecation above is emitted.

Expected behavior
No deprecation. E.g. in is_request(), return false when $meta is empty (or pass key( $meta ) ?? ''); alternatively make ACF_Data::is() / acf_is_local_field_key() null-safe.

Workaround
Swap ACF's filter callback for a null-safe one (behaviour is unchanged, since PHP already treated a null key as ''):

if ( remove_filter( 'acf/is_field_key', '_acf_apply_is_local_field_key', 20 ) ) {
    add_filter( 'acf/is_field_key', fn( $bool, $id ) => acf_is_local_field_key( $id ?? '' ), 20, 2 );
}

Version Information

  • WordPress 7.1.3
  • PHP 8.5.7
  • ACF PRO 6.8.10

Related: #1034 (same PHP 8.5 deprecation, different code path in pro/options-page.php).

主要言語
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 を短くまとめたダイジェスト。