Skip to content

Conversation

@obenland
Copy link
Member

Fixes #

Proposed changes:

  • Added null coalescing operator to safely check if $args[0] exists before testing if it's callable in Scheduler::async_batch()

Other information:

  • Have you written new tests for your changes, if applicable?

Testing instructions:

The fix prevents a PHP warning that occurs when Scheduler::async_batch() is called without arguments:

Warning: Undefined array key 0 in /includes/class-scheduler.php on line 475
  • All existing tests continue to pass
  • The functionality remains unchanged - the code still correctly identifies when a callback is passed as the first argument

Changelog entry

  • Automatically create a changelog entry from the details below.
Changelog Entry Details

Significance

  • Patch
  • Minor
  • Major

Type

  • Added - for new features
  • Changed - for changes in existing functionality
  • Deprecated - for soon-to-be removed features
  • Removed - for now removed features
  • Fixed - for any bug fixes
  • Security - in case of vulnerabilities

Message

Undefined array key warning in Scheduler::async_batch when called without arguments.

Fixes a PHP warning that occurs when async_batch() is called without
arguments by adding a null coalescing operator to safely check if
$args[0] exists before testing if it's callable.
Copilot AI review requested due to automatic review settings November 18, 2025 18:14
@obenland obenland self-assigned this Nov 18, 2025
@obenland obenland requested a review from a team November 18, 2025 18:14
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a PHP warning that occurs when Scheduler::async_batch() is called without arguments by adding a null coalescing operator to safely check for the existence of $args[0] before testing if it's callable.

Key Changes:

  • Added null coalescing operator (??) to prevent undefined array key warning when checking if $args[0] is callable

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
includes/class-scheduler.php Added null coalescing operator to safely check $args[0] before is_callable() test
.github/changelog/2497-from-description Added changelog entry documenting the bug fix

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@obenland obenland merged commit 97582ef into trunk Nov 19, 2025
15 checks passed
@obenland obenland deleted the fix/scheduler-undefined-array-key branch November 19, 2025 12:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants