Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Godaddy compatibility - null passed to argument #1 $search of str_replace - array|string expected #7135

Open
joejoe04 opened this issue Nov 22, 2024 · 0 comments

Comments

@joejoe04
Copy link

Describe the bug
User reports the following error:

Fatal error: Uncaught TypeError: str_replace(): Argument #1 ($search) must be of type array|string, null given in /var/www/wp-content/plugins/wp-rocket/inc/ThirdParty/Hostings/Godaddy.php:152 Stack trace: #0 /var/www/wp-content/plugins/wp-rocket/inc/ThirdParty/Hostings/Godaddy.php(152): str_replace(NULL, '160.153.168.4', '/var/www/wp-con...') #1 /var/www/wp-content/plugins/wp-rocket/inc/ThirdParty/Hostings/Godaddy.php(107): WP_Rocket\ThirdParty\Hostings\Godaddy->purge_request('BAN', '/var/www/wp-con...') #2 /var/www/wp-includes/class-wp-hook.php(324): WP_Rocket\ThirdParty\Hostings\Godaddy->clean_file('/var/www/wp-con...') #3 /var/www/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array) #4 /var/www/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #5 /var/www/wp-content/plugins/wp-rocket/inc/functions/files.php(585): do_action('before_rocket_c...', '/var/www/wp-con...') #6 /var/www/wp-content/plugins/wp-rocket/inc/common/purge.php(249): rocket_clean_files(Array) #7 /var/www/wp-includes/class-wp-hook.php(326): rocket_clean_post(23593) #8 /var/www/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array) #9 /var/www/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #10 /var/www/wp-includes/post.php(7436): do_action('clean_post_cach...', 23593, Object(WP_Post)) #11 /var/www/wp-includes/post.php(4761): clean_post_cache(Object(WP_Post)) #12 /var/www/wp-includes/post.php(4995): wp_insert_post(Array, false, true) #13 /var/www/wp-admin/includes/post.php(453): wp_update_post(Array) #14 /var/www/wp-admin/post.php(227): edit_post() #15 {main} thrown in /var/www/wp-content/plugins/wp-rocket/inc/ThirdParty/Hostings/Godaddy.php on line 152

To Reproduce
Not entirely sure what causes it, but any case out of WP Rocket's control where wp_parse_url() returns anything other than a string or array would cause this error.

Expected behavior
We should protect against cases we can't control where wp_parse_url() returns value of type other than string or array by doing a type check here:

$url = untrailingslashit( set_url_scheme( str_replace( $host, $this->vip_url, $url ), 'http' ) );

Additional context
Ticket - https://secure.helpscout.net/conversation/2771218400/525430

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

No branches or pull requests

1 participant