Skip to content

Conversation

barryhughes
Copy link
Member

When looking at #1271, I noticed a problem with the wp action-scheduler action get <id> command. This command was mostly functional, but also generated a warning relating to its handling of the --fields flag:

PHP Warning:  Undefined array key "fields" in /.../wp-content/plugins/action-scheduler/classes/WP_CLI/Action/Get_Command.php on line 27

The problem was a small oversight in the line used to check if this flag was set.


Steps to replicate

  1. First, identify an existing scheduled action and note down the ID.
    1. An easy way to do this is to run wp action-scheduler action list and grab the first ID.
    2. In the event you don't have any actions, you can generate one with wp eval "as_enqueue_async_action( 'test' );" (or else you can use wp action-scheduler action create test now once Import get_flag_value() from WP_CLI\Utils before using. #1271 has been merged).
  2. Using the current stable release (3.9.2), try running wp action-scheduler action get <ID> and you should see the same error noted in the PR description.
  3. Switch to this branch and repeat, the error should be solved.
  4. Confirm that the --fields flag still works as expected by running wp action-scheduler action get <ID> --fields=hook,status.

Changelog

Fixes a problem with wp action-scheduler action get and its handling of the --fields flag.

@barryhughes barryhughes requested review from a team and prettyboymp and removed request for a team June 3, 2025 13:23
@barryhughes
Copy link
Member Author

✍🏼 Note that the same challenge with PhpUnit noted here is impacting the test results.

@crstauf
Copy link
Contributor

crstauf commented Jun 4, 2025

@barryhughes Are the parentheses around the second conditional necessary at this point?

@barryhughes
Copy link
Member Author

Not strictly necessary, if I'm reading correctly, because we'd get exactly the same result without them (&& having higher precedence than ||). That said, this makes things clearer (imo) if one doesn't recall the rules of operator precedence.

Copy link
Contributor

@prettyboymp prettyboymp left a comment

Choose a reason for hiding this comment

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

Changes look good.

@prettyboymp prettyboymp merged commit 64ddf09 into trunk Jun 6, 2025
80 of 208 checks passed
@prettyboymp prettyboymp deleted the fix/ACTSCH-68/action-get-command branch June 6, 2025 19:53
@jorgeatorres jorgeatorres added this to the 3.9.3 milestone Jul 15, 2025
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