It is noted that modules implementing ServiceProviderBase to alter defined services can 'lose' to other modules overriding the same service as there is no way to know which one should overtake in that situation.

Is this 'fixable' by making your modules weight higher than the others?

  • I haven't needed this but I would guess that altering the weights in core.extension config might do the trick but it might not since this is a symfony thing and I do not know if order of module is being considered in this case. – Ivan Jaros Jul 9 '17 at 20:20
  • If you create a module that overrides a service - its best to do it this way and not in the services yml as that can lead to errors in deployment – Kevin Jul 10 '17 at 12:30
up vote 4 down vote accepted

Yes, the serviceProviderClasses are discovered in DrupalKernel::discoverServiceProviders(), I've stopped the code there and the list was sorted by module weight and modules with the same weight alphabetically.

Your Answer


By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.