getgrav / grav-plugin-admin

Grav Admin Plugin
http://getgrav.org
MIT License
355 stars 227 forks source link

Statistics does not work #992

Open Kuurusch opened 7 years ago

Kuurusch commented 7 years ago

Hallo, I'm back with a new problem :) I've recognised, that the statistics on the frontpanel in the admin-interface does not work. It stays 0. Any idea what the problem could be or how to debug? I tested it from several other IP-destinations but nothing happens.

flaviocopes commented 7 years ago

Did you turn off "Visitor tracking" in the Admin plugin settings?

Kuurusch commented 7 years ago

No, it is activated

Kuurusch commented 7 years ago

@flaviocopes Any ideas, how I can debug this situation?

flaviocopes commented 7 years ago

The functionality is all provided in https://github.com/getgrav/grav-plugin-admin/blob/develop/classes/popularity.php#L47

So you might want to add some exit(); calls in that function, to determine where in the flow it's stopping. If you reach the end, might be permission issues in saving the data under logs/popularity

Kuurusch commented 7 years ago

So is this true, that I have to look in the user/plugins/admin/classes/popularity.php ? When I analyse in this file the function trackHit(), this function is newer be called! What could be the problem? In which file is this function called?

flaviocopes commented 7 years ago

Here: https://github.com/getgrav/grav-plugin-admin/blob/develop/admin.php#L509-L519

Kuurusch commented 7 years ago

Hm, but this function "onShutdown()" is never called! I placed an exit just at the first line in this function, and nothing happens!

rhukster commented 7 years ago

You won't see an exit because it's called after everything is sent to the browser. Put a log statement in there that will write to a file. Then you can see if it's called.

Kuurusch commented 7 years ago

Ou, ok, I thought it's something like this. Thank you!

Kuurusch commented 7 years ago

Okdoky, my call does not survives this "foreach" https://github.com/getgrav/grav-plugin-admin/blob/develop/classes/popularity.php#L63

But strangely, it also don't ends with a return statement, so it doesn't enter the if

flaviocopes commented 7 years ago

@Kuurusch that's weird. Maybe dump what's the content of $this->config->get('plugins.admin.popularity.ignore'), and when it's breaking - inside the if, or if it enters the foreach at all.

Kuurusch commented 7 years ago

Hm, so it's strange that in the admin-interface under "Popularity" there are two ignore patterns: "/test*" and "/modular". But if I try to delete them, they stay after I click the "safe-Button".

The foreach it enters, but it turns only ones with "/test*". Afterwards it breaks somehow.

flaviocopes commented 7 years ago

There is an issue with removing all elements from a list. I discovered it yesterday, going to fix it now. You can check by manually removing the items in your user/config/plugins/admin.yaml

Kuurusch commented 7 years ago

Ou cool, thanks a lot! I will try this weekend. Then I can investigate further, if the crash occures because of this second item some how. It's strange behaviour

Kuurusch commented 7 years ago

@flaviocopes Hey, there is still a problem with removing all elements from the list! I can delete the two entries "/test*" and "/modular" in admin.yaml over the admin-interface, but in the interface itselve they stay

I think this is a problem as soon as one changes something else in the admin-interface and press the safe-button. After that these two entries are again in the admin.yaml-file!

Kuurusch commented 7 years ago

Ok, I've found the problem with the statistic-function. I found out, that the fnmatch()-function from php is in my system not known. It's something with POSIX, so somehow it seems, OpenWRT is not fully POSIX compatible and therefore PHP has not installed the POSIX-functions. But I thought, OpenWRT is based on Debian and Debian is POSIX conform...