Problem/Motivation
Our embedded components have broken dependencies if we want them to be compatible with drupal/core.
We need better visiblity and testing of embedded Drupal components requirements in order to be able to actually maintain all our dependencies.
With #2712647: Update Symfony components to ~3.2 and #2871253: Update Symfony components to 3.2.8 we're locking drupal/core at symfony ~3.2 but the embedded components still declare just ~2.7
and ~2.8
. In order to be compatible with drupal/core this should be something like ~2.7|~3.0
and ~2.8|~3.0
.
In #2862254: Update non-Symfony dependencies before 8.3.0 doctrine/commons
was updated from to 2.5.1
to 2.6.2
. The version requirement declaration was changed from 2.5.*
to ^2.5
in core/composer.json but not in:
- core/lib/Drupal/Component/Annotation/composer.json
- core/lib/Drupal/Component/ClassFinder/composer.json
We have broken component name declarations for drupal/core-file-cache
in:
- core/lib/Drupal/Component/Annotation/composer.json
- core/lib/Drupal/Component/Discovery/composer.json
We have broken component name declarations for drupal/core-utility
in:
- core/lib/Drupal/Component/Diff/composer.json
And in #2776235: Cached autoloader misses cause failures when missed class becomes available drupal/core-class-finder
was added, but we forgot to add it to ComposerIntegrationTest
.
All this happened because embedded components within drupal/core don't have their composer.json files taken into account by composer. A future subtree split into separate repositories and actually requiring instead of replacing will solve this, but for now we need a different solution.
Proposed resolution
Components should not be tied to the requirements of drupal/core, unless there is an actual hard requirement within the component. This is because the component might be consumed by another project and they shouldn't be forced to upgrade from, for instance, symfony 2.8 to 3.2 just because we did, if the component doesn't actually need it.
So:
- A patch to both 8.3.x and 8.4.x should fix obvious errors in components' composer.json files, and it should fix the omission from
ComposerIntegrationTest
. - The patch should also add the same version constraints to both 8.4.x and 8.3.x branches for components, which allows both branches to be built with composer. This would be an open-ended >= type constraint on the lowest version in core.
- So that we can test whether this is working, we should allow for a recursive merge of components' composer.json files from core/composer.json. This will exercise the version constraints, but will not
require
them as dependencies since they are in thereplace
section. - Ideally, there would be a core branch test which performs
composer update
and then runs the tests. This would tell us if our component requirement constraints need work.
Remaining tasks
- Add a change record mentioning that we're merging in the components' constraints.
- Follow-up: Figure out how to put components into vendor (or not).
User interface changes
None.
API changes
None.
Data model changes
None.
Comment | File | Size | Author |
---|---|---|---|
#115 | 2867960_115_85x.patch | 6.37 KB | Mile23 |
#114 | 2867960-114.patch | 6.31 KB | jofitz |
#96 | 2867960-96-85x.patch | 6.26 KB | mpdonadio |
#96 | 2867960-96-84x.patch | 6.26 KB | mpdonadio |
Comments
Comment #2
Eric_A CreditAttribution: Eric_A commentedComment #3
Eric_A CreditAttribution: Eric_A commentedComment #5
Eric_A CreditAttribution: Eric_A commentedHere's the patch for 8.3 with just the five fixes for the three core component composer.json files.
Comment #6
Eric_A CreditAttribution: Eric_A commentedComment #7
Eric_A CreditAttribution: Eric_A commentedComment #8
Eric_A CreditAttribution: Eric_A commentedJust noticed that
drupal/core-class-finder
is missing in action from the merge list. (And replace section and ComposerIntegrationTest).Comment #9
Eric_A CreditAttribution: Eric_A commentedComment #10
Eric_A CreditAttribution: Eric_A commentedComment #11
Eric_A CreditAttribution: Eric_A commentedComment #13
Eric_A CreditAttribution: Eric_A commentedI made a typo and created a zero byte file 2867960-without-component-fixes-9.patch. Here's the correct file.
Note that this one is supposed to fail, even if it is real code and not a test.
Comment #14
Eric_A CreditAttribution: Eric_A commentedSigh, I now I tested it with the wrong branch. One more time...
Comment #16
Eric_A CreditAttribution: Eric_A commentedPatch in #14 was not supposed to pass...
Also, the Drupal 8.3 patch needed to be expanded with
ComposerIntegrationTest
and to the composerreplace
section.Comment #17
Eric_A CreditAttribution: Eric_A commentedComment #19
MixologicNow that #2352091: Create (and maintain) a subtree split of Drupal core and #2513388: Create (and maintain) a subtree split of each Drupal Component are essentially fixed, these bugs in the composer.json are going to be more prominent and should be fixed soon.
Comment #20
Eric_A CreditAttribution: Eric_A commentedDo you think it would be best to remove the replace section parts from this patch? Or perhaps even split off the composer.json fixes (8.3/8.4) from the embedded package merge plugin control (8.4 only?)?
Comment #21
Eric_A CreditAttribution: Eric_A commentedComment #22
Eric_A CreditAttribution: Eric_A commentedComment #23
Mile23Let's fix it so stuff is working without changing the replace-es. We should have a separate issue for that. I'd wager it's not going to be as easy as it could be.
Needs work because it doesn't apply to 8.3.x due to composer.lock having changed. I'll forgo the 'needs reroll' tag because it really just needs to be re-applied with --rej and then have the lock file rebuilt.
Comment #24
Eric_A CreditAttribution: Eric_A commentedI've removed the replace section fix which broadened the scope to much, especially given the fix wasn't tested here.
Note that the 8.4 patches make a one line change to the root composer.json and add a merge section to core/composer.json as the control mechanism. The 8.3 patch contains just plain fixes in core/composer.json.
Comment #26
Eric_A CreditAttribution: Eric_A commentedComment #27
Eric_A CreditAttribution: Eric_A commentedThis patch does not conflict with the patch in #2712647-355: Update Symfony components to ~3.2, but I haven't checked if that one would start failing due to possibly missing updates to embedded components version requirement declarations. If it does I'd be happy to help adding the component fixes to that patch.
Comment #28
Eric_A CreditAttribution: Eric_A commentedActually, looking at that patch it's clear that it does not update the symfony dependencies in the components, so yes, that patch is probably broken in this respect and will fail testing if this one goes in first.
Comment #29
Mile23So the idea here is that we merge these composer.json files so that they'll be exercised, and any dependencies they have are taken into account, as well as any errors that would break things.
We want to keep the replace section because we don't want to require and pull the components into vendor/. Yet. :-) That's definitely a follow-up.
The patches in #24 apply and allow for an install, and also survive a
composer update
.Everything looks good, except the IS mentions a change record. I'm not sure one is needed, but it might be helpful.
Comment #30
Eric_A CreditAttribution: Eric_A commentedWell, I don't think this is meant to be an actual change. It's all a temporary measure, but then again, I don't really know how the component split is going and if we're actually going to require these components any time soon.
Do we consider changing the recurse property from false to true in the root composer template an actual change? Will it actually affect any project, now or when 8.4.0 is released? And even if so, it's still a template if you ask me.
How long before we can actually require the components and ditch the component merging? Before 8.4.0? If so, then it's definitely a temporary measure to keep all the dependencies correct until we actually require the components...
The thing I've been pondering on is if we want the merging to be done in core/composer.json or in the root composer.json. The components are embedded in drupal/core but the merge plugin seems to be working on root level really, given that the file paths to merge are actually declared on root package level. If we move the merging to drupal/drupal then we don't have to recurse. But then the template isn't a clean example anymore. If that's a temporary 8.4.x thing then no problem at all, but otherwise I'm not sure.
Comment #31
Mile23I'm coming from #2873101: Component version constraints are out-dated
The component split has occurred, but core isn't using it. Try going to an empty directory and typing
composer require drupal/core-uuid
and be amazed. :-)There are problems with the declarations of dependencies in some of the component composer.json files. We can't at this point use some components because they have these problems. For instance, we'd like to use the plugin component in the testbot instead of having our own copy of the code, but we can't because of these problems: #2643110: Have drupalci_testbot require drupal/core-plugin in composer.json
We also need to update the integration test, because that's good to have.
By way of preventing regressions, it's nice to merge the component composer.json files. Even if we never directly require the components and only replace them in core/composer.json, then we're still getting the benefit of having Composer try to account for their dependencies.
And... We want these to be merged from core/composer.json (and not ./composer.json) because they're dependencies of drupal/core, not drupal/drupal. I'd rather not have the recursion, but we're only doing the recursion on core/composer.json anyway, and we're in control of the merges in that file.
If we change to requiring the components, it will happen in core/composer.json. And when that happens, even if someone's installed ./composer.json still has the recursion set to true due to being outdated or whatever, there won't be any merges in core/composer.json to recurse through.
Comment #32
Mile23Comment #33
Eric_A CreditAttribution: Eric_A commentedSo #2712647: Update Symfony components to ~3.2 went in and it and it did without addressing our embedded component dependency declarations. Which means the 8.4 patch here with the merge mechanism will fail now until we have those components with symfony dependencies declaring compatibility with both symfony 2 and 3.
We've had these problems before and until now the fixes went in without any tests or other controlling mechanism. It's a good thing to try to add such a mechanism now, but at the same time we need to get the dependencies declarations fixed ASAP, given that split off read-only repo's of all embedded components are now out there at GitHub and Packagist.
Comment #34
Eric_A CreditAttribution: Eric_A commentedComment #35
Eric_A CreditAttribution: Eric_A commentedThe 8.3 patch does not have the symfony problem though, does not have the merging mechanism, and no divergence with 8.4 so that one is ready to go into both 8.3 and 8.4. How to proceed?
Comment #36
Mile23Components should not be tied to the requirements of drupal/core, unless there is an actual hard requirement within the component. This is because the component might be consumed by another project and they shouldn't be forced to upgrade from, for instance, symfony 2.8 to 3.2 just because we did, if the component doesn't actually need it.
So:
ComposerIntegrationTest
.require
them as dependencies since they are in thereplace
section.composer update
and then runs the tests. This would tell us if our component requirement constraints need work.Unfortunately, there's no way to exercise these merged component composer.json files other than to just say
composer update
, which then updates all the dependencies. For instance, composer/installers is updated to 1.3.0 in the lock file for both patches. The testbot might tell us that this isn't a problem, but it might be inconsistent enough to make a maintainer unhappy.In order to get around this, we might verify that the merge works and then go back to the old lock file, but that patch is not presented here. Maintainers could come up with a better idea, too. :-)
So here are two patches. The only difference between them is their updated composer.lock files.
Comment #38
Mile23Here are the same patches where I verified that the merges work with
composer update
, and then did the following:Comment #39
Mile23Updating title and added change record.
Comment #40
Mile23Comment #43
Eric_A CreditAttribution: Eric_A commentedRegarding the patch for drupal 8.3:
Changing version requirement declarations (and syntax) for these components seems out of scope for the purposes of this issue.
Comment #44
Eric_A CreditAttribution: Eric_A commentedI think we should do the minimum here to just get the composer merging to pass in 8.3 and 8.4. Anything beyond fixing the obvious errors will get us into discussions we'd better take to separate issues.
Comment #45
Mile23See #36. The components don't have a hard dependency on any version other than being newer than the one we use in core for 8.3.x. Also, if we declare a version dependency of, say, ~2.8 in 8.3.x, and ~3.2 in 8.4.x, then we impose that raise in version constraint on any project using the component, even though the component itself doesn't need the newer version.
So, if we have a better way to express 'any version higher than 2.8.*' which satisfies the needs of both drupal/core and any other project that might use the components, then I'm all for it.
Comment #46
Eric_A CreditAttribution: Eric_A commentedHow about having symfony version requirements untouched in drupal 8.3 components and for drupal 8.4 components change them to something like
>=2.8 < 4.0.0
?Comment #47
Eric_A CreditAttribution: Eric_A commentedAh, I only now see that drupal 8.3 components have some broken symfony component requirements as well, given that drupal/core requires~2.8
which isn't compatible with~2.7
.But then in drupal 8.3 it could become something like
>=2.7 <3.0.0
?Comment #48
Eric_A CreditAttribution: Eric_A commentedSigh,
~2.7
is compatible with~2.8
. Still #46 seems like the way to go?Comment #49
Mile23OK, added <4.0.0 to all those symfony components.
The interdiffs for the different branches are identical, and the patches only differ on the composer.lock content hash. But they're both here so they have their own test run.
Comment #51
Mile23I can't repro the fail of
Drupal\node\Tests\Views\FrontPageTest
locally, so I'm setting to NR and re-running the test. Also it's in the list of random fails: #2829040-35: [meta] Known intermittent, random, and environment-specific test failuresComment #52
Eric_A CreditAttribution: Eric_A commentedI believe that for the purposes of this issue it is out of scope to change minimum symfony version requirements from 2.7 to 2.8 for involved components, especially in Drupal 8.3.
I feel it's even out of scope for the 8.4 patch. Of course some (8.4) components will prove to be actually coupled to symfony 2.8 or even 3.0, but I fail to see why we should attempt to fix all that in this issue.
Comment #53
Eric_A CreditAttribution: Eric_A commentedComment #54
Mile23You're right... We should be as wide in version constraints as we reasonably can.
I was using the version constraints that core has. Since we don't have tests of the core components themselves at minimum version constraints, it's kind of hard to account for changes to the components since core was using 2.7 versions of symfony components.
Here's a version with 2.7 restored.
Comment #55
mpdonadioDrupal 8.4 just switched to Symfony 3.2: #2712647: Update Symfony components to ~3.2 and #2871253: Update Symfony components to 3.2.8.
Comment #56
Mile23@mpdonadio: Yes, but the components should cast a wider net, since they're supposed to be consumed by other projects. That's why the upper constraints on them for symfony components is <4.0.0.
Comment #57
mpdonadio#56++ ... My bad.
Comment #58
Eric_A CreditAttribution: Eric_A commentedWith the introduction of Component composer.json merging we can't ignore incompatibilities with symfony 3 for drupal 8.4, but for 8.3 this is not an issue at all. I think that in this issue it's best to leave the symfony requirements alone for the components in 8.3.x.
As said before, some components will prove to be actually coupled to symfony >=2.8 or even >=3.0. Let's fix it in dedicated issues, be it 8.3 issues with (partial) forward port, or 8.4 issues with or without (partial) backport.
Comment #59
Eric_A CreditAttribution: Eric_A commentedI've started with creating 8.4 issues for fixing the symfony requirements. See #2876669: Fix dependency version requirement declarations in components.
Comment #60
Eric_A CreditAttribution: Eric_A commentedOpened #2876725: Fix trivial core component composer bugs before 8.4.0.
Comment #61
Mile23Trying to figure out how to test some of these things led me here: #2876408: Update wikimedia/composer-merge-plugin to ~1.4 in composer.json to match composer.lock
Comment #62
Mile23I made a travis-ci test of the components, which currently fails because of this issue. https://github.com/paul-m/drupal_component_tester
Travis results here: https://travis-ci.org/paul-m/drupal_component_tester
Comment #63
Eric_A CreditAttribution: Eric_A commentedNice!!!
How about we do #2876725: Fix trivial core component composer bugs before 8.4.0 first, to make current branch users happy? We'll still have 8.4.x with the broken symfony dependencies to keep us busy.
Comment #64
Mile23A review here would be great. :-)
Comment #65
Eric_A CreditAttribution: Eric_A commentedWell, I'd RTBC this if it weren't for the concerns I have regarding changing requirement declarations in drupal/core 8.3 and adding wikimedia/merge-plugin to 8.3. If those we're left out for 8.3 I would have RTBC'd this. Since you want to keep 8.3 and 8.4 fully in sync we'll need others to chime in. :-)
On a side note: I kind of consider the components in 8.3 major version 3 and the components in 8.4 major version 4.
Comment #66
Mile23Patch in #54 keeps the current versions, just adds <4.0.0 for symfony components. This is in both 8.4 and 8.3, because the requirements for the components themselves probably haven't changed. We'll test this assumption in follow-ups.
We want to have version requirements that are general enough for the outside world, specific enough for core, and somehow testable.
We can't test until the dependencies are at least minimally correct and resolvable, so we add reasonable best-guess version boundaries now. Then we get more specific in #2876669: Fix dependency version requirement declarations in components and children.
How does that sound?
Comment #67
Eric_A CreditAttribution: Eric_A commentedIndeed, moving away from the tilde operator allows us to keep the symfony version constraints in sync with regards to the scope of this issue! So we're fine within a drupal/core context. Independent consumers of drupal 8.3 components might suddenly get a higher version of symfony, but this was never supported yet, I guess.
What remains is introducing the merge declarations in drupal/core 8.3 with the changed recurse property in the drupal/drupal composer.json template. There's a chance that the latter will have composer suddenly start merging stuff it didn't merge before, right? If so, a little notice in the change record would be good?
Comment #68
Eric_A CreditAttribution: Eric_A commentedActually, I think the change notice is good enough as it is.
Mile23 has taken over significantly, so I think i can RTBC.
Comment #69
Mile23It will only merge what we tell it to merge. Since we're merging the component composer files, the recurse will only go as far as those components require. It might be that some component dependency also has wikimedia merge directives, in which case we might need another strategy, but so far that's not the case.
Comment #70
Eric_A CreditAttribution: Eric_A commentedI was thinking about required packages from vendors other than drupal. If any such package has a merge section like the one we're introducing in drupal/core then composer will merge embedded composer.json files whereas it doesn't do that right now.
Comment #71
Mile23Well, if you apply the patch and run
composer update -vv
you'll see that currently we don't have that problem. There's really no way around assuming it won't be a problem, other than to not exercise the composer.json files for the components.Comment #72
Eric_A CreditAttribution: Eric_A commentedNo, no, I mean packages *added* to the template composer.json, and dependencies of those packages.
Comment #73
Mile23wikimedia will only start merging the files we tell it to merge, under
extra:merge-plugin:require
. The only way for packages required by drupal/drupal to start recursively merging is if we also add its composer.json toextra:merge-plugin:require
.The only worrisome part is dependencies of
core/composer.json
, but for that we have this:Also:
DRUPAL_ROOT/composer.json
isn't a template. It's the drupal/drupal package. It gets used every time a tarball is built, for instance.We all look forward to the day when we can be free of this bailing-wire-and-spit type of dependency management, but that day is not near. :-)
Comment #75
Mile23Rerolled for composer.lock content-hash after #2876408: Update wikimedia/composer-merge-plugin to ~1.4 in composer.json to match composer.lock
Comment #77
Mile23Reroll of 8.4.x patch.
8.3.x patch in #75 still applies and passes.
Comment #78
Mile23Comment #80
jibranDo we still need #2876669: Fix dependency version requirement declarations in components after this? We need a new 8.5.x patch.
Comment #81
Mile23This issue is to get the component composer.json files into shape so that we can use them.
We can then figure out more specific requirements in other issues. And since the composer.json files will actually work, we can write automated tests to help us figure that out.
Comment #82
Mile23Patch for 8.5.x.
The only difference is the lock file's content-hash. Either patch will apply to either branch using
git apply --rej
. Create a new lock file withcomposer update --lock
.Comment #83
jibran#81 makes sense to me so RTBC
Comment #85
Mile23Would love to be able to require core components in the testbot before 8.5.0... #2643110: Have drupalci_testbot require drupal/core-plugin in composer.json
Comment #86
Mile23The plan seems to be that we should stop using the wikimedia merge plugin: #2912387: Stop using wikimedia/composer-merge-plugin
Therefore we'll eventually need to figure out another way to account for the Components. We might end up requiring them into core's composer.json.
I won't change RTBC here in case this becomes a temporary measure to get things working.
Comment #88
Mile23Needs some work since #2876725: Fix trivial core component composer bugs before 8.4.0
Comment #89
jofitz CreditAttribution: jofitz at ComputerMinds commentedRe-rolled.
Comment #91
jofitz CreditAttribution: jofitz at ComputerMinds commentedWhoops, the patch in #89 was against 8.5.x. This is against 8.4.x.
Comment #92
Eric_A CreditAttribution: Eric_A commentedComment #93
jofitz CreditAttribution: jofitz at ComputerMinds commentedPatch in #91 no longer applies. Re-rolled.
Comment #94
Mile23Almost RTBC except it needs an 8.5.x patch so we can do both at the same time. The only difference is the lock file content hash, which you can make like this:
I was able to perform
composer update
andcomposer update --prefer-lowest
and then run all the unit tests, for both 8.4.x and 8.5.x.Comment #95
Mile23Comment #96
mpdonadioThe 84x patch is just the one from #93renamed for clarity.
Ran ComposerIntegrationTest locally and both passed.
Comment #97
mpdonadioComment #98
Mile23Same deal as #94: I was able to perform
composer update
andcomposer update --prefer-lowest
and then run all the unit tests, for both 8.4.x and 8.5.x.Comment #100
Mile23Test failed due to #2919773: Fail to download drupal/coder because github.com/klausi/coder has gone missing
Restarting test.
Comment #102
andypostComment #103
alexpottDo we need a change record because people are managing their own root composer.json files? I.e. are people going to have to change the recurse value in their own root composer.json files? I also wonder what happens with composer drupal installer? Or do we just not care because the core is coming anyway and this buys us testing on DrupalCI but makes no difference for anyone else atm?
Comment #104
alexpottWell there is a CR https://www.drupal.org/node/2875519 - but it is not telling a site what are the actual impacts of the change for them and what if anything they need to do.
Comment #105
alexpottAlso the CR talks about things that haven't happened yet - ie. moving components to vendor which is odd because it means that people reading it are getting information that is not helping them deal with the actual change.
Comment #106
Mile23That's pretty much it. Drupal core doesn't even officially support having a different
composer.json
file. However, other projects could do the same trick for their testing.The only concern is that if you required, say, drupal/address into drupal/drupal in the past, and maybe drupal/address' requirements are in conflict with a component or two. How do you find out? You have to merge the components. But if you don't add the merge to your stale
composer.json
file then you never find out. We'd expect this to be as much a problem as it is right now (not a huge one).However... If you follow the update.txt instructions you'll do the right thing in that case and type
composer require drupal/address
into the new drupal/drupal. Then your stalecomposer.json
file won't be stale any more, and you'll find out that there's a conflict (if there is).Hmm... Looking for that issue about updating UPDATE.TXT to make this clearer, and can't find it.
Updated CR to point out that you can make this change in your bespoke composer.json file if you want, with instructions.
Comment #108
jofitz CreditAttribution: jofitz at ComputerMinds commentedRestarting tests.
Comment #109
jofitz CreditAttribution: jofitz at ComputerMinds commentedTests passed so setting back to RTBC, assuming testbot failure.
Comment #110
larowlan@xjm and I discussed this and decided to postpone it on #2874909: Update Symfony components to 3.3.* as that is Critical.
If the two won't collide, please advise.
Comment #111
Mile23The changes to the component composer.json files have a very wide allowance for symfony versions, safe to say >=2.8 <4.0. That should include 3.3.
Part of the point of merging the dependencies here is that we can then test which constraints are right or wrong and generally make them more maintainable.
We should probably concern ourselves with the 3.3 upgrade first, but as part of that we might end up changing the components and forgetting to change their constraints to ^3.3. Which we wouldn't do if we fixed this issue first.
Comment #113
Mile23#2874909: Update Symfony components to 3.3.* was replaced by #2927746: Update Symfony components to 3.4.*, which is in, so I'm unpostponing here.
Also, the testbot now depends on this: #2643110: Have drupalci_testbot require drupal/core-plugin in composer.json
Comment #114
jofitz CreditAttribution: jofitz at ComputerMinds commentedThe patches from #96 no longer apply so I rerolled.
Comment #115
Mile23This will probably need another re-roll after #2940367: Update Symfony components to 3.4.4 (or vice-versa).
It'd be great to get this in 8.5.x so we can start testing the component constraints before the 8.6.0 release. It's only disruptive to our test results if we're doing the wrong thing, which is what we want.
Comment #116
jibranWe already have a follow-up #2876669: Fix dependency version requirement declarations in components ready to finetune version requirements so setting it to RTBC.
Comment #117
alexpottCommitted c70c4f4 and pushed to 8.5.x. Thanks!
Committed 65b232a and pushed to 8.6.x. Thanks!
Whilst 8.5.x and 8.6.x are relatively aligned I think we should do this. It helps keeps our component composer.json a bit more honest.