Skip to content

Bug: upgrader_pre_download() strict bool type hint causes fatal TypeError with other plugins #371

@marcusquinn

Description

@marcusquinn

Summary

Addon_Repository::upgrader_pre_download() in inc/class-addon-repository.php:152 declares a strict bool $reply type hint:

public function upgrader_pre_download(bool $reply, $package, \WP_Upgrader $upgrader, $hook_extra) {

The WordPress upgrader_pre_download filter can legitimately pass WP_Error or string (file path) values through the callback chain — not just bool. When any earlier-priority filter returns WP_Error, this method throws a fatal TypeError.

Steps to Reproduce

  1. Install Ultimate Multisite on a WordPress Multisite
  2. Install any plugin that hooks upgrader_pre_download and may return WP_Error (e.g., Kadence Blocks Pro via StellarWP Uplink, WooCommerce Helper, GPLVault)
  3. Attempt to update any plugin via WP-CLI or the admin UI

Expected Behavior

The filter callback should accept any value that WordPress core may pass through the filter chain, including WP_Error and string.

Actual Behavior

Fatal error:

Fatal error: Uncaught TypeError: WP_Ultimo\Addon_Repository::upgrader_pre_download(): 
Argument #1 ($reply) must be of type bool, WP_Error given

This crashes the entire update process.

Suggested Fix

Remove the bool type hint from $reply, or accept mixed and handle non-bool values:

// Option 1: Remove type hint (matches WordPress core's filter signature)
public function upgrader_pre_download($reply, $package, \WP_Upgrader $upgrader, $hook_extra) {
    if (!is_bool($reply)) {
        return $reply; // Pass through non-bool values from other filters
    }
    // ... existing logic
}

// Option 2: Accept mixed and guard
public function upgrader_pre_download(mixed $reply, $package, \WP_Upgrader $upgrader, $hook_extra) {
    if ($reply !== false) {
        return $reply;
    }
    // ... existing logic
}

Environment

  • WordPress 6.7+
  • PHP 8.1+
  • Ultimate Multisite (latest from GitHub)
  • Conflicting plugins: Kadence Blocks Pro (StellarWP Uplink), GPLVault Updater, WooCommerce

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions