Skip to content

Fixed:The recovery_mode_clean_expired_keys cron event is orphaned after converting to Multisite#6835

Closed
narenin wants to merge 3 commits intoWordPress:trunkfrom
narenin:61450-recovery_mode_clean_expired_keys-orphaned-cron-multisite
Closed

Fixed:The recovery_mode_clean_expired_keys cron event is orphaned after converting to Multisite#6835
narenin wants to merge 3 commits intoWordPress:trunkfrom
narenin:61450-recovery_mode_clean_expired_keys-orphaned-cron-multisite

Conversation

@narenin
Copy link

@narenin narenin commented Jun 16, 2024

Trac ticket: https://core.trac.wordpress.org/ticket/61450


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@github-actions
Copy link

github-actions bot commented Jun 16, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props narenin, mukesh27, dilipbheda, johnbillion.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions
Copy link

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

add_action( 'wp_logout', array( $this, 'exit_recovery_mode' ) );
add_action( 'login_form_' . self::EXIT_ACTION, array( $this, 'handle_exit_recovery_mode' ) );
add_action( 'recovery_mode_clean_expired_keys', array( $this, 'clean_expired_keys' ) );
add_action( 'wp_install', array( $this, 'remove_orphaned_recovery_mode_cron_event' ), 10, 1 );
Copy link
Member

Choose a reason for hiding this comment

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

The function don't have argument 🤔

Copy link
Author

Choose a reason for hiding this comment

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

Sorry my bad 😞 Fixed now.

// Check if we are in a Multisite installation.
if ( is_multisite() ) {
// Check if the cron event is scheduled.
$timestamp = wp_next_scheduled( 'recovery_mode_clean_expired_keys' );

Choose a reason for hiding this comment

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

Hello @narenin,

I think it is better to use the wp_clear_scheduled_hook function instead of the wp_unschedule_event.

@mukeshpanchal27 Please share your opinions as well.

Thanks

Copy link
Member

@johnbillion johnbillion left a comment

Choose a reason for hiding this comment

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

@narenin Thanks for the PR. Are you sure that this works? The WP_Recovery_Mode class does not get instantiated when is_multisite() is true so this wp_install callback will never get called once Multisite is installed.

A better approach might be to call wp_clear_scheduled_hook( 'recovery_mode_clean_expired_keys' ) directly inside populate_network(). Needs testing though!

@narenin
Copy link
Author

narenin commented Jan 31, 2025

@johnbillion I have implemented the suggested changes, could you please take the look.

@github-actions
Copy link

A commit was made that fixes the Trac ticket referenced in the description of this pull request.

SVN changeset: 59798
GitHub commit: 9b17242

This PR will be closed, but please confirm the accuracy of this and reopen if there is more work to be done.

@github-actions github-actions bot closed this Feb 10, 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