marknotton / craft-plugin-agent

Query the server-side information from the users agent data.
MIT License
7 stars 4 forks source link

floor(): Argument #1 ($num) must be of type int|float, string given #11

Closed schellenbergk closed 3 years ago

schellenbergk commented 3 years ago

Getting this on "craftcms/cms": "^3.6.0", PHP 7.4.16

TypeError: floor(): Argument #1 ($num) must be of type int|float, string given in /vendor/marknotton/agent/src/services/Services.php:244
Stack trace:
#0 /vendor/marknotton/agent/src/services/Services.php(244): floor('89.0.4389.82')
...

Its this line:

$this->version = floor($this->agent->version($this->agent->browser()));

marknotton commented 3 years ago

Thanks, I'll check this out.

icreatestuff commented 3 years ago

I'm also getting this. Seems to be a problem in Google Chrome and MacOS Safari that are reporting strings like '91.0.4472.114' and '14.0.3'. Firefox (v88.0 at least) continues to work.

marknotton commented 3 years ago

Thanks for your input @icreatestuff, and my apologies for the delayed response to this @schellenbergk.

It's been a long while since I've updated this plugin and it needed a little TLC before I felt comfortable submitting a new release. I wasn't able to replicate the issue you've experienced, but that floor method obviously didn't account for strings.

I've got a new release out, it should start appearing in the Plugin Store soon. Or you can give it a go here: https://github.com/marknotton/craft-plugin-agent/releases/tag/1.2.0

Let me know how you get on please 👍

icreatestuff commented 3 years ago

Thanks for the new release that's fixed up the issues I was seeing 👍