plausible / wordpress

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

PHP Parse error #186

Closed valentin-anamorphik closed 6 months ago

valentin-anamorphik commented 6 months ago

Hi,

I have this error (debug.log) when activating the plugin. Error 500.

[23-Feb-2024 10:34:08 UTC] PHP Parse error: syntax error, unexpected ')' in /wp-content/plugins/plausible-analytics/src/Admin/Settings/API.php on line 142

Thanks.

Dan0sz commented 6 months ago

Which PHP version are you using?

valentin-anamorphik commented 6 months ago

7.2.34

https://github.com/plausible/wordpress?tab=readme-ov-file#minimum-requirements

Dan0sz commented 6 months ago

Okay, and just to be sure; you're running the latest version?

Dan0sz commented 6 months ago

FYI; we're releasing 2.0.6 on Monday, try it, cause it might response your issue. If it doesn't, please let me know and see if the line number changed in the error.

Dan0sz commented 6 months ago

Nevermind! I just had a look at the code again and noticed the trailing comma after the last parameter in the sprintf() function call. Which isn't yet supported in PHP 7.2 and lower.

It'll be fixed in 2.0.6 which'll be released next Monday. If you don't want to wait, you can install the pre-release manually, which is available here.

valentin-anamorphik commented 6 months ago

Nevermind! I just had a look at the code again and noticed the trailing comma after the last parameter in the sprintf() function call. Which isn't yet supported in PHP 7.2 and lower.

It'll be fixed in 2.0.6 which'll be released next Monday. If you don't want to wait, you can install the pre-release manually, which is available here.

[26-Feb-2024 08:16:32 UTC] PHP Parse error: syntax error, unexpected 'array' (T_ARRAY), expecting function (T_FUNCTION) or const (T_CONST) in /wp-content/plugins/plausible-analytics/src/Client/lib/Model/Capabilities.php on line 84

I think your plugin requires PHP 7.4 or PHP 8.

Dan0sz commented 6 months ago

Ah, yes, you're right. The API client we added in 2.0 is a 3rd party library and I just noticed that PHP 7.4 or higher is required for it to run.

In the next release I'll raise the required PHP and WP versions.

Sorry for the hassle.