Opened 6 weeks ago
Closed 4 weeks ago
#64728 closed defect (bug) (fixed)
Using null as an array offset is deprecated in PHP 8.5.3
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 7.0 | Priority: | normal |
| Severity: | minor | Version: | 6.9.1 |
| Component: | Toolbar | Keywords: | has-patch commit |
| Focuses: | Cc: |
Description
Error message when using PHP 8.5.3 over PHP 8.4.18:
Deprecated: Using null as an array offset is deprecated, use an empty string instead in wp-includes/class-wp-admin-bar.php on line 172
(The error is shown right below the Admin Bar)
Change History (7)
This ticket was mentioned in PR #11055 on WordPress/wordpress-develop by @westonruter.
6 weeks ago
#1
- Keywords has-patch added
#2
follow-up:
↓ 4
@
6 weeks ago
- Keywords reporter-feedback needs-testing added
- Milestone changed from Awaiting Review to 7.0
@sky_76 I tried logging out $args['parent'] on that line and it is always either a string or false. Perhaps you have a plugin that registers an admin menu node with a parent supplied as null? Can you log out the $args to find out what plugin/theme that is?
In any case, it makes sense to improve the type checking here. I've opened https://github.com/WordPress/wordpress-develop/pull/11055 to fix. Please test that as well.
#4
in reply to:
↑ 2
@
6 weeks ago
Replying to westonruter:
@sky_76 I tried logging out
$args['parent']on that line and it is always either astringorfalse. Perhaps you have a plugin that registers an admin menu node with aparentsupplied asnull? Can you log out the$argsto find out what plugin/theme that is?
In any case, it makes sense to improve the type checking here. I've opened https://github.com/WordPress/wordpress-develop/pull/11055 to fix. Please test that as well.
Ok, I am so sorry, it is just one plugin that is the culprit:
[id] => omgf
[title] => OMGF
[parent] =>
[href] => https://mydomainname.com/wp-admin/options-general.php?page=optimize-webfonts
[group] =>
[meta] => Array
(
)
Maybe best to set this to "wontfix"? Again, sorry for that.
#5
@
6 weeks ago
- Keywords needs-testing removed
Patch Testing Report
Patch Tested: https://github.com/WordPress/wordpress-develop/pull/11055
Environment
- WordPress: 7.0-beta1-20260225.235833
- PHP: 8.5.2
- Server: PHP.wasm
- Database: WP_SQLite_Driver (Server: 8.0.38 / Client: 3.51.0)
- Browser: Chrome 145.0.0.0
- OS: macOS
- Theme: Twenty Twenty-Five 1.4
- MU Plugins: None activated
- Plugins:
- Code Snippets 3.9.5
- Test Reports 1.2.1
Steps taken
- Initiate WordPress Playground with the following link:
https://playground.wordpress.net/?php=8.5&wp=trunk
- Add the following code via
functions.phporCode Snippetsplugin to trigger the PHP notice
add_action( 'admin_bar_menu', function( $wp_admin_bar ) {
$wp_admin_bar->add_node( [
'id' => 'my-test-node',
'title' => 'Test Node',
'parent' => null,
] );
}, 999 );
- Ensure
WP_DEBUGandWP_DEBUG_LOGare true - Check
/wp-content/debug.logto view the notice:
PHP Deprecated: Using null as an array offset is deprecated, use an empty string instead in /wordpress/wp-includes/class-wp-admin-bar.php on line 172
- Apply patch
https://playground.wordpress.net/?php=8.5&wp=trunk&core-pr=11055
- Repeat steps 2-4
- Confirm that
PHP Deprecatednotice does not occur - ✅ Patch is solving the problem
Expected result
- No further PHP Deprecated notices logged when parent is
null
Screenshots/Screencast with results
#6
@
6 weeks ago
- Keywords commit added; reporter-feedback removed
- Owner set to westonruter
- Status changed from new to accepted
@ozgursar Thanks for that. Given that the issue was reproduced and the PR fixes the issue, this seems like something worthwhile to commit for core's overall type hardening and improved PHP compatibility.


Trac ticket: https://core.trac.wordpress.org/ticket/64728
## Use of AI Tools
n/a