After updating to Google Analytics 6.x-2.3 through Drush I got this error:

Fatal error: Cannot redeclare googleanalytics_requirements() (previously declared in /path-to-drupal/sites/all/modules/google_analytics/googleanalytics.module:219) in /path-to-drupal/sites/all/modules/google_analytics/googleanalytics.install on line 74

Don't know if it's an isolated error in my installation or a bug, just wanted to share this.

CommentFileSizeAuthor
#25 drush-921116.patch3.31 KBjonhattan
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

JWinTX’s picture

I am getting the exact same error on all 3 of my sites.

dmjossel’s picture

Same here.

hass’s picture

I will look into it later, but please use 3.0.

hass’s picture

Project: Google Analytics » Drush
Version: 6.x-2.3 » All-versions-3.3
Component: Code » PM (dl, en, up ...)
Priority: Minor » Critical

This is a Drush bug. It complains that the hook_requirement function is declared in line 219 and this was the case in GA 2.2, but I have moved the requirement hook in 2.3 to .install file as it need to be. This was not an important GA bug, but it was a minor code change that has been made.

Please change the version number of Drush to your version. I'm only changing the queue now. Also higher the priority as I do not like to get my GA queue flodded with this Drush issue.

moshe weitzman’s picture

Project: Drush » Google Analytics
Version: All-versions-3.3 » 6.x-3.x-dev
Component: PM (dl, en, up ...) » Code
Priority: Critical » Minor
Status: Active » Fixed

Looks to me like this site has copies of both the old and new code. how could it be drush's fault if a site has duplicate functions?

AdrianB’s picture

Also higher the priority as I do not like to get my GA queue flodded with this Drush issue.

I had no intention to flood the wrong issue queue, I assumed it was an error in the GA module code and just wanted to report it. Since the error didn't effect anything (afaik) I set it to "minor".

jmuessig’s picture

subscribe

hass’s picture

Category: bug » support

If 3 people have the same issue I would really wonder if they all have the module twice on their box. I thought that Drush may load the .install before removing the old module directory. Does it really delete the old version and copy than the new version on the box?

moshe weitzman’s picture

Title: Cannot redeclare googleanalytics_requirements() » drush leaves behind old files during updatecode
Project: Google Analytics » Drush
Version: 6.x-3.x-dev »
Component: Code » PM (dl, en, up ...)
Status: Fixed » Closed (duplicate)

I see what you are saying. There are a lot of permutations for updating modules using drush (i.e. different version control strategies). I do think we have open bugs already here.

Daniel Norton’s picture

Status: Closed (duplicate) » Active

If you would like to close this as a duplicate, please identify the original.

hass’s picture

I've found #781040: Drush is not removing old files when updating modules with svnsync, but i'd like to remark that filenames have not changed in GA 3.0 nor have files removed. I have only moved a few functions from the .module into .install file. To clarify - this cannot be a "leave behind" issue!

jsibley’s picture

Version: » All-versions-3.0

I am by no means an expert, but I solved the problem for my site by:

- checking and saving my google analytics key
- disabling and removing the google analytics module
- downloading the module again using drush
- updating the site using drush (no errors this time)
- enabling the module
- putting back in the correct google analytics key

I have no idea what the cause of the problem is but I had the same error (fatal, in my case) when updating my site and this seems to have taken care of things.

hass’s picture

Deleting the old directory and uploading the new version is enough. NO need to disable the module.

selfuntitled’s picture

Version: All-versions-3.0 »

I can confirm the same problem has consistently come up on all 5 of the sites I manage. Each is a different Drupal install with dramatically different sets of modules on two different web servers.

Initially saw this problem with Drush 3.0rc4 so updated to 3.3 and symptoms didn't change.

I tried deleting the google_analytics folder as suggested above and it did solve the problem... sortof...

Instead I had error come up with the forum_access module - Cannot redeclare forum_access_enable()

I can say for sure that this is not a duplicate of #781040 as none of these sites are managed under SVN Control.

I will test to see if I can reproduce consistently on a clean install using out of date versions of both of these two modules.

Update - just tested on a clean install with only google analytics installed - could not reproduce. I'll keep poking around, see if I can track down some further specifics about what is creating the problem.

hass’s picture

Category: support » bug
Priority: Minor » Critical

Marked #926024: Error updating via Drush as a duplicate. Hell - could not someone of the maintainers repro and FIX this issue, please?

jfine’s picture

Same issue, Drush 3.3. It does appear to be a Drush issue because a quick grep shows the function is only in the install file.

$ grep -ri googleanalytics_requirements httpdocs/
httpdocs/sites/all/modules/google_analytics/googleanalytics.install:function googleanalytics_requirements($phase) {

Drush must load up something prior to updating and somehow it stays in memory when the files are replaced.

If it helps I'm running it via FastCGI on Apache 2.2, PHP 5.2.4.

Cyberwolf’s picture

Same problem here.

jonhattan’s picture

Title: drush leaves behind old files during updatecode » drush updatecode should fork to a backend process to avoid problems
Assigned: Unassigned » jonhattan

Problem is that in the same process updatecode does a full bootstrap (loading .module of 2.2), then download 2.3 and then load .install of 2.3. To avoid this the upgrading should be invoked in a backend process.

moshe weitzman’s picture

oh damn, this sucks. the backend process is easy to implement but so many people forget to do --php and their systems are setup strangely. This is going to cause even more bug reports.

i do agree that backend is the way to go here.

greg.1.anderson’s picture

To solve #19, please review and commit #918468: drush.ini or php.ini? [Drush should use php.ini files in drush conf folders + some fixes for drush paths that contain spaces], which correctly handles --php for Linux and greatly reduces the need to run drush via an alias. Windows users will need a similar patch for drush.bat.

DamienMcKenna’s picture

bjcool’s picture

+

xjm’s picture

Tracking.

moshe weitzman’s picture

#18 is correct. patch welcome.

jonhattan’s picture

Status: Active » Needs review
FileSize
3.31 KB

It was easier than what I figured out at a first glance.

moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me. If you have tested this, then feel free to commit.

jonhattan’s picture

Status: Reviewed & tested by the community » Fixed

commited.

hass’s picture

When are you going to create a new release?

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.