Make WordPress Core

Opened 3 months ago

Last modified 3 months ago

#61940 new defect (bug)

`upgrader_process_complete` runs when no plugins selected to upgrade

Reported by: brianhenryie's profile brianhenryie Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: Upgrade/Install Keywords: has-patch has-screenshots
Focuses: Cc:

Description

When JavaScript is disabled it is possible to submit plugins.php's Bulk actions bulk-action-form Update option update-selected:

The update process is starting. This process may take a while on some hosts, so please be patient.
Updating Plugin (1/1)

The plugin is at the latest version.

updated successfully.

All updates have been completed.

With JavaScript enabled the process halts:

Please select at least one item to perform this action on.

This is problematic where we are listening to the upgrader_process_complete.

The trace is ~

  • plugins.php:147 switch statement case update-selected creates an iframe with update.php?action=update-selected&plugins= and no plugins in the list.
  • update.php:50 creates a new Plugin_Upgrader() and calls Plugin_Upgrader::bulk_upgrade()
  • class-plugin-upgrader.php:414 fires do_action( 'upgrader_process_complete' ... ) where the $plugins variables is array( 0 => '' )

It would be preferable if upgrader_process_complete is never called rather than needing to check for the empty-ish array.

Attachments (3)

Screenshot 2024-08-27 at 10.06.00 AM.png (17.5 KB) - added by brianhenryie 3 months ago.
UI when JavaScript is enabled and no plugins are selected for bulk update
Screenshot 2024-08-27 at 10.06.43 AM.png (83.8 KB) - added by brianhenryie 3 months ago.
UI when JavaScript is disabled and no plugins are selected for bulk update
Bulk update no plugins with no javascript.gif (74.4 KB) - added by circlecube 3 months ago.
Bulk update no plugins with no javascript

Download all attachments as: .zip

Change History (8)

@brianhenryie
3 months ago

UI when JavaScript is enabled and no plugins are selected for bulk update

@brianhenryie
3 months ago

UI when JavaScript is disabled and no plugins are selected for bulk update

This ticket was mentioned in Slack in #core-test by brianhenryie. View the logs.


3 months ago

This ticket was mentioned in PR #7255 on WordPress/wordpress-develop by @narenin.


3 months ago
#2

  • Keywords has-patch added

@circlecube
3 months ago

Bulk update no plugins with no javascript

#3 @circlecube
3 months ago

  • Keywords has-screenshots added

I tested this and confirm that when javascript is disabled, the plugins bulk update fires with no plugins selected. Attached a quick gif above.

This ticket was mentioned in PR #7264 on WordPress/wordpress-develop by @brianhenryie.


3 months ago
#4

When JavaScript is disabled in the browser, it is possible to submit plugins.php's Bulk actions Update. The updater then runs and fires upgrader_process_complete with a $plugins array with only an empty string in it.

The changes here check are any plugins selected and if not, displays an admin notice.

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

Slack request for testing tips: https://wordpress.slack.com/archives/C03B0H5J0/p1724780845998239

I tried the following as a test but it fails with Constant DB_NAME already defined.

public function test_submit_bulk_update_form_with_no_plugins_selected() {
        $_POST = array(
                'plugin_status'    => 'all',
                'paged'            => '1',
                '_wpnonce'         => wp_create_nonce( 'bulk-plugins' ),
                '_wp_http_referer' => '/wp-admin/plugins.php',
                'action'           => 'update-selected',
                'action2'          => '-1',
        );

        ob_start();
        require ABSPATH . 'wp-admin/plugins.php';
        $output = ob_get_clean();

        $this->assertNotContains( 'The update process is starting.', $output );

        $this->assertFalse( did_action( 'upgrader_process_complete' ) );
}

I will add a Playwright test showing the updater is not run and the new admin notice is displayed but it would be nice to test that the upgrader_process_complete action is never fired.

#5 @hellofromTonya
3 months ago

  • Version 6.6.1 deleted

Hello @brianhenryie,

Welcome back to WordPress Core's Trac.

I'm doing triage today for bugs reported on 6.6.1 or 6.6.2 (i.e. via Version) and then updating ticket information.

Resetting the Version, as 6.6.1 did not change the code reported in this ticket. Once the root cause is found, then the Version can be updated with the WordPress version that introduced the bug.

Note: See TracTickets for help on using tickets.