#54558 closed defect (bug) (fixed)
Notice: Undefined index in WordPress 5.9 Beta
Reported by: | kafleg | Owned by: | audrasjb |
---|---|---|---|
Milestone: | 5.9 | Priority: | normal |
Severity: | normal | Version: | 5.9 |
Component: | Editor | Keywords: | has-patch has-unit-tests commit |
Focuses: | Cc: |
Description
When we go to Appearance > Editor and then to Template Parts, I see this notice.
<b>Notice</b>: Undefined index: path in <b>E:\laragon\www\59-beta\wp-includes\rest-api.php</b> on line <b>2854</b><br />
Screenshot: https://prnt.sc/21dpjkw
Attachments (2)
Change History (21)
This ticket was mentioned in Slack in #core-test by costdev. View the logs.
3 years ago
#4
@
3 years ago
- Component changed from General to Editor
- Milestone changed from Awaiting Review to 5.9
#5
@
3 years ago
Hi there!
In addition to the error, I also see the below error in my error log.
PHP Warning: array_keys() expects parameter 1 to be array, bool given in /wordpress/wp-includes/update.php on line 993 PHP Warning: Invalid argument supplied for foreach() in /wordpress/wp-includes/update.php on line 993
This ticket was mentioned in PR #1996 on WordPress/wordpress-develop by costdev.
3 years ago
#6
- Keywords has-unit-tests added
This PR:
- Covers
$path
values of typestring
. - Covers
$path
values of typearray
with values of typestring
. - Adds unit tests.
Trac ticket: https://core.trac.wordpress.org/ticket/54558
#7
follow-up:
↓ 11
@
3 years ago
@mukesh27 To make sure this doesn't occur at an earlier stage, can you do the following:
- Navigate to
Appearance > Editor
. - Clear your
debug.log
file. - Navigate to
Template Parts
. - Confirm that the log now contains the error you mentioned above.
This ticket was mentioned in Slack in #core by audrasjb. View the logs.
3 years ago
#10
@
3 years ago
- Owner set to audrasjb
- Status changed from new to reviewing
Self assigning for test/review.
#11
in reply to:
↑ 7
@
3 years ago
If I follow the below steps I don't get additional errors that I post.
Replying to costdev:
- Navigate to
Appearance > Editor
.- Clear your
debug.log
file.- Navigate to
Template Parts
.- Confirm that the log now contains the error you mentioned above.
#12
@
3 years ago
Test Report
Env
- WordPress 5.0.14 and 5.9-beta1
- Ubuntu 20.04.2 LTS server
- Theme: Twenty Twenty One
- Plugin: WP Downgrade | Beta Tester
Steps to test
- Navigate to Appearance > Editor.
- Clear your debug.log file.
- Navigate to Template Parts.
No error in debug.log nor on the frontend.
#13
@
3 years ago
- Keywords commit added; needs-testing removed
- Status changed from reviewing to accepted
It looks good to me as well.
As the two previous tests were successful, let's commit the last patch.
3 years ago
#15
Committed in https://core.trac.wordpress.org/changeset/52312
#18
@
3 years ago
[52312] added a foreach loop with the value being assigned by reference.
This can lead to weird issues later on, if the variable (here: $path
) is used again in the function, while the reference was not broken. While it's not in this case, let's follow best practices and add unset( $path );
after the loop.
See e.g. the example at https://www.php.net/manual/en/control-structures.foreach.php
Thanks for reporting this issue @kafleg!
Test Report
Env
Steps to test
Appearance > Editor
.Template Parts
.Results
The reported notice is displayed:
Notes
?context=edit
path missing a leading slash.