AdvancedCustomFields / AdvancedCustomFields/acf
PHP 8.5: "Using null as an array offset" deprecation in acf_pro_options_page::get_page() (pro/options-page.php:226)
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 945
- Forks
- 197
- PR merge metrics
- No merged PRs in 30d
Description
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.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in pro/options-page.php at acf_pro_options_page::get_page(), then reproduce the PHP 8.5 deprecation with WP_DEBUG and WP_DEBUG_LOG enabled. Ensure null and empty slugs retain their existing behavior without logging the deprecation; also review the related array-offset patterns on lines 140, 145, and 207.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100