Upgrade Your Drupal Skills

We trained 1,000+ Drupal Developers over the last decade.

See Advanced Courses NAH, I know Enough

Acquia Doctrine dependencies

Parent Feed: 

We started receiving reports of broken Lightning builds due to the release of doctrine/common:2.8.0 and/or doctrine/inflector:1.2.0 which require php ~7.1 and php ^7.0 respectively.

Lightning actually doesn't have a direct dependency on anything under the doctrine namespace. The dependencies come from drupal/core. So should drupal/core constrain doctrine/common to <=2.7.3 so that it continues to support php 5.6? No.

If you follow the dependency tree for what happens when you run composer update for a Lightning project in a php 5.6 environment, it looks like this:

  • acquia/lightning:2.1.7 requires:
  • drupal/core:~8.3.1, drupal/core:8.3.5 requires:
  • doctrine/common:^2.5, doctrine/common:2.8.0 requires php ~7.1, so it will resolve to 2.7.3, which requires:
  • doctrine/inflector:1.*, doctrine/inflector:1.2.0 requires php:^7.0, so it will resolve to 1.1.0, which simply requires php:>=5.3.2

So why are we getting reports of broken builds?

The problem arises when:

  1. Your project commits its composer.lock file (which it generally should)
  2. Your development environment has a different php version than your CI or production/test environment

If you have php 7.0 installed locally, the dependency resolution for doctrine/inflector will look like this:

  • acquia/lightning:2.1.7 requires:
  • drupal/core:~8.3.1, drupal/core:8.3.5 requires:
  • doctrine/common:^2.5, doctrine/common:2.8.0 requires php ~7.1, so it will resolve to 2.7.3, which requires:
  • doctrine/inflector:1.*, which will resolve to doctrine/inflector:1.2.0

Which will lock doctrine/inflector to v1.2.0; which requires php ^7.0. Then when you push to your php 5.6 CI environment, you'll get an error like this:

Problem 1
    - Installation request for doctrine/inflector v1.2.0 -> satisfiable by doctrine/inflector[v1.2.0].
    - doctrine/inflector v1.2.0 requires php ^7.0 -> your PHP version (5.6.24) does not satisfy that requirement.
Problem 2
    - doctrine/inflector v1.2.0 requires php ^7.0 -> your PHP version (5.6.24) does not satisfy that requirement.
    - doctrine/common v2.7.3 requires doctrine/inflector 1.* -> satisfiable by doctrine/inflector[v1.2.0].
    - Installation request for doctrine/common v2.7.3 -> satisfiable by doctrine/common[v2.7.3].

The solution, of course, is to run composer update in a dev environment that matches your CI/test/production environment.

Author: 
Original Post: 

About Drupal Sun

Drupal Sun is an Evolving Web project. It allows you to:

  • Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
  • Facet based on tags, author, or feed
  • Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
  • View the entire article text inline, or in the context of the site where it was created

See the blog post at Evolving Web

Evolving Web