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.
Problem/Motivation
Spin-off from #2712647: Update Symfony components to ~3.2.
The interface has changed, but in core we don't really call any methods on it. Symfony was generally good for providing forward compatibility between 2.8 and 3.0 but there's no way to write compatible code against both interfaces with this one.
Proposed resolution
Create a new interface that extends from the 2.8 version in 8.1.x and the 3.0 version in 8.2.x, that way modules can be written that work with both versions.
Remaining tasks
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#16 | exec-context-2746337-16.patch | 581 bytes | klausi |
#3 | 2746337-8-1-x.patch | 1.16 KB | catch |
#3 | 2746337.patch | 1.16 KB | catch |
Comments
Comment #2
catchComment #3
catchComment #4
klausiThe downside of this is that the next 8.1.x minor release will introduce the API break where people have to change their validator code, right? So instead of having the API break with the release of 8.2.x we have it with the next 8.1.x release.
But yeah, maybe the compatibility with both branches is worth it.
Comment #5
catchYou'll still be able to use the interface since that won't be removed in 8.1.x, and the new interface we're adding extends the old one so type hints should still be valid. Your module will be broken in 8.2.x until you update still of course, can't do anything about that.
Since I only updated one class in user module, we should find out what exactly breaks once test run finishes.
Comment #10
catchDoh. This isn't going to work, or not without a lot more hackery.
Comment #11
dawehnerDid we considered to use
class_alias()
again for the greater good?Comment #12
klausi@dawehner: I didn't know class_alias(), do you have an issue where we discussed it already?
class_alias() sounds a bit magic to me. Where would we put the class_alias() calls? Isn't it very confusing then when reading the code that a namespaced interface is suddenly a different interface with a different namespace? It looks like class_alias() also works with interfaces, so at least there seems to be some technical possibility.
Comment #13
catchditto what klausi said, new to me too and not obvious where to call it.
It would be, but ideally this code would only have to exist for 6-12 months, so if prevents a hard break between sequential releases, +1 in spite of the weirdness.
Comment #14
dawehnerOne obvious place could be somehow in DrupalKernel
Comment #15
klausiAnother obvious place would be a custom autoloader like done in https://samsonasik.wordpress.com/2014/12/19/symfony-2-6-1-class_alias-of...
Comment #16
klausiOr in autoload.php? Attached is a patch what I have in mind.
This will break on the current 8.2.x branch with Symfony 2 because the new interface already exists. So we will have to do this as part of #2712647: Update Symfony components to ~3.2.
Comment #17
dawehnerThat would work for me. Its ugly but that how BC layers are.
Comment #19
jibranLet's move it to a new file (class_aliases.php) so that we can maintain the list and update it as needed.
Comment #20
klausiAs posted in #2712647: Update Symfony components to ~3.2 I think we have exhausted our ideas here with no working outcome. Feel free to reopen if you can get something working.