Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Class \CRM_Mosaico_AbDemux not found - potential conflict with org.civicoop.areas ? #427

Closed
ufundo opened this issue Jan 11, 2021 · 25 comments

Comments

@ufundo
Copy link

ufundo commented Jan 11, 2021

Hi,

Upgrade from 2.5 to 2.6 caused this fatal error around the container / service loading for me on CiviCRM 5.28.3 , Drupal 7, PHP 7.3:

Class \CRM_Mosaico_AbDemux not found in CachedCiviContainer->getMosaicoAbDemuxService() (line 840 .../civicrm/templates_c/CachedCiviContainer.~~~~.php)

Tried clearing caches and manually emptying templates_c directory with no success. Works again downgrading to 2.5. Some compatibility issue?

@eileenmcnaughton
Copy link
Collaborator

@totten @seamuslee001 are we also clearing the services on extension upgrades in an ok order?

@ufundo if you manually delete the file above it should work? The services are cached in files like CachedCiviContainer

@ufundo
Copy link
Author

ufundo commented Jan 11, 2021

Hi @eileenmcnaughton thanks for help.

Was getting the same error even after deleting the CachedCiviContainer files ( and everything else in templates_c ). I think maybe it had crashed/corrupted the extension upgrade process.

I noticed this civicrm/civicrm-core#19141 and wondered if might be relevant. Have just found the extension upgrade seems to work OK if the site is upgraded to 5.33.1 before extension upgrade.

If the container-thing-I-don't-understand is required for smooth upgrade perhaps this new 2.6 Mosaico release should require 5.32 where it is merged into core?

@eileenmcnaughton
Copy link
Collaborator

@mattwire I think that makes sense to increment the supported version to reduce issues people hit / have to be supported - people on 5.28 can continue to use 2.5 until the next civi security release drops...

@mattwire
Copy link
Collaborator

@ufundo @eileenmcnaughton I've upgraded a number of 5.28.4 sites to 2.6 with no issues. That said, I had similar issues on a number of sites when flexmailer moved from extension to core extension and #19141 probably resolves those issues too. So I'd say not mosaico specific. I don't mind incrementing min-version but 2.6 is already released and published.

@magnolia61
Copy link

@ufundo I have the same issue as you do. Cant upgrade to 2.6 without the fatal error you describe

@ufundo
Copy link
Author

ufundo commented Jan 12, 2021

Sorry @magnolia61 (though I guess it's nice to know it's not just me ;)

Unfortunately I've found the apparently successful extension upgrade after upgrading to 5.33.1 was only on the surface. No longer crashes every page but is still throwing the error in other places (every time cron runs at least, not sure where else...)

@ufundo
Copy link
Author

ufundo commented Jan 15, 2021

Strangely it started crashing fatally on 5.33.1 in the same way it had on 5.28, so seemingly not resolved by #19141 .

FWIW no crashes after commenting

$listenerSpecs[] = ['civi.api.prepare', ['mosaico_ab_demux', 'wrapMailingApi'], Civi\API\Events::W_LATE];
- so issue with how the container is loaded in the context of that specific listener maybe?

Will try to dig a bit more into later today...

@eileenmcnaughton
Copy link
Collaborator

@totten any thoughts?

@ufundo
Copy link
Author

ufundo commented Jan 17, 2021

Did some digging. Seems to be a conflict with @jaapjansma 's https://lab.civicrm.org/extensions/areas .

Disabling areas extension resolves the crashing and have been able to reproduce the error on a fresh buildkit by just installing mosaico and areas (CiviCRM 5.35.alpha1 Drupal 7.78).

I'm afraid I couldn't see why the conflict though.

@magnolia61 - I wonder if this is the case for you also?

@eileenmcnaughton
Copy link
Collaborator

Good sleuthing!

@ufundo ufundo changed the title Class \CRM_Mosaico_AbDemux not found in CachedCiviContainer->getMosaicoAbDemuxService() ? Class \CRM_Mosaico_AbDemux not found - potential conflict with org.civicoop.areas ? Jan 17, 2021
@magnolia61
Copy link

Spot on. Disabling the Area extension did the trick. @jaapjansma would you have a clue on how this could be connected?

@jaapjansma
Copy link
Contributor

I don't know what causes this error.

@ufundo
Copy link
Author

ufundo commented Jan 21, 2021

Hmm, I can't see anything in code for either extension that looks like it would clash. Would it be appropriate to raise an issue on the Areas repo as well?

@jaapjansma
Copy link
Contributor

Yes that would appropriate to do so.

ps. I am the original developer of the area extension so a fix would be more than welcome.

@jaapjansma
Copy link
Contributor

It might be that those lines are causing the issue: https://lab.civicrm.org/extensions/areas/-/blob/master/areas.php#L144

@planetwebb
Copy link

Note that I also had this error upgrading to 2.6 and could not recover by disabling the areas extension via the database. 5.32.2-Drupal 7.78

@MegaphoneJon
Copy link
Contributor

MegaphoneJon commented Jan 28, 2021

I'm having this problem on Civi 5.33.2 (D8 latest) and I don't have the Areas extension installed. My backtrace follows.

Error: Class 'CRM_Mosaico_AbDemux' not found in CachedCiviContainer->getMosaicoAbDemuxService() (line 901 of 
/home/jon/local/mysite/web/sites/default/files/civicrm/templates_c/CachedCiviContainer.41d32a24ad98e4b7c3479d5edd3e739d.php) #0                         
/home/jon/local/mysite/vendor/symfony/dependency-injection/Container.php(306): CachedCiviContainer->getMosaicoAbDemuxService()                          
#1 /home/jon/local/mysite/vendor/civicrm/civicrm-core/Civi/Core/CiviEventDispatcher.php(86): Symfony\Component\DependencyInjection\Container->get('mosaico_ab_demu...')                            
#2 /home/jon/local/mysite/vendor/symfony/event-dispatcher/EventDispatcher.php(214): Civi\Core\CiviEventDispatcher->Civi\Core\{closure}(Object(Civi\API\Event\PrepareEvent), 'civi.api.prepar...',  
Object(Civi\Core\CiviEventDispatcher))                                      
#3 /home/jon/local/mysite/vendor/symfony/event-dispatcher/EventDispatcher.php(44): Symfony\Component\EventDispatcher\EventDispatcher->doDispatch(Array, 'civi.api.prepar...',                      
Object(Civi\API\Event\PrepareEvent))                                        
#4 /home/jon/local/mysite/vendor/civicrm/civicrm-core/Civi/Core/CiviEventDispatcher.php(129): Symfony\Component\EventDispatcher\EventDispatcher->dispatch('civi.api.prepar...',                    
Object(Civi\API\Event\PrepareEvent))                                        
#5 /home/jon/local/mysite/vendor/civicrm/civicrm-core/Civi/API/Kernel.php(238): Civi\Core\CiviEventDispatcher->dispatch('civi.api.prepar...', Object(Civi\API\Event\PrepareEvent))                 
#6 /home/jon/local/mysite/vendor/civicrm/civicrm-core/Civi/API/Kernel.php(149): Civi\API\Kernel->prepare(Object(Civi\API\Provider\MagicFunctionProvider), Array)                                   
#7 /home/jon/local/mysite/vendor/civicrm/civicrm-core/Civi/API/Kernel.php(81): Civi\API\Kernel->runRequest(Array)                                       
#8 /home/jon/local/mysite/vendor/civicrm/civicrm-core/api/api.php(131): Civi\API\Kernel->runSafe('CustomField', 'getfields', Array)                     
#9 /home/jon/local/mysite/vendor/civicrm/civicrm-core/api/api.php(171): civicrm_api3('CustomField', 'getfields', Array)                                 
#10 /home/jon/local/mysite/vendor/civicrm/civicrm-core/Civi/API/Subscriber/APIv3SchemaAdapter.php(47): _civicrm_api3_api_getfields(Array)               
#11 /home/jon/local/mysite/vendor/symfony/event-dispatcher/EventDispatcher.php(214): Civi\API\Subscriber\APIv3SchemaAdapter->onApiPrepare(Object(Civi\API\Event\PrepareEvent),                     
'civi.api.prepar...', Object(Civi\Core\CiviEventDispatcher))                
#12 /home/jon/local/mysite/vendor/symfony/event-dispatcher/EventDispatcher.php(44): Symfony\Component\EventDispatcher\EventDispatcher->doDispatch(Array, 'civi.api.prepar...',                     
Object(Civi\API\Event\PrepareEvent))                                        
#13 /home/jon/local/mysite/vendor/civicrm/civicrm-core/Civi/Core/CiviEventDispatcher.php(129): Symfony\Component\EventDispatcher\EventDispatcher->dispatch('civi.api.prepar...',                   
Object(Civi\API\Event\PrepareEvent))                                        
#14 /home/jon/local/mysite/vendor/civicrm/civicrm-core/Civi/API/Kernel.php(238): Civi\Core\CiviEventDispatcher->dispatch('civi.api.prepar...', Object(Civi\API\Event\PrepareEvent))                
#15 /home/jon/local/mysite/vendor/civicrm/civicrm-core/Civi/API/Kernel.php(149): Civi\API\Kernel->prepare(Object(Civi\API\Provider\MagicFunctionProvider), Array)                                  
#16 /home/jon/local/mysite/vendor/civicrm/civicrm-core/Civi/API/Kernel.php(81): Civi\API\Kernel->runRequest(Array)                                      
#17 /home/jon/local/mysite/vendor/civicrm/civicrm-core/api/api.php(131): Civi\API\Kernel->runSafe('CustomField', 'get', Array)                          
#18 /home/jon/local/mysite/web/sites/all/civicrm/extensions/com.jlacey.salutations/salutations.php(320): civicrm_api3('CustomField', 'get', Array)      
#19 /home/jon/local/mysite/vendor/civicrm/civicrm-core/CRM/Utils/Hook.php(283): salutations_civicrm_fieldOptions('Contact', 'preferred_langu...', Array, Array)                                    
#20 /home/jon/local/mysite/vendor/civicrm/civicrm-core/CRM/Utils/Hook/DrupalBase.php(73): CRM_Utils_Hook->runHooks(Array, 'civicrm_fieldOp...', 4, 'Contact', 'preferred_langu...', Array, Array,  
NULL, NULL)     
#21 /home/jon/local/mysite/vendor/civicrm/civicrm-core/Civi/Core/CiviEventDispatcher.php(180): CRM_Utils_Hook_DrupalBase->invokeViaUF(4, 'Contact', 'preferred_langu...', Array, Array, NULL,      
NULL, 'civicrm_fieldOp...')      
#22 /home/jon/local/mysite/vendor/symfony/event-dispatcher/EventDispatcher.php(214): Civi\Core\CiviEventDispatcher::delegateToUF(Object(Civi\Core\Event\GenericHookEvent), 'hook_civicrm_fi...',   
Object(Civi\Core\CiviEventDispatcher))                                      
#23 /home/jon/local/mysite/vendor/symfony/event-dispatcher/EventDispatcher.php(44): Symfony\Component\EventDispatcher\EventDispatcher->doDispatch(Array, 'hook_civicrm_fi...',                     
Object(Civi\Core\Event\GenericHookEvent))                                   
#24 /home/jon/local/mysite/vendor/civicrm/civicrm-core/Civi/Core/CiviEventDispatcher.php(129): Symfony\Component\EventDispatcher\EventDispatcher->dispatch('hook_civicrm_fi...',                   
Object(Civi\Core\Event\GenericHookEvent))                                   
#25 /home/jon/local/mysite/vendor/civicrm/civicrm-core/CRM/Utils/Hook.php(167): Civi\Core\CiviEventDispatcher->dispatch('hook_civicrm_fi...', Object(Civi\Core\Event\GenericHookEvent))            
#26 /home/jon/local/mysite/vendor/civicrm/civicrm-core/CRM/Utils/Hook.php(1002): CRM_Utils_Hook->invoke(Array, 'Contact', 'preferred_langu...', Array, Array, NULL, NULL, 'civicrm_fieldOp...')    
#27 /home/jon/local/mysite/vendor/civicrm/civicrm-core/CRM/Core/PseudoConstant.php(261): CRM_Utils_Hook::fieldOptions('Contact', 'preferred_langu...', Array, Array)                               
#28 /home/jon/local/mysite/vendor/civicrm/civicrm-core/CRM/Contact/BAO/Contact.php(3454): CRM_Core_PseudoConstant::get('CRM_Contact_BAO...', 'preferred_langu...', Array, NULL)                    
#29 /home/jon/local/mysite/vendor/civicrm/civicrm-core/CRM/Core/I18n.php(187): CRM_Contact_BAO_Contact::buildOptions('preferred_langu...')              
#30 /home/jon/local/mysite/vendor/civicrm/civicrm-core/CRM/Core/I18n.php(258): CRM_Core_I18n::languages()    
#31 /home/jon/local/mysite/vendor/civicrm/civicrm-core/CRM/Core/Smarty.php(143): CRM_Core_I18n::uiLanguages()
#32 /home/jon/local/mysite/vendor/civicrm/civicrm-core/CRM/Core/Smarty.php(161): CRM_Core_Smarty->initialize()                                          
#33 /home/jon/local/mysite/web/sites/all/civicrm/extensions/biz.jmaconsulting.lineitemedit/lineitemedit.civix.php(94): CRM_Core_Smarty::singleton()     
#34 /home/jon/local/mysite/web/sites/all/civicrm/extensions/biz.jmaconsulting.lineitemedit/lineitemedit.php(11): _lineitemedit_civix_civicrm_config(Object(CRM_Core_Config))                       
#35 /home/jon/local/mysite/vendor/civicrm/civicrm-core/CRM/Utils/Hook.php(271): lineitemedit_civicrm_config(Object(CRM_Core_Config))                    
#36 /home/jon/local/mysite/vendor/civicrm/civicrm-core/CRM/Utils/Hook/DrupalBase.php(73): CRM_Utils_Hook->runHooks(Array, 'civicrm_config', 1, Object(CRM_Core_Config), NULL, NULL, NULL, NULL,    
NULL)           
#37 /home/jon/local/mysite/vendor/civicrm/civicrm-core/Civi/Core/CiviEventDispatcher.php(168): CRM_Utils_Hook_DrupalBase->invokeViaUF(1, Object(CRM_Core_Config), NULL, NULL, NULL, NULL, NULL,    
'civicrm_config')                
#38 /home/jon/local/mysite/vendor/symfony/event-dispatcher/EventDispatcher.php(214): Civi\Core\CiviEventDispatcher::delegateToUF(Object(Civi\Core\Event\GenericHookEvent), 'hook_civicrm_co...',   
Object(Civi\Core\CiviEventDispatcher))                                      
#39 /home/jon/local/mysite/vendor/symfony/event-dispatcher/EventDispatcher.php(44): Symfony\Component\EventDispatcher\EventDispatcher->doDispatch(Array, 'hook_civicrm_co...',                     
Object(Civi\Core\Event\GenericHookEvent))                                   
#40 /home/jon/local/mysite/vendor/civicrm/civicrm-core/Civi/Core/CiviEventDispatcher.php(129): Symfony\Component\EventDispatcher\EventDispatcher->dispatch('hook_civicrm_co...',                   
Object(Civi\Core\Event\GenericHookEvent))                                   
#41 /home/jon/local/mysite/vendor/civicrm/civicrm-core/CRM/Utils/Hook.php(167): Civi\Core\CiviEventDispatcher->dispatch('hook_civicrm_co...', Object(Civi\Core\Event\GenericHookEvent))            
#42 /home/jon/local/mysite/vendor/civicrm/civicrm-core/CRM/Utils/Hook.php(1352): CRM_Utils_Hook->invoke(Array, Object(CRM_Core_Config), NULL, NULL, NULL, NULL, NULL, 'civicrm_config')            
#43 /home/jon/local/mysite/vendor/civicrm/civicrm-core/CRM/Core/Config.php(104): CRM_Utils_Hook::config(Object(CRM_Core_Config))                        
#44 /home/jon/local/mysite/web/modules/contrib/civicrm/src/Civicrm.php(61): CRM_Core_Config::singleton()     
#45 /home/jon/local/mysite/web/modules/contrib/civicrm/src/PathProcessor/CivicrmPathProcessor.php(22): Drupal\civicrm\Civicrm->initialize()             
#46 /home/jon/local/mysite/web/core/lib/Drupal/Core/PathProcessor/PathProcessorManager.php(70): Drupal\civicrm\PathProcessor\CivicrmPathProcessor->processInbound('/civicrm/',                     
Object(Symfony\Component\HttpFoundation\Request))                           
#47 /home/jon/local/mysite/web/modules/contrib/redirect/src/EventSubscriber/RedirectRequestSubscriber.php(138): Drupal\Core\PathProcessor\PathProcessorManager->processInbound('/civicrm/',        
Object(Symfony\Component\HttpFoundation\Request))                           
#48 [internal function]: Drupal\redirect\EventSubscriber\RedirectRequestSubscriber->onKernelRequestCheckRedirect(Object(Symfony\Component\HttpKernel\Event\GetResponseEvent), 'kernel.request',    
Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))     
#49 /home/jon/local/mysite/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php(111): call_user_func(Array,                  
Object(Symfony\Component\HttpKernel\Event\GetResponseEvent), 'kernel.request', Object(Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher))  
#50 /home/jon/local/mysite/vendor/symfony/http-kernel/HttpKernel.php(127): Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.request',                              
Object(Symfony\Component\HttpKernel\Event\GetResponseEvent))                
#51 /home/jon/local/mysite/vendor/symfony/http-kernel/HttpKernel.php(68): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)                  
#52 /home/jon/local/mysite/web/core/lib/Drupal/Core/StackMiddleware/Session.php(57): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)    
#53 /home/jon/local/mysite/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(47): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1,      
true)           
#54 /home/jon/local/mysite/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106):               
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)                                          
#55 /home/jon/local/mysite/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request),  
1, true)        
#56 /home/jon/local/mysite/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(47):          
Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)                                          
#57 /home/jon/local/mysite/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(52):           
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)                                   
#58 /home/jon/local/mysite/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request),   
1, true)        
#59 /home/jon/local/mysite/web/core/lib/Drupal/Core/DrupalKernel.php(708): Stack\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)                              
#60 /home/jon/local/mysite/web/index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))                        
#61 {main}. 

@MegaphoneJon
Copy link
Contributor

MegaphoneJon commented Jan 28, 2021

I couldn't replicate this on my dmaster with Mosaico and Areas (though I haven't updated my dev site so it's still on 5.34, not 5.35). However, I notice that what Areas and Salutations have in common is they both make an API3 call inside the hook_civicrm_fieldOptions hook. Removing that call fixes this problem.

I don't know Symfony very well, but I think I've got several pieces of this puzzle:

  • This is ultimately the autoloader's failure. It's not finding CRM/Mosaico/AbDemux.php.
  • Looking at my CachedCiviContainer.abc.php, Mosaico is the only extension that registers a service that references a class that is a) not in core, b) not PSR-4 compliant. This seems relevant because the Civi autoloader uses stream_resolve_include_path() to find files. I suspect that PSR-4 compliant namespaces are resolved sooner in the autoloader process, and the path for CRM_* namespaces is set in hook_civicrm_config.
  • It looks like hook_civicrm_fieldOptions is called early enough in the page load process that the Civi autoloader isn't yet aware of non-core CRM_* files.

This seems like something @totten is the expert on. This is starting to feel like an issue in core rather than the extensions.

@pbatroff
Copy link
Contributor

pbatroff commented Feb 8, 2021

I have the same Problem on a civicrm 5.28.3, when updating mosaico extension. CiviCRM throws this error on all sites then. I do not have areas installed in that env. I also cannot find Extensions that are utilizing hook_civicrm_fieldOptions from what I can see.

This is reproducible, tested on 2 sites with above specs.

@homotechsual
Copy link
Contributor

homotechsual commented Feb 9, 2021

We're also seeing this on a single CiviCRM site with Areas and Mosaico that was just upgraded to Drupal 9.

@MegaphoneJon
Copy link
Contributor

I have a one-line patch that very likely solves this problem. I would wait for Jenkins to run a pass on it, but after that it'd be great to hear from others (on the PR!) whether the patch fixes this bug.

@alifrumin
Copy link

@MegaphoneJon patch worked for me!

@jaapjansma
Copy link
Contributor

jaapjansma commented Apr 23, 2021

I have this same error on a wordpress civicrm site without areas extension.
The error appears when trying to see the contacts in a smart group (through Contact --> Manage Groups)

The patch from @MegaphoneJon did not work for me.

jaapjansma added a commit to jaapjansma/uk.co.vedaconsulting.mosaico that referenced this issue Apr 23, 2021
@jaapjansma
Copy link
Contributor

I have found the issue and proposed a fix: #446

The issue is that the civi.api.prepare event is sometimes called before civicrm is fully loaded and at that time the CRM_Mosaico_AbMux class could not be found. Moving the event listener to mosaico.php solves the problem for me.

mattwire added a commit that referenced this issue May 24, 2021
@mattwire
Copy link
Collaborator

This was fixed in an earlier 2.x release via #446

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants