wernerjoss / grav-plugin-ipcount

The IPcount Plugin is for Grav CMS. It counts the visitors on your Website
MIT License
3 stars 1 forks source link

Undefined offset: 210203 with PHP 7.4 and Grav 1.7 #1

Closed pmoreno-rodriguez closed 3 years ago

pmoreno-rodriguez commented 3 years ago

Hi. When I use the ipcount plugin with Grav 1.7 and PHP 7.4, website shows the following error:

Whoops \ Exception \ ErrorException (E_NOTICE)
Undefined offset: 210203

It seems that error can be in the lines 43-45:

$count = (int) $countdata['count'];
$daycount = (int) $countdata["days"][$today];
$isBot = false;

Could you revise this error?

wernerjoss commented 3 years ago

@pmoreno-rodriguez , well, I have seen this problem too, on a local docker instance. can you try to store a new file counter.json with content {"count":123456} or any other total count number in your user/data/counter folder ? (this solved the issue here)

pmoreno-rodriguez commented 3 years ago

Hi. I've tried what you mentioned, and now the error says:

"Undefined index: days"

This doesn't resolve the problem.

You can view directly in: http://grav17.hukawati.es/

wernerjoss commented 3 years ago

hm, strange - I just tried again with no (or empty) data file, as well as the example above (only overall count data): all ok. however, I introduced a try/catch block in case of the 'undefined index' error in file classes/ipcount.class.php. can you replace this and try again ?

pmoreno-rodriguez commented 3 years ago

Wow, now it works fine. I replaced ipcount.class.php with your new code and works perfect. You can see in http://grav17.hukawati.es/estadisticas

Thank you very much for your help

wernerjoss commented 3 years ago

ok, fine, I'm glad it works for you now. I'll make a new release and close this issue as resolved. btw., if you like this plugin, feel free to give it a star :smile: