wordpress-sdk icon indicating copy to clipboard operation
wordpress-sdk copied to clipboard

Blocked access to `api.freemius.com` just fails without notice

Open evrpress opened this issue 2 years ago • 4 comments

🐞 bug report

Behavior:

  • What is the issue? (*) Some hosts block requests to other domains for "security" reasons. This happens with api.freemius.com as 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

evrpress avatar Jan 17 '24 11:01 evrpress

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

evrpress avatar Jan 17 '24 11:01 evrpress

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
);

evrpress avatar Jan 17 '24 11:01 evrpress

+1 to fix

flowdee avatar Jan 17 '24 11:01 flowdee

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.

vovafeldman avatar Jan 17 '24 12:01 vovafeldman