I'm using the latest Aegir and Drush 4.5. I can clone (copy) site in Aegir just fine, but a new site using entityreference is having this problem ...
Drush command terminated abnormally due to an unrecoverable error. Error: Cannot redeclare class EntityReference_BehaviorHandler_Broken in /var/aegir/platforms/.../sites/example.com/modules/entityreference/plugins/behavior/abstract.inc, line 187
Somehow, Drupal is trying to redeclare this class. Not sure why. I even tried a registry rebuild, no luck.
Comments
Comment #1
MatthewHager commentedI'm having this same issue. Can't figure out a workaround.
Comment #2
chrisschaub commentedBefore cloning ...
drush sql-cli
mysql> update system set status=0 where name = 'entityreference' and type='module';
now do the clone
then login to both sites using
drush sql-cli
mysql> update system set status=1 where name = 'entityreference' and type='module';
now you can
drush rr (rebuild registry)
drush cc all (clear cache)
do these last two steps on both sites after resetting module to active. Yes, a gross hack, but the only way I've found to get past the issue. It's a design flaw of Aegir + Drupal 7 + Drush. Drupal 7's registry needs to be rebuilt by Aegir after the file copy and database import are done, but before the verify of the clone.
Comment #3
chrisschaub commentedThis ticket exists as well ...
http://drupal.org/node/1478688
I'm not sure if entityrefernce has some specific issue with the registry that could be alleviated by the module itself. Maybe it's storing paths to plugins or something, haven't looked.
Comment #4
Jackinloadup commentedThanks cschaub your workaround in #2 was a success!
Comment #5
omega8cc commentedIt may be some issue in the module itself, but it is not really a design flaw in Aegir or Drush. It is a bad practice to use site specific space for your code, or you are following well known recipe for disaster.
Comment #6
chrisschaub commentedAegir should rebuild any paths when it is moving stuff around. Since it's perfectly acceptable (and suggested) practice to put code in this area with regular Drupal development, it should be fine for Aegir as well. It's a design flaw if Aegir can't work with standard Drupal best practices. The point of an install profile is to get a site basically configured. If you want customize or extend the site after that, the code should go in the sites area or sites/all (which is not good in a multi-site environment). And really, this is just a simple fix to have Aegir call registry rebuild right after clone or migrate, before verify. Aegir already does something similar by rebuilding settings info for paths, registry rebuild is just one that got missed. It's a bug in my opinion.
Comment #7
omega8cc commentedIt looks like we have already hijacked this thread, as it is not really module (entityreference) specific, so i would propose to move this issue to the Provision queue.
There are two, only partially related issues here: how Aegir handles the site specific code and why, and the real reason behind "Cannot redeclare class" error.
Again, it is not really a bug in Aegir nor design flaw (call it a missing feature, if you wish - however I would call it a missing workaround), since these modules simply can't be reliably tracked/compared by Aegir and thus will be reported as missing on platform comparison, because they don't and will not exist on the target platform, until the site archive will be extracted in the new place. It was discussed and explained many times in the Aegir project queue. While modules in the site space can't be really supported (for reasons just explained), adding registry rebuild is already in the features queue (and is already added in BOA, btw).
The "Cannot redeclare class" is a result of having the same code in more than one places (in PHP memory, not on the disk, so registry rebuild can't really help). It is php-cli what still remembers already declared class, not Aegir database. Since the module doesn't really exist in two places (unless you have it also in sites/all/modules), the "Cannot redeclare class" error can't be caused by Aegir itself and there is nothing registry rebuild could do on this level. I think it is rather something to fix on the php.ini level. I guess it is
realpath_cache_ttlwhat should be lowered in the php-cli ini file to avoid this. It is a pure guessing, but it would be interesting to try to reproduce the problem with something likerealpath_cache_ttl=5.Comment #8
omega8cc commentedOr maybe you have APC enabled for php-cli? What is the result of
php -i | grep apccommand?Comment #9
PI_Ron commentedI couldn't get the workaround in #2 to work with my omeg8.cc hosted site, but succeeded with following method:
• Created a new platform including entity_reference and removed from site.com/modules folder
• created a vanilla site on new platform
• copied files/ etc. over to new site
• exported database of old site via chive
• imported to new site via chive (backup_migrate backup/restore failed)
• newsite> drush rr
Hope this helps
By the way, this site was using entity_reference-1.0-rc3
Comment #10
_vid commentedI'm having a similar problem; though my error message was slightly different. The clone or migrate failed when the new site couldn't bootstrap due to a missing 'site'/modules/entity/includes/entity.inc file.
Interestingly the address of the old site modules dir. was used inside the new platform.
Like so: 'NEW_PLATFORM/sites/OLD_SITE/modules/entity/includes/entity.inc'
I tried the fix in #2 but it wasn't sufficient. Perhaps because I have modules requiring entityreference? So took it step further.
$ drush dis entity$ sudo rm -R modules/entity*$ drush updb; drush cc all; drush cron -v$ drush updb; drush cc all; drush cron -vThat worked for me. I'm not proud of it... but it worked.
Comment #11
omega8cc commentedThis patch helped us in many issues related to this module: http://drupal.org/node/1459540#comment-6810146
Comment #12
_vid commentedI tried the patch from: http://drupal.org/node/1459540#comment-6810146 but we are still seeing the same error on another site for my specify variation of the issue;
when I clone (or migrate)
site.domain.com on prod-drupal-7.17
to
site.dev-server.domain.com on dev-drupal-7.17
bootstrap's function _registry_check_code() is looking for the new site's copy of the includes/entity.inc with the old path.
require_once(/var/aegir/platforms/dev-drupal-7.17/sites/site.domain.com/modules/entity/includes/entity.inc): failed to open stream: No such file or directory bootstrap.inc:3084The solution was cschaub's #2 above: http://drupal.org/node/1680000#comment-6272174
I also have entity and entityreference in my site's module folder.
@omega8cc in looking at your comments in #7 above, I wonder;
Could I avoid this issue by moving entity and entityreference into the platform?
I was reluctant to do that in my production platform for just 1 or 2 sites, while both entity and entityreference were in -dev, but now that we have full releases for each module, it maybe worth a try; although, Entity Reference View Widget is still in alpha... if it can live it in
I realize I continue to hijack this issue but my error does appear to share the same solution and entityreference is the only module that I've encountered this problem with, so if creating a new issue is recommended, I can do that. Whether I would post it here or in the provision queue is to be determined.
A little more info on my issue:
We have confirmed that if you clone or migrate (with a new name) on the same platform there is no issue, as the path to the old entity.inc is still accessible to the new site.
Additionally, migrating to a new platform while keeping the exact same name does work.
Which presents an interesting GUI-only workaround:
No
drush sql-cliordrush rrrequired.Comment #13
omega8cc commented@ _vid That is why BOA includes registry-rebuild as a part of every verify task, which helps when you are using sites specific space sites/foo/modules instead of platform specific sites/all/modules. Still, using site specific space may cause this kind of problems sometimes, so we don't recommend it. Also, renaming the site during migration between platforms is another recipe for disaster. I would recommend to study recipe #5 at: http://omega8.cc/the-best-recipes-for-disaster-139#fail-e and also discussions linked there. Our modified Aegir version installed by BOA includes extended inline help which helps to understand this better and avoid issues.
Comment #14
_vid commented@omega8cc; Thanks for your response. BOA has some nice features.
We confirmed that moving entity and entity reference into the platform level avoided this problem.
For anyone else who's curious our steps were:
$ cd sites/all/modules;$ drush dl entity entityreference$ cd sites/SITENAME;$ cd modules;$ sudo rm -R entity entityreference;$ drush rr;On a side note, we encountered one of the issues that comes with using registry rebuild: the feeds module needs to list its plugins in the info file or the site wont verify after registry rebuild. So we patched that and everything else was good. Interestingly there was commit fixing that in feeds years ago: http://drupal.org/node/1201638.
Comment #15
omega8cc commented@_vid Good catch with broken again Feeds module. It already hit us a few times and I'm surprised that this patch is no longer there, so I have re-opened #1201638: Plugins should be listed in info file.
Comment #16
nwom commentedThe patch in #1423778: Fatal error loading EntityReference_SelectionHandler_Broken should fix this issue. I had the same issue when importing an Aegir site backup into a new site.