If you override the core module into a site specific module directory then you get duplicate function error.
Fatal error: Cannot redeclare statistics_uninstall() (previously declared in [site-path]/modules/core-override/statistics/statistics.install:13) in /Sites/Drupal/modules/statistics/statistics.install on line 20
Drush command terminated abnormally due to an unrecoverable error. [error]
Error: Cannot redeclare statistics_uninstall() (previously declared in [site-path]/modules/core-override/statistics/statistics.install:13) in
/Sites/Drupal/modules/statistics/statistics.install, line 20
So instead of calling the core statistics.install file directly, I would suggest doing a drupal_get_path to see which module is actually enabeled.
Line 198 of better_statistics.module
$path = drupal_get_path('module', 'statistics');
require_once $path . '/statistics.install';
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | better_statistics-fatal_error_when_stats_module_overridden-1933096-3.patch | 763 bytes | iamEAP |
Comments
Comment #1
mondrakeNeed to be cautious here, since drupal_get_path() is only available on a fully bootstrapped request, which is not the case when a page is served from the cache. Since better_statistics_get_default_fields() may be called is such a context, that would lead to (another) fatal error.
For other similar issues I found that system_list() (which is available at DRUPAL_BOOTSTRAP_VARIABLES bootstrap phase, i.e. available in the context of better_statistics_exit, which boostraps up to DRUPAL_BOOTSTRAP_SESSION) may provide the same info, with some workaround:
Comment #2
iamEAP commentedThanks for the quick detective work, mondrake! Looks like a decent solution, there.
I believe system_list('module_enabled') would be statically cached on fully bootstrapped requests, but I don't believe it would be on cached requests. Could optimize a bit by using system_list('bootstrap') instead, since Statistics is a bootstrap module and that would be statically cached on all page requests.
davexoxide, may I ask why you've overridden the Core statistics module in a site-specific module directory? Just want to gauge how common this might be.
Comment #3
iamEAP commentedAnd after closer inspection, it appears system_list('bootstrap') doesn't contain nearly enough information. Oh, well. Here's #1 as a patch.
Comment #3.0
iamEAP commentedhiding site specific paths. client privacy.
Comment #4
socialnicheguru commentedThe patch applies fine.
I am not sure how to test
I am using redis, authcache for caching