wordpress-sdk
wordpress-sdk copied to clipboard
Blocked access to `api.freemius.com` just fails without notice
🐞 bug report
Behavior:
-
What is the issue? (*)Some hosts block requests to other domains for "security" reasons. This happens withapi.freemius.comas well. The problem is that there's no visual feedback on the actication screen so users have no idea what's going on.
In this video I block access to api.freemius.com:
https://github.com/Freemius/wordpress-sdk/assets/881729/d35cead8-7b18-4e5d-b80e-bc7fb6550e83
-
What is the expected behavior?
An error message should show up explaining that access to api.freemius.com is needed for activation and updates
Versions: (*)
-
Freemius SDK Version:2.6.2 -
WordPress Version:6.4.2 -
PHP Version:8.2
The problem causes a Fatal Error (at least on new PHP versions)
PHP Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, false given in /wp-content/plugins/mailster/vendor/freemius/wordpress-sdk/includes/class-freemius.php:19985
Use this snippet for a quick test:
add_filter(
'pre_http_request',
function ( $bool, $r, $url ) {
if ( false !== strpos( $url, '//api.freemius.com' ) ) {
return new WP_Error( 'http_blocked', esc_html__( 'A valid URL was blocked.' ) );
}
return $bool;
},
100,
3
);
+1 to fix
We obviously have error handling in place. I'm unsure why the error wasn't triggered. The team will try to reproduce it and fix.