Make WordPress Core

Opened 15 months ago

Last modified 4 months ago

#57518 new defect (bug)

Undefined array key in widgets.php on line 919

Reported by: sageth's profile sageth Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Widgets Keywords: has-patch
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 (2)

This ticket was mentioned in PR #3880 on WordPress/wordpress-develop by Sageth.


15 months ago
#1

  • Keywords has-patch added

In some cases, viewing a page or post will cause a PHP warning:

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"

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

#2 @Ipstenu
4 months 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.

Note: See TracTickets for help on using tickets.