Closed (fixed)
Project:
Drupal core
Version:
6.9
Component:
statistics.module
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
21 Jan 2009 at 12:55 UTC
Updated:
5 Feb 2009 at 19:20 UTC
Not sure why but I get this PHP error displayed at the bottom of the front page (and seems like only the front page) when admin is logged out (in anonymous mode):
Fatal error: Call to undefined function user_access() in ../modules/statistics/statistics.module on line 52
When logged in as admin, it goes away.
I checked Line 52 of my statistics.module and I see this code:
/* Extended filtering added by SiliconMind */
if (variable_get('statistics_exclude_admins',true) && user_access('administer site configuration'))
return;
Can someone give me clues on what may be causing this?
Comments
Comment #1
asimmonds commentedYou have the page cache enabled in the performance settings, which serves cached pages to anonymous users. Drupal only loads a subset of the full functionality available while doing this.
Your statistics.module is locally modified (from issue #255769: statistics module needs basic log rules ?), either remove these local modifications or disable page caching.
You could try moving the
drupal_bootstrap(DRUPAL_BOOTSTRAP_PATH);line above the modified code.Comment #2
spiffyd commented@asimmonds: Thank you for your suggestions!
Yes I did have a locally modified statistics.module (from issue #255769: statistics module needs basic log rules ).
Since these features are crucial, I kept the modifications and disabled page caching instead.
I also posted an entry in the #255759 thread http://drupal.org/node/255769 linking the patch to this issue.
Comment #3
dave reidspiffyd: You might be interested in the Statistics Advanced Settings module (http://drupal.org/project/statistics_advanced). Marking as fixed since this was a problem with a core hack.
Comment #4
gpk commented@2: if you change the line
if (variable_get('statistics_exclude_admins',true) && user_access('administer site configuration'))to
if ($user->uid && variable_get('statistics_exclude_admins',true) && user_access('administer site configuration'))you can should be able to use normal page caching as well as the patch. (Anonymous users should not have admin permissions, and non-anonymous users will never see cached pages, so user_access will work.)
There is also http://drupal.org/project/statistics_filter, per http://drupal.org/node/255769#comment-837557. but this hasn't had much activity recently, and there is a suggestion that it will in any case #305764: Merge with Statistics Advanced module?.