Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

PHP 8.5: "Using null as an array offset" deprecation in acf_pro_options_page::get_page() (pro/options-page.php:226)

Đang mở Phù hợp với người mới
#1,034 3 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
78/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
php
Lĩnh vực
backend

Hướng nghiên cứu

Bắt đầu trong pro/options-page.php tại acf_pro_options_page::get_page(), sau đó tái hiện cảnh báo ngừng sử dụng của PHP 8.5 với WP_DEBUG và WP_DEBUG_LOG được bật. Đảm bảo các slug null và rỗng vẫn giữ nguyên hành vi hiện có mà không ghi nhật ký cảnh báo ngừng sử dụng; đồng thời xem xét các mẫu array-offset liên quan ở các dòng 140, 145 và 207.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Describe the bug
On PHP 8.5, ACF PRO 6.8.9 logs this on a large share of requests — about 850 entries a day on our site:

PHP Deprecated: Using null as an array offset is deprecated, use an empty string instead in wp-content/plugins/advanced-custom-fields-pro/pro/options-page.php on line 226

Line 226 is the body of acf_pro_options_page::get_page():

function get_page( $slug ) {

	return isset( $this->pages[ $slug ] ) ? $this->pages[ $slug ] : null;
}

It is being called with $slug === null, and PHP 8.5 deprecates using null as an array offset.

To Reproduce

  1. Run ACF PRO 6.8.9 on PHP 8.5 with WP_DEBUG and WP_DEBUG_LOG enabled, on a site with options pages registered.
  2. Load front-end and admin pages.
  3. See the deprecation in wp-content/debug.log.

We have not pinned down which caller passes the null slug; anything that reaches get_page() with null triggers it.

Expected behavior
No deprecation. A null key has always addressed the same array entry as '', so converting it first changes nothing about what the method returns:

function get_page( $slug ) {

	if ( null === $slug ) {
		$slug = '';
	}

	return isset( $this->pages[ $slug ] ) ? $this->pages[ $slug ] : null;
}

Tested on PHP 8.5: get_page( null ) still returns the page stored under '', normal and missing slugs behave as before, and the deprecation no longer appears in our log (250 entries in the 40 minutes before the change).

Screenshots or Video
Not applicable — the log line is quoted above.

Code
No field group export needed; the notice comes from pro/options-page.php itself.

Version Information:

  • WordPress Version 7.1
  • PHP Version 8.5.8
  • ACF Version ACF PRO 6.8.9
  • Browser not applicable (server-side)

Additional context
The same $this->pages[ $slug ] pattern also appears on lines 140, 145 and 207 of pro/options-page.php. They are not firing for us, but they would raise the same notice if they ever received a null slug, so they may be worth the same guard.

Ngôn ngữ chính
PHP
Star
947
Fork
198
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của AdvancedCustomFields/acf

Tất cả issue của AdvancedCustomFields/acf

Issue tương tự

Thêm issue về PHP

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.