Opened 3 years ago
Closed 3 months ago
#57518 closed defect (bug) (fixed)
Undefined array key in widgets.php on line 919
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 7.0 | Priority: | normal |
| Severity: | normal | Version: | 2.8 |
| Component: | Widgets | Keywords: | has-patch needs-testing has-unit-tests |
| Focuses: | Cc: |
Description
If you enable a plugin with a widget and then go to a page which does not display the widget (e.g. a Jetpack sitemap), you will receive an error similar to:
PHP message: PHP Warning: Undefined array key "jetpack-search-filters-1" in /wp-includes/widgets.php on line 918
PHP message: PHP Warning: Trying to access array offset on value of type null in /wp-includes/widgets.php on line 918" while reading response header from upstream, ...,
request: "GET /attachment-sitemap4.xml HTTP/2.0", ...,
referrer: "/sitemap_index.xml"
The issue appears to occur with some plugins, but not all and adding a check to see if the variable is set first seems to address the issue. There is no identified front-end impact, however, this can quickly fill up logs depending on your site traffic and configuration.
Testing can be completed by using Jetpack Search and Rank Math Sitemap xml files, though other combinations exist.
Change History (11)
This ticket was mentioned in PR #3880 on WordPress/wordpress-develop by Sageth.
3 years ago
#1
- Keywords has-patch added
#2
@
2 years ago
I'm seeing this with Jetpack and (I think...) YoastSEO as well.
It would be nice to have this in core since it's a fairly minor change and (having tested) does work.
@mindctrl commented on PR #3880:
11 months ago
#3
@Sageth are you still around and able to bring this up to date with trunk?
11 months ago
#4
@Sageth are you still around and able to bring this up to date with
trunk?
Updated with trunk as well as adding parenthesis suggestion and addressing the code standard failure.
This ticket was mentioned in PR #10710 on WordPress/wordpress-develop by @josephscott.
3 months ago
#6
- Keywords has-unit-tests added
https://core.trac.wordpress.org/ticket/57518
This includes a test for this condition.
#7
@
3 months ago
I have a version of this that includes a test for the condition that generates the warning - https://github.com/WordPress/wordpress-develop/pull/10710
@westonruter commented on PR #10710:
3 months ago
#8
There's one error:
1) Tests_Widgets_WpBlockThemeRegisterClassicSidebars::test_should_reregister_previous_theme_sidebar PHPUnit\Framework\InvalidArgumentException: Argument #1 of PHPUnit\Framework\Assert::assertArrayNotHasKey() must be an integer or string /var/www/tests/phpunit/tests/widgets/wpBlockThemeRegisterClassicSidebar.php:54 phpvfscomposer:///var/www/vendor/phpunit/phpunit/phpunit:106 /var/www/vendor/bin/phpunit:118
@josephscott commented on PR #10710:
3 months ago
#9
Thank you - I should have ran a broader set of the tests before pushing this. Updated.
In some cases, viewing a page or post will cause a PHP warning:
This appears to be a logging issue only.
Description of Change: Adding a check to see if the widget ID is set prior to evaluation.
Trac ticket: https://core.trac.wordpress.org/ticket/57518