Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Solution
tl;drcomposer update "drupal/libraries"
Original reportt
When updating from 8.3.7 to 8.4.0, I recieve the following error:
Constructing service "validation.constraint" from a parent definition
is not supported at build time. in
/srv/bindings/***/code/vendor/symfony/dependency-injection/ContainerBuilder.php:847
Stack trace:
#0
/srv/bindings/***/code/vendor/symfony/dependency-injection/ContainerBuilder.php(451):
Symfony\Component\DependencyInjection\ContainerBuilder->createService(Object(Symfony\Component\DependencyInjection\DefinitionDecorator),
'validation.cons...')
#1
/srv/bindings/***/code/vendor/symfony/dependency-injection/ContainerBuilder.php(957):
Symfony\Component\DependencyInjection\ContainerBuilder->get('validation.cons...',
1)
#2
/srv/bindings/***/code/vendor/symfony/dependency-injection/ContainerBuilder.php(954):
Symfony\Component\DependencyInjection\ContainerBuilder->resolveServices(Object(Symfony\Component\DependencyInjection\Reference))
#3
/srv/bindings/***/code/vendor/symfony/dependency-injection/ContainerBuilder.php(1145):
Symfony\Component\DependencyInjection\ContainerBuilder->resolveServices(Array)
#4
/srv/bindings/***/code/vendor/symfony/dependency-injection/ContainerBuilder.php(918):
Symfony\Component\DependencyInjection\ContainerBuilder->callMethod(Object(Drupal\Core\Config\TypedConfigManager),
Array)
#5
/srv/bindings/***/code/vendor/symfony/dependency-injection/ContainerBuilder.php(451):
Symfony\Component\DependencyInjection\ContainerBuilder->createService(Object(Symfony\Component\DependencyInjection\Definition),
'config.typed')
#6
/srv/bindings/***/code/vendor/symfony/dependency-injection/ContainerBuilder.php(957):
Symfony\Component\DependencyInjection\ContainerBuilder->get('config.typed',
1)
#7
/srv/bindings/***/code/vendor/symfony/dependency-injection/ContainerBuilder.php(954):
Symfony\Component\DependencyInjection\ContainerBuilder->resolveServices(Object(Symfony\Component\DependencyInjection\Reference))
#8
/srv/bindings/***/code/vendor/symfony/dependency-injection/ContainerBuilder.php(879):
Symfony\Component\DependencyInjection\ContainerBuilder->resolveServices(Array)
#9
/srv/bindings/***/code/vendor/symfony/dependency-injection/ContainerBuilder.php(451):
Symfony\Component\DependencyInjection\ContainerBuilder->createService(Object(Symfony\Component\DependencyInjection\Definition),
'config.factory')
#10
/srv/bindings/***/code/modules/libraries/src/LibrariesServiceProvider.php(29):
Symfony\Component\DependencyInjection\ContainerBuilder->get('config.factory')
#11
/srv/bindings/***/code/core/lib/Drupal/Core/DependencyInjection/Compiler/ModifyServiceDefinitionsPass.php(30):
Drupal\libraries\LibrariesServiceProvider->alter(Object(Drupal\Core\DependencyInjection\ContainerBuilder))
#12
/srv/bindings/***/code/vendor/symfony/dependency-injection/Compiler/Compiler.php(120):
Drupal\Core\DependencyInjection\Compiler\ModifyServiceDefinitionsPass->process(Object(Drupal\Core\DependencyInjection\ContainerBuilder))
#13
/srv/bindings/***/code/vendor/symfony/dependency-injection/ContainerBuilder.php(573):
Symfony\Component\DependencyInjection\Compiler\Compiler->compile(Object(Drupal\Core\DependencyInjection\ContainerBuilder))
#14
/srv/bindings/***/code/core/lib/Drupal/Core/DrupalKernel.php(1307):
Symfony\Component\DependencyInjection\ContainerBuilder->compile()
#15
/srv/bindings/***/code/core/lib/Drupal/Core/DrupalKernel.php(884):
Drupal\Core\DrupalKernel->compileContainer()
#16
/srv/bindings/***/code/core/lib/Drupal/Core/DrupalKernel.php(466):
Drupal\Core\DrupalKernel->initializeContainer()
#17
/srv/bindings/***/code/core/lib/Drupal/Core/DrupalKernel.php(709):
Drupal\Core\DrupalKernel->boot()
#18
/srv/bindings/***/code/core/includes/utility.inc(43):
Drupal\Core\DrupalKernel->prepareLegacyRequest(Object(Symfony\Component\HttpFoundation\Request))
#19 /opt/pantheon/drush8/commands/core/cache.drush.inc(302):
drupal_rebuild(Object(Composer\Autoload\ClassLoader),
Object(Symfony\Component\HttpFoundation\Request))
#20 /opt/pantheon/drush8/includes/command.inc(422):
drush_cache_rebuild()
#21 /opt/pantheon/drush8/includes/command.inc(231):
_drush_invoke_hooks(Array, Array)
#22 /opt/pantheon/drush8/includes/command.inc(199): drush_command()
#23 /opt/pantheon/drush8/lib/Drush/Boot/BaseBoot.php(67):
drush_dispatch(Array)
#24 /opt/pantheon/drush8/includes/preflight.inc(66):
Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#25 /opt/pantheon/drush8/drush.php(12): drush_main()
#26 {main} [0.38 sec, 15.68 MB]
Someone posted something similar on StackExchange. I posted my input here.
When I downloaded the Drupal 8.4.0 zip from the Drupal Github mirror repo, unzipped, then grepped through the code, I found this:
$ grep -rF 'validation.constrain'
drupal-8.4.0/core/core.services.yml: - [setValidationConstraintManager, ['@validation.constraint']]
drupal-8.4.0/core/core.services.yml: - [setValidationConstraintManager, ['@validation.constraint']]
drupal-8.4.0/core/core.services.yml: validation.constraint:
drupal-8.4.0/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/ComplexDataConstraint.php: $constraint_manager = \Drupal::service('validation.constraint');
Is it possible that Symfony deprecated this validation.constraint
configuration key, and yet Drupal forgot to make the necessary change in their 8.4.0 code?
Comment | File | Size | Author |
---|---|---|---|
#18 | 2915332-18.patch | 9.06 KB | dawehner |
Comments
Comment #2
xeM8VfDh CreditAttribution: xeM8VfDh commentedComment #3
cilefen CreditAttribution: cilefen as a volunteer commentedComment #4
xeM8VfDh CreditAttribution: xeM8VfDh commentedEnvironment
my site is running on Pantheon with PHP 7.0.
Background
I initiated the site update via Pantheon's interface, which I believe is running Drush on the back end to handle this operation. Sorry I don't have more detailed steps to produce the problem, but the StackExchange links i posted does report the problem resulting from
drush updb
. But, that's not realy an important detail to focus on. Once I ran into this issue after trying to update, any/all drush commands (including cache clearing) result in the same error. The problem is that the application is unable to bootstrap itself and spin up, thus it cannot fullfill any requests (web, Drush, or otherwise). As far as I can tell, the system is failing to spin up because it is choking on the core Drupal configuration incore/core.services.yml
that I referenced at the end of my issue.When the Kernel is booting, it is instantiating the
config.typed
configuration, which in turn calls thevalidation.constraint
which is configured with aparent
attribute, making it a configuration instance ofDefinitionDecorator
instead ofDefinition
. ThecreateService()
method onContainerBuilder
is choking right off the bat with:As the message suggests: Constructing a service from a parent definition is not supported at build time.
The problem was introduced in this commit when
@validation.constraint
became a dependency ofconfig.typed
via thecalls
attribute added in the commit:Workaround
Edit
core/core.services.yml
and comment out thecalls
attribute for theconfig.typed
block as follows:Now go to
[your_url]/update.php
in a browser. There will be pending database updates that need to run. That's it.WARNING
I have no idea what the repercussions of the configuration change above are. I don't suggest anyone do this in production. It's just a demonstration of what is causing the problem and how to hack around it. As far as I can tell, this is a Drupal bug stemming from an improper usage of the new Symfony configuration standard. I have no idea why/how this wasn't caught in QA before 8.4.0 was released, but I am guessing it is because only a certain set of circumstances cause the bootstrap process to instantiate
config.typed
, otherwise everyone who updated to 8.4.0 would be experiencing this problem, and no QA would have passed because all 8.4.0 instances would be choking in this way. I will look into what circumstances in my environment triggerconfig.typed
and report back if I find anything.Comment #5
xeM8VfDh CreditAttribution: xeM8VfDh commentedComment #6
xeM8VfDh CreditAttribution: xeM8VfDh commentedMy testing indicated that my boot strapping process is instantiating configured serviced in this order:
config.factory
config.typed
validation.constraint
Some further inspection of the stack trace suggests that
config.factory
is being instantiated incode/modules/libraries/src/LibrariesServiceProvider.php
. That's coming from the Libraries module. There is a working but not "official" Drupal 8 release. I have it installed because I am using Juicebox module, which requires it.I've tested putting the original
core/core.services.yml
file back in place, disabling Juicebox, disabling Libraries, then executing a drush cache clear, and the problem no longer occurs. So, this update problem doesn't affect all systems but does affect those with Libraries module installed.The question now is, is this really the fault of Libraries module, or is there still an inherent problem with the new
config.typed
configurations use ofvalidation.constraint
in its newcalls
attribute?How to Reproduce This Error
If you are on a version below 3.4.0:
If you are already on version 3.4.0:
Comment #7
mhavelant CreditAttribution: mhavelant at Brainsum for Tieto commentedI get the same error. I have a site with core 8.3.7, and wanted to update it to 8.4.0.
The error was there when I first used drush updb on 8.4, and didn't go away after upgrading to drush 9 (as the answer from stackexchange suggested).
Comment #8
emdahlstrom CreditAttribution: emdahlstrom commentedDisabling libraries api worked for me too, many thanks!
Comment #9
xeM8VfDh CreditAttribution: xeM8VfDh commentedAs it turns out, in my case, this might only have been a problem with Libraries release 8.x-3.x-dev (2016-Nov-13) that I was running, not the current 8.x-3.x-dev release. Digging more into it now.
Comment #10
xjm@mhavelant, what happens if you run update.php through the user interface?
Comment #11
xeM8VfDh CreditAttribution: xeM8VfDh commentedMy Solution
8.x-3.x-dev (2016-Nov-13)
to latest8.x-3.x-dev
update.php
for good measure8.4.0
Still not sure though whether Drupal core devs intentionally wanted to make
config.typed
inaccessible at build time. If the answer is yes, feel free to close this.@mhavelant , if you post your stack trace, we can probably identify the module that is causing this in your case.
Comment #12
fgmFWIW, I encounter the same (apparently rare) error in a different context in code I'm writing, when trying to obtain the config.factory in a CompilerPass.
Comment #13
larowlanUpdating libraries API was the fix for me too
I think we can mark that in the OP and call this resolved?
Comment #14
mhavelant CreditAttribution: mhavelant at Brainsum for Tieto commentedI tried to update another 8.3.7 site with the same error message.
@xjm Update.php throws the same exception.
@xeM8VfDh The stack trace:
This site doesn't have 'Libraries' either, but it's based off the minimal profile unlike the other one. The other major points are the same (drupal-composer project, php7, trying to update from 8.3.7).
Comment #15
fgmDug a bit further on this: it happens because the config.factory needs to receive the config.typed, which is where this attempt at adding a validation.constraint takes place.
Comment #16
dawehnerOne way around that could be to make
validation.constraint
a lazy service. Config validation should not be triggered on container build time.Comment #17
Alan D. CreditAttribution: Alan D. commentedAlso hit this with both a composer update and separately with a manual update last week. The cause was the libraries module, and placing the latest dev version post-update didn't help.
I didn't try updating the libraries module before doing core update that comment #11 suggested as a workaround, the module wasn't used so I just nuked it.
So Libraries & Cors UI (comment #14) problematic.
Comment #18
dawehnerDoes this solve the problem?
Comment #19
fgmI'm a bit skeptical on this patch, even if it solves the problem: since most - if not all - pages use the config factory, it seems this solution only adds a bit more work on all pages, does it not ?
Comment #20
dawehner@fgm
The config validation is just used during saving, so I think its fine?
Comment #21
fgm@dawehner : it may well be that I misunderstand what's going on, but AIUI with this patch, the new proxy class is used any time a reference to the config factory is done, to defer instantiation until a method is actually used on the service, at which point the lazyLoadItself() calls the original (now proxied) service, meaning all (most) pages now incur one more autoload and function call, meaning a tiny bit of performance lost.
Admittedly, it is not used on pages served by the internal page cache, where it would be more significant, so maybe it is not really an issue.
Comment #22
dawehnerIts not only that, it is also not used on uncached requests as well. These methods should just be used on POST requests technically.
Comment #23
xeM8VfDh CreditAttribution: xeM8VfDh commented@mhavelant, as @Alan D. mentioned, your specific problem stemming from the CORS UI (cors_ui) module you have installed. See #10 from your stack trace:
That module is calling the
config.factory
configuration, which is eventually callingconfig.typed
, which is the source of this problem.If you disable that module and then try updating, it might work. If you need that module, you first want to check to make sure you are on the most current version of that module. If you are, then you will want to open an issue on the module letting them know that their code is not compatible with Drupal core 8.4.0. You can reference this issue as well as others I have referenced above.
Comment #24
dawehnerIt would be super nice to have someone trying out the patch on a real site.
Comment #25
mhavelant CreditAttribution: mhavelant at Brainsum for Tieto commented@xeM8VfDh Disabling the cors_ui module was the key for me, I could now update 8.3.7 to 8.4, thanks!
Comment #26
ivavictoriaRan into this same error; the cors_ui module is the culprit for me as well.
I gave @dawehner's patch a try, and it looks like it works. If I update to 8.4 and apply the patch, I'm able to run `drush updb` and carry on like normal.
Since I don't know the full implications of using the patch, I'm going to stick with disabling the cors_ui module for now.
I'll be keep my eye on this thread for further developments.
Comment #27
darrenwh CreditAttribution: darrenwh as a volunteer and commentedI've recently update a site to 8.4.4 and got the above error, I applied the patch and an error issue still exists:
Comment #28
xeM8VfDh CreditAttribution: xeM8VfDh commented@darrenwh, is there any more to the error? If not, is there a specific reason you think your issue relates to this issue/patch? Your error seem more related to these other issues:
https://www.drupal.org/project/drupal/issues/2890294
https://www.drupal.org/project/drupal/issues/2874827
Comment #29
darrenwh CreditAttribution: darrenwh as a volunteer and commentedHaving read this https://drupal.stackexchange.com/questions/247703/what-is-the-cause-for-...
I update libraries to latest version that seems to have resolved the issue
composer require 'drupal/libraries:^3.0'
Comment #35
borisson_I think this is no longer relevant and we can close this, because of #29?
Comment #36
cilefen CreditAttribution: cilefen as a volunteer commented