Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta Adatta ai principianti
#1,034 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
php
Ambito
backend

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

  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.

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

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di AdvancedCustomFields/acf

Tutte le issue di AdvancedCustomFields/acf

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.