plausible / wordpress

Plausible Analytics WordPress plugin
https://plausible.io/wordpress-analytics-plugin
MIT License
50 stars 26 forks source link

Enabling userroles for tracking causes Fatal error #182

Closed ThomasTr closed 7 months ago

ThomasTr commented 7 months ago

When enabling Userroles under "Userroles tracking", it causes fatal error:

Fatal error: Uncaught TypeError: in_array(): Argument #2 ($haystack) must be of type array, string given in /var/www/wimh/wp-content/plugins/plausible-analytics-2.0.5B1/src/Includes/Actions.php:60 Stack trace: #0 /var/www/wimh/wp-content/plugins/plausible-analytics-2.0.5B1/src/Includes/Actions.php(60): in_array() #1 /var/www/wimh/wp-includes/class-wp-hook.php(324): Plausible\Analytics\WP\Includes\Actions->maybe_register_assets() #2 /var/www/wimh/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters() #3 /var/www/wimh/wp-includes/plugin.php(517): WP_Hook->do_action() #4 /var/www/wimh/wp-includes/script-loader.php(2262): do_action() #5 /var/www/wimh/wp-includes/class-wp-hook.php(324): wp_enqueue_scripts() #6 /var/www/wimh/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters() #7 /var/www/wimh/wp-includes/plugin.php(517): WP_Hook->do_action() #8 /var/www/wimh/wp-includes/general-template.php(3052): do_action() #9 /var/www/wimh/wp-content/themes/wpzoom-derive/header.php(106): wp_head() #10 /var/www/wimh/wp-includes/template.php(790): require_once('...') #11 /var/www/wimh/wp-includes/template.php(725): load_template() #12 /var/www/wimh/wp-includes/general-template.php(48): locate_template() #13 /var/www/wimh/wp-content/themes/wpzoom-derive/page-templates/homepage-builder-bb.php(6): get_header() #14 /var/www/wimh/wp-includes/template-loader.php(106): include('...') #15 /var/www/wimh/wp-blog-header.php(19): require_once('...') #16 /var/www/wimh/index.php(17): require('...') #17 {main} thrown in /var/www/wimh/wp-content/plugins/plausible-analytics-2.0.5B1/src/Includes/Actions.php on line 60
ThomasTr commented 7 months ago

Correction: The Fatal error is always on frontpage. Tested it when i was logged in, then it works. But on private browser window this error exists.

ThomasTr commented 7 months ago

Version of plugin is 2.0.5 Beta 1

ThomasTr commented 7 months ago

Upgraded to version 2.0.5 Beta 2 and no errors anymore on frontpage.

Dan0sz commented 7 months ago

Great! Still curious why you were getting those errors, even though wp_parse_args() should assure that the enhanced measurements option was an array, but regardless, adding extra checks doesn't hurt anyone.