PHP 8.5: "Using null as an array offset" deprecation in acf_pro_options_page::get_page() (pro/options-page.php:226)
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
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
- Run ACF PRO 6.8.9 on PHP 8.5 with
WP_DEBUGandWP_DEBUG_LOGenabled, on a site with options pages registered. - Load front-end and admin pages.
- 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
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của AdvancedCustomFields/acf
-
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)Có thể đã có người làm @faisalahammad đã nhận 12 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
AdvancedCustomFields/acf#1044 ·
-
is_preview was called incorrectly notice on every early get_field() since 6.8.10 (acf_revisions::acf_validate_post_id)Có thể đã có người làm @faisalahammad đã nhận 12 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
AdvancedCustomFields/acf#1041 · 1 bình luận ·
-
True / False ACF control bug on RTL layoutsCó thể đã có người làm @elicohenator đã nhận 35 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
AdvancedCustomFields/acf#1038 ·
-
Bug: class-acf-field-icon_picker.php calls wp_get_attachment_image_url() with string Dashicon slug, causing fatal TypeError on PHP 8+Có thể đã có người làm @antwonw đã nhận 46 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
AdvancedCustomFields/acf#1032 · 1 bình luận ·
-
Drop trap, acf_after_titleCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
AdvancedCustomFields/acf#1029 · 1 bình luận ·
Tất cả issue của AdvancedCustomFields/acf
Issue tương tự
-
[Sync EN] calendar: document the ValueErrors thrown for invalid calendar IDs and dates (#6005)Đang mởsync-en
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
iftechfoundation/ifdb#1415 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Перевод устарел
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
glpi-project/glpi#26064 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
PHP Warning in latest verisionĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
OpenGIS/waymark-wp#79 ·