Problem/Motivation
Symfony 5.1 added an InputBag class to store user input. In Drupal core we have a number of places - mostly tests, but not all - where we directly refer to ParameterBag, and at first glance these seem to often be used to store or mock user supplied input.
Proposed resolution
Replace relevant instances of ParameterBag with InputBag for Symfony 5.
Remaining tasks
- Identify which instances need to be replaced
- Determine if we can do this in Drupal 9 with a BC layer or can wait for Symfony 5/6 in Drupal 10
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #38 | interdiff_35-38.txt | 1.15 KB | murilohp |
| #38 | 3162981-38.patch | 32.88 KB | murilohp |
| #35 | 3162981-35.patch | 33.65 KB | quietone |
| #35 | interdiff-30-35.txt | 1.26 KB | quietone |
| #30 | interdiff_22-30.txt | 20.11 KB | murilohp |
Comments
Comment #2
longwaveComment #3
andypostNearly the same we faced in https://www.drupal.org/node/2743809
Comment #4
andypostOn first look
-
\Drupal\media_library\MediaLibraryStateextends it but now mismatch withInputBag-
\Drupal\Core\Form\FormBuilder::doBuildForm()also affected as creating request-
\Drupal\Core\Security\RequestSanitizer::sanitize()processing exactly affected bags so needs shim- other usage in tests but around ~40 places
Comment #6
gábor hojtsyComment #7
andypostPrimary usage looks is for
_raw_variables~20Here's 2 approaches to replace it - patches are examples for one of tests
- aliasing to core namespace as
_raw_variablesis core's concept (could use separate issue to dig)- replace the class directly (patch 2) - more changes but easy to catch remains
Comment #9
daffie commented+1 for replacing the class directly (patch 2).
Comment #10
longwaveAlso +1 to replacing the class instead of aliasing, it will make it less confusing in the future.
Comment #11
daffie commentedI asked @catch on slack about with which solution we should go and his answer was also option 2. It looks to me that we have consensus about the which solution to choose. Putting this issue back to needs work for implementation solution #2.
Comment #13
paulocsPlease check if all places were properly replaced.
Comment #15
murilohp commentedHey @paulocs, I think you forgot to update one place, you updated the tests but not on the implementation, this new patch can fix the testing error.
Comment #16
murilohp commentedForgot to chante the status.
Comment #17
murilohp commentedI'm so sorry for my previous interdiff, here's the correct one.
Comment #18
murilohp commentedComment #20
murilohp commentedMoving to needs review due to my mistake with interdiff.
Comment #21
lucienchalom commentedI found an inconsistency in the documentation on file core/lib/Drupal/Core/Routing/RouteMatch.php
lines 41:
and line 64:
$this->rawParameters = new InputBag($raw_parameters);Can someone confirm if this is how was supposed to be?
Besides that, there was no addition of coding standards and the code looks to be working fine.
As soon this is resolved I can move to RTBC
Comment #22
murilohp commented@lucienchalom good catch! I've updated the code, here's a new patch.
Comment #23
murilohp commentedComment #24
lucienchalom commentedThank you @murilohp!
Everything looks good to me.
RTBC
Comment #25
longwaveNot sure if we want to do this now and use \Drupal\Core\Http\InputBag or wait until we are on Symfony 5.4 when we can use \Symfony\Component\HttpFoundation\InputBag instead?
The Symfony InputBag is final so we can't do a backward compatible switch by extending it.
Comment #26
catchI'm also not sure how much we're gaining here compared to waiting for Symfony 5.4 - we're not actually removing any deprecation messages with this, and we'll want to switch away from \Drupal\Core\Http\InputBag including where it's currently used in core one we're on 5.4 too.
Leaving RTBC but will try to get a third opinion.
Comment #27
catchDiscussed briefly with @alexpott.
If we were able to make the Drupal InputBag a real forward compatibility layer, this might have been fine, but instead it was purely an internal layer so we could update calling code (which isn't necessary for the examples here). Given that, going to mark this postponed on #3197482: Update Drupal 10 to depend on Symfony 5.4 (as a stepping stone to Symfony 6, for deprecation checking support). Once that's in, updating this patch should just be switching the use statements.
Comment #28
catchUpdating the status helps.
Comment #29
daffie commented#3197482: Update Drupal 10 to depend on Symfony 5.4 (as a stepping stone to Symfony 6, for deprecation checking support) has landed.
Comment #30
murilohp commentedHey, I rerolled the patch, and also removed the
\Drupal\Core\Http\InputBagclass, since SF 5.4 landed, I don't think this is necessary anymore. If you think this is not part of the scope of this issue, I can revert and we create a new issue just for the InputBag clean up.Comment #31
murilohp commentedComment #32
daffie commentedComment #33
catchWe marked that internal for removal in 10.0.0, so it's fine to remove here!
Comment #34
daffie commentedThe testbot is failing for D10.
Comment #35
quietone commentedJust did composer update.
Comment #36
longwaveThis seems out of scope.
Comment #37
longwaveThis sentence doesn't quite make sense.
Should we be backporting this sort of thing to 9.x, or does it not really matter?
Comment #38
murilohp commentedMy bad @longwave, I was having some problems testing locally then I changed the
/core/tests/Drupal/TestTools/PhpUnitCompatibility/ClassWriter.phpand forgot to rollback. Thanks for pointing this out!About #37:
1. I changed the return comment on this new patch.
2. IMHO I don't think we should backport this to 9.x. Just focus on D10.
Comment #39
longwaveCSpell appears to be complaining that a file no longer exists, but why did it not do this before?Oh, that's not the issue - it is just
Comment #40
catchOn backporting - it's been good to do as much as we can in 9.x prior to 10.x (we already made a lot of changes along these lines), but I don't we need to worry too much about extracting changes for backport now that 10.x is open (unless there's an additional specific reason to do so).
Comment #41
longwaveRaised #3259142: PHPStan commit check fails if a file is deleted for #39.
Comment #42
murilohp commented#3259142 landed, now I'm rerunning #38, hope it passes now.
Comment #44
spokjeLooks like a random test fail, restarting test
Comment #45
spokjeAnd @catch beat me to it :)
Comment #46
longwaveThis looks good now.
Comment #48
catchThis looks great. Removing usages and one internal class rather than deprecations as such so good to go in before the alpha.
Committed c022827 and pushed to 10.0.x. Thanks!