Skip to content

Argument 2 ($url) passed to exclude_rocket_from_wp_updates() must be of the type string #7042

@joejoe04

Description

@joejoe04

Describe the bug
User reported the following error with version 3.17.1 (incomplete stack trace was provided):

Se ha producido un error del tipo E_ERROR en la línea 135 del archivo /home/customer/www/example.net/public_html/wp-content/plugins/wp-rocket/inc/Engine/Plugin/UpdaterSubscriber.php. Mensaje de error: Uncaught TypeError: Argument 2 passed to WP_Rocket\Engine\Plugin\UpdaterSubscriber::exclude_rocket_from_wp_updates() must be of the type string, null given, called in /home/customer/www/example.net/public_html/wp-includes/class-wp-hook.php on line 324 and defined in /home/customer/www/example.net/public_html/wp-content/plugins/wp-rocket/inc/Engine/Plugin/UpdaterSubscriber.php:135 Stack trace: #0 /home/customer/www/example.net/public_html/wp-includes/class-wp-hook.php(324): WP_Rocket\Engine\Plugin\UpdaterSubscriber->exclude_rocket_from_wp_updates(Array, NULL) #1 /home/customer/www/example.net/public_html/wp-includes/plugin.php(205): WP_Hook->apply_filters(Array, Array) #2 /home/customer/www/example.net/public_html/wp-includes/class-wp-http.php(234): apply_filters('http_request_ar...', Array, NULL) #3 /home/customer/www/example.net/public_html/wp-includes/class-wp-http.php(638): WP_Http->request(NULL, Array) #4 /home/customer/www/example.net/public_html/wp-includes/http.php(184): WP_Http->get(NULL, Array) #5 /h

It relates to this line:

public function exclude_rocket_from_wp_updates( $request, string $url ) {

I can see a recent update to the related method here:
7348869
https://imageshack.com/a/img922/4788/YNsWPZ.png

The change removed the check to make sure $url is a string, and it opens us up to errors like these.

To Reproduce
Steps to reproduce the behavior:

  1. Update to version 3.17.1
  2. Not sure exactly what other condition is required. Could be a conflict with another plugin or theme.
  3. Anything that could cause the $url parameter to not be of type string.

Expected behavior
We should check to confirm the $url parameter is a string to prevent this error from happening.

Additional context
Ticket - https://secure.helpscout.net/conversation/2737001255/518317
Slack - https://wp-media.slack.com/archives/C43T1AYMQ/p1729176825682779

Metadata

Metadata

Labels

priority: mediumIssues which are important, but no one will go out of business.severity: moderateFeature isn't working as expected but has work around to get same value

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions