Freemius / wordpress-sdk

https://freemius.com
GNU General Public License v3.0
258 stars 76 forks source link

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

Open evrpress opened 5 months ago

evrpress commented 5 months ago

🐞 bug report

Behavior:

In this video I block access to api.freemius.com:

https://github.com/Freemius/wordpress-sdk/assets/881729/d35cead8-7b18-4e5d-b80e-bc7fb6550e83

An error message should show up explaining that access to api.freemius.com is needed for activation and updates

Versions: (*)

evrpress commented 5 months ago

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 commented 5 months ago

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
);
flowdee commented 5 months ago

+1 to fix

vovafeldman commented 5 months ago

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.