Problem/Motivation
In #3319582: Fix calls to methods with too many parameters passed in we discovered the $migration argument in the constructor of Drupal\block\Plugin\migrate\process\BlockTheme is unused.
Let's deprecate it in 10.1 and remove it in 11.0.
Steps to reproduce
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
Release notes snippet
Issue fork drupal-3323209
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
spokjeComment #4
mondrakeI've added an inline comment in the MR
Comment #5
spokje@mondrake I think the official way of deprecating was chosen for a reason...
This leaves us with a lot of deprecation messages from migrations as well as some "fun" new ones
.
Unless I'm doing something very wrong, I think we need to revert back to the official way even if it looses typehinting (which ironically will result in a PHPStan level 2 issue...).
Comment #6
mondrakeWe could do
so we don't lose anything in terms of strictness, PHPStan/PHPUnit will ensure type is respected. Then in D11 clean it all up.
Again, IMHO PHPStan will force us to reconsider some of our current standards...
Comment #7
spokjeHmmm, am a bit lost now. Those failing tests all pass on my local setup.
Comment #8
mondrakeYou might temporarily change the deprecation trigger to an exception and look at the stack trace that gets out of the tests from running on DrupalCI
Comment #9
mondrakeI found sometimes the test jobs execute against a repo that is not yet including the last MR commit. Tried to retrigger the test.
Comment #10
mondrakelooks good to me now, let’s bring to committers’ eyes - there’s a different approach than standard re. deprecation of individual function parameters
Comment #11
spokjeMeh, that's rather annoying.
At least now I know about it
Comment #12
longwaveThe constructor arguments have to lose their typehints, or downstream callers cannot actually update the method call before Drupal 11? The constructor then has to handle arguments both with and without the $migration parameter present by checking the type of the 4th arg?.
(It seems unlikely there is a downstream caller, I wish we just made most plugin constructors internal and didn't have to do this dance)
Comment #13
spokjeWell, it was worth a shot ;)
Ironically, since we're working on a PHPStan issue, that's level 2 will start to throw errors when there are _no_ type hints...
So when we end up raising the level, we need to add an @phpstan-ignore-next-line as last line in the DocBlock...
Comment #14
spokjeChanged the deprecation back to the documented "default" way.
Comment #15
smustgrave commentedSeems like a valid deprecation with no failures.
Comment #16
alexpottI reviewed the MR and left a comment that needs addressing.
Comment #17
smustgrave commentedAdded the type back and left a comment.
Comment #18
spokjeAdded another commit, thinking that this is what @alexpott was after.
If this is indeed the case, we need to update https://www.drupal.org/about/core/policies/core-change-policies/drupal-d....
I'm all for this change, but it is annoying that in the rare case we have some solid documentation, it seems to be outdated.
This means a lot of people spend a lot of time on this issue alone, thinking they were doing the officially documented way.
Anyway: Let's await what core committers have to say, and if this is the now official way of deprecating a constructor parameter.
Comment #19
smustgrave commentedReviewing the MR
All the threads appear to be address. The one open one appears to be a comment
Ran just the tests locally and did get a failure
Deprecation call is correct version
All appears good to me
Good work!
Comment #20
quietone commentedFYI, the policy for constructor parameter removal has been updated during the life of this issue.
Setting to NW for the questions raised in the MR.
Comment #21
mondrakeWorking on this.
Comment #22
mondrakeI think the questions in the MR are superceded by latest changes.
Comment #23
smustgrave commentedFrom what I can tell the open threads have been addressed.
Comment #25
alexpottThere's no need for the test to be a kernel test - it can be a unit test. Doing the following fixes this...
But actually I think there are some further things to do...
isn't the invalid arguments I asked for originally... but we have property types... and in this class we have...
So the
assert(is_array($themes));is pointless and I would argue that we should take this opportunity to add the property typehint toprotected $themeConfig;and whilst we're here we should removeprotected $configFactory;because it is never set.Comment #26
mondrakedone #25 (dunno why the MR pushes are now displaced vs d.org comments), then some:
1) removed @coversDefaultClass from test since it is only testing deprecation, and we saw it is confusing if left in (see #3326239: Add phpstan/phpstan-phpunit as a dev dependency).
2) made the
arraydeclaration a bit more stringentstring[].Comment #27
smustgrave commentedChange looks fine to me but been wrong twice before
Comment #28
alexpottCommitted f979f42 and pushed to 10.1.x. Thanks!