PHP 8.5: "Using null as an array offset" deprecation in acf_pro_options_page::get_page() (pro/options-page.php:226)
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 78/100
Direzione di ricerca
Iniziare in pro/options-page.php, in acf_pro_options_page::get_page(), quindi riprodurre la deprecazione di PHP 8.5 con WP_DEBUG e WP_DEBUG_LOG abilitati. Assicurarsi che gli slug null e vuoti mantengano il comportamento esistente senza registrare la deprecazione; esaminare inoltre i pattern correlati di accesso agli array alle righe 140, 145 e 207.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- PHP
- Stelle
- 946
- Fork
- 197
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di AdvancedCustomFields/acf
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
AdvancedCustomFields/acf#1041 · 1 commento ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
AdvancedCustomFields/acf#1038 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
AdvancedCustomFields/acf#1032 · 1 commento ·
-
Drop trap, acf_after_titleAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
AdvancedCustomFields/acf#1029 · 1 commento ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
AdvancedCustomFields/acf#1028 · 1 commento ·
Tutte le issue di AdvancedCustomFields/acf
Issue simili
-
UX
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
ProfessionalWiki/NeoWiki#1573 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
-
sync-en
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
I maintainer di solito rispondono entro 1 giorno
-
sync-en
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno