Skip to content

Add actions field to wp cron event list#124

Draft
Copilot wants to merge 11 commits intomainfrom
copilot/add-cron-event-actions-display
Draft

Add actions field to wp cron event list#124
Copilot wants to merge 11 commits intomainfrom
copilot/add-cron-event-actions-display

Conversation

Copy link
Contributor

Copilot AI commented Jan 25, 2026

Fix for Actions Field Not Being Populated

Root Cause

The lazy-loading condition if ( ! empty( $formatter->fields ) && ... ) was failing because:

  1. The WP-CLI Formatter class has a __get() magic method but no __isset() method
  2. PHP's empty() function first calls __isset() to check if a property exists
  3. Without __isset(), PHP returns FALSE (property not set), making empty() return TRUE
  4. This caused the entire condition to fail, preventing actions from being populated

Solution

Assign $formatter->fields to a variable first before checking with empty():

$requested_fields = $formatter->fields;
if ( ! empty( $requested_fields ) && in_array( 'actions', $requested_fields, true ) ) {
    // populate actions
}

This ensures the magic __get() method is called and returns the actual fields array before we check if it's empty.

Test Impact

This fix resolves the failing test where the actions field was showing empty for all cron events, even when callbacks were registered.

Original prompt

This section details on the original issue you should resolve

<issue_title>wp cron event list should show the actions for each event</issue_title>
<issue_description>I just updated WP-Crontrol so it also shows the actions attached to each cron event. WP-CLI should do the same when you use wp cron event list.</issue_description>

Comments on the Issue (you are @copilot in this section)

@danielbachhuber FYI - `wp cron event list` now lives in https://github.com/wp-cli/cron-command @danielbachhuber Also, `wp profile` has a `get_name_location_from_callback` that might be useful to abstract to `WP_CLI\Utils`: https://github.com/wp-cli/profile-command/blob/master/inc/class-profiler.php#L469 @danielbachhuber Could/should this be solved with documentation instead?

Use wp hook <hook> to inspect the callbacks on each event.</comment_new>


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot AI and others added 2 commits January 25, 2026 17:40
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot AI changed the title [WIP] Add actions display for each cron event in wp cron event list Add actions field to wp cron event list Jan 25, 2026
Copilot AI requested a review from swissspidy January 25, 2026 17:48
@codecov
Copy link

codecov bot commented Jan 25, 2026

Codecov Report

❌ Patch coverage is 84.21053% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/Cron_Event_Command.php 84.21% 6 Missing ⚠️

📢 Thoughts on this report? Let us know!

This comment was marked as resolved.

swissspidy and others added 2 commits February 3, 2026 21:15
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
… actions field

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
@swissspidy

This comment was marked as resolved.

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>

This comment was marked as resolved.

@swissspidy

This comment was marked as resolved.

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>

This comment was marked as resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

wp cron event list should show the actions for each event

2 participants

Comments