Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I am occasionally getting the following error:
Fatal error: Call to undefined function drupal_get_path() in /path/to/better_statistics/better_statistics.module on line 181
Seems like there's no harm in replacing the drupal_get_path with a dirname(__FILE__).
Comments
Comment #1
iamEAP CreditAttribution: iamEAP commentedAnd actually, after trying that, it fired another call to undefined function, this time on drupal_get_schema_unprocessed. Looks like we need to manually include common.inc in better_statistics_exit().
Comment #2
iamEAP CreditAttribution: iamEAP commentedLooks like this happens only when a page is served from cache. Bumping to major.
We should also add a test for this.
Comment #3
mondrake+1 I also found my error_log full of this. All cached pages served to anonymous users.
Cheers
Comment #4
iamEAP CreditAttribution: iamEAP commentedNo tests, but I'm using this on a production site.
Another workaround, I believe, is to just save the statistics configuration form.
Comment #5
mondrakeCurrently testing on a site. The patch itself seems OK. The problem I currently have is with caching overall. It seems like modules are not 'loaded' when serving a cached page. So I have a problem in the integration I wrote for Browscap. The statistics.api works, but a sub-function (called by the callback) which resides in the module, is not available, so kicking a 'Call to undefined function browscap_get_browser()' in the error_log (I am not sure if the page was served anyway, or the error presented to the user as well).
I'll be back when I have more. Most probably nothing for you to do in code, but some development guidelines for documentation to be added to cope with caching.
Makes sense to you?
Comment #6
iamEAP CreditAttribution: iamEAP commentedHi, Mondrake. I believe I understand; I've created a separate issue here: #1879512: API - Dealing with statistics data collection on cached page requests Let me know there if I'm completely off base.
In the meantime, let me know how the patch above works for you.
Think I'd like to do another point release once this, the issue I just mentioned, and drush integration are done.
Comment #7
mondrakeI made progress vs. my issue in #5: Browscap now OK, but my other module using statistics API, ip_geoloc, now shows the same problem).
This means I believe that the patch in #4 works fine as long as no other modules are engaged in a cached page request - for which I will follow on in #1879512: API - Dealing with statistics data collection on cached page requests that makes the exact point.
All this to say RTBC :)
Comment #8
iamEAP CreditAttribution: iamEAP commentedThanks as always for your participation, mondrake!
http://drupalcode.org/project/better_statistics.git/commit/e88ba2b
Comment #9
mondrakeHmmm - sorry to reopen.
Now I am getting the following error:
when a page is served from cache, with modules integrated through the API.
In fact I believe the problem is in line 173-4
module_load_install() calls module_load_include() that calls drupal_get_path(). If this last is not defined, statistics.install won't be loaded and the schema result empty - leading to the error above.
Would it make sense to include statistics.install directly instead, like (not tested yet, just thinking aloud :)) :
cheers
Comment #10
mondrakeYep, solution in #9 worked fine for me, so here's the patch for review
Comment #11
iamEAP CreditAttribution: iamEAP commentedThanks for the patch, Mondrake.
Seems good, but it's definitely apparent that we need to add tests to ensure we don't get these errors on pages served from cache.
I likely will not have time to get to this until at least the weekend, so feel free to take a stab at a test.
Comment #12
mondrakeNot really my playground :)
I'll be happy to review yours...
Comment #13
iamEAP CreditAttribution: iamEAP commentedAlright. Here's two patches. One's test only, the other is test and real patch. Test only should fail, the full patch should pass.
I made one modification to your patch in #10, mondrake. The call to require install.inc isn't necessary.
Comment #14
mondrakeWorks fine. Thanks.
Comment #15
iamEAP CreditAttribution: iamEAP commentedThanks again, mondrake.
http://drupalcode.org/project/better_statistics.git/commit/079a2bf