Problem/Motivation
See if PSR/log 3 compatibility is possible after the update to Symfony 6, and add forward to compatibility to core for its changes.
Follow-up issue of #3264918: Update symfony/console to Symfony 6
If we do this Drush will become uninstallable until the following things are fixed:
https://github.com/grasmash/expander/pull/17
https://github.com/consolidation/log/pull/27
https://github.com/consolidation/annotated-command/pull/266
https://github.com/consolidation/robo/pull/1109
Proposed resolution
Remaining tasks
User interface changes
None
API changes
Code that implements \Psr\Log\LoggerInterface will need to be updated. Typically code that uses the \Drupal\Core\Logger\RfcLoggerTrait will only need to change:
public function log($level, $message, array $context = []) {
to
public function log($level, string|\Stringable $message, array $context = []): void {
Data model changes
None
Release notes snippet
Psr/Log has been updated to version 3. All the methods that are on \Psr\Log\LoggerInterface have stricter typehints. Contrib and custom modules that provide logger implementations will need to be updated for Drupal 10.
| Comment | File | Size | Author |
|---|---|---|---|
| #16 | 3272447-16.patch | 9.35 KB | spokje |
| #16 | raw_diff-8-16.txt | 2.15 KB | spokje |
| #11 | 3272447-8.patch | 9.35 KB | alexpott |
| #11 | 3272447-no-update2-8.patch | 5.72 KB | alexpott |
| #8 | 3272447-8.patch | 9.35 KB | alexpott |
Comments
Comment #2
alexpottHere's a go at this.
Comment #3
alexpottComment #4
catchThis is tricky - contrib modules will have to make the same change. I guess they could conditionally define the method depending on core version?
Comment #5
alexpott@catch yeah it is tricky. This is why Symfony use their debug classloader and emit deprecations so they can warn people about stuff like this. In order to be both D9 and D10 compatible you'll have to do something like https://github.com/Chi-teck/drupal-code-generator/pull/83. If we do do this if I was a maintainer of a logging module I'd maintain separate D9 and D10 versions and add the psr/log dependency to my composer.json.
Comment #6
catchWe need to decide whether to do this or not for 10.x, and it's starting to get a bit late. If we do it, it'll be a breaking change for contrib logging modules, and they'll probably need 10.x-specific branches.
Looks like all the drush issues are fixed now.
If we don't, it'll probably be an 11.x blocker.
Comment #7
alexpottFor me we should do this for Drupal 10. This is exactly the time when we should be updating the major versions of our dependencies. I think given the existence of \Drupal\Core\Logger\RfcLoggerTrait updates will be quite small.
Comment #8
alexpottRe-rolled the patch...
@catch re:
I don't think this is true. I think if you only make the change to log method to add the return type hint it will still work. See the patch attached that only makes the code changes but not the update to the library.
Comment #9
catchOK I was just following what you said in #5, hadn't actually thought it through.
If that's the case I think we should just go ahead here, we can find the contrib modules affected and open issues for them so they get a direct notification too.
Comment #11
alexpottActually the most disruptive change has already occurred! 10.0.x is already on psr/log v2 and 9.x is on v1.
For what it is worth it is possible to have something that is compatible with v1 and v3... see attached noupdate2 patch...
Also we've already changed the major version for Drupal 10 - see #3266017: Update psr/log to v2
I think my reviews here resolve the needs framework manager tag.
Comment #12
alexpottComment #13
catchNew CR shows the minimal necessary change, and maintaining compatibility between Drupal 9 and Drupal 10, is just adding a void return type hint, so agreed the easiest thing to do will be to update, and as @alexpott points out we've already gone to psr/2.
No changes needed in 9.5.x so the 9.4.0 release isn't strictly relevant here too. Going to remove the 'needs release manager review' tag as well I think this is fine. edit: also confirmed with @xjm in slack that she's +1.
Comment #14
longwaveLet's just get this done now in D10, upstream packages are adding typehints all over the place, we need to be keeping up.
Comment #15
catchNeeds a re-roll after #3275864: Update to Symfony 6.1.1 but ready to go otherwise.
Comment #16
spokjeAttempted a reroll
Comment #17
alexpottReroll looks good.
Comment #20
catchCrediting @xjm for the slack discussion.
Committed aac42cf and pushed to 10.0.x. Thanks!
Comment #22
xjm