Skip to content

PHP Warning: Undefined array key "widget_id" #2910

@Gnodesign

Description

@Gnodesign

Describe the bug
On PHP 8+, WP Job Manager triggers warnings for an undefined array key widget_id in WP_Job_Manager_Widget::get_cached_widget() and cache_widget(). The code assumes $args['widget_id'] is always present. The widget should gracefully handle missing widget_id values (e.g. by skipping caching) to avoid PHP warnings and ensure PHP 8+ compatibility.

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'WP Dashboard -> Appearance -> Widgets"
  2. Add "Recent/Featured Jobs" widget
  3. Save Changes
  4. See error in debug.log

Isolating the problem (mark completed items with an [x]):

  • I have deactivated other plugins and confirmed this bug occurs when only WP Job Manager plugin is active.
  • This bug happens with a default WordPress theme active.
  • I can reproduce this bug consistently using the steps above.

WordPress Environment

  • WordPress Version: 6.9
  • WP Job Manager Version: 2.4.0
  • PHP Version: 8+

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions