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';

Comments

mondrake’s picture

Need 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:

      $list = system_list('module_enabled');
      $path = dirname(DRUPAL_ROOT . '/' . $list['statistics']->filename);
      require_once $path . '/statistics.install';
iamEAP’s picture

Version: 7.x-1.2 » 7.x-1.x-dev

Thanks 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.

iamEAP’s picture

Status: Active » Needs review
StatusFileSize
new763 bytes

And after closer inspection, it appears system_list('bootstrap') doesn't contain nearly enough information. Oh, well. Here's #1 as a patch.

iamEAP’s picture

Issue summary: View changes

hiding site specific paths. client privacy.

socialnicheguru’s picture

Issue summary: View changes

The patch applies fine.
I am not sure how to test

I am using redis, authcache for caching