Problem/Motivation
In #3555534: Since symfony/validator 7.4: Support for evaluating options in the base Constraint class is deprecated. Initialize properties in the constructor instead., passing any value that is not an associative array or NULL as $options to the addConstraint() methods and ConstraintManager::create() was deprecated.
This issue is for the purpose of:
- Adding the
?arraytype declaration for$optionsargument - Adding the
stringtype declarations for the$nameargument - Adding the correct return type declaration
- Adding an
array_is_list($option)check inside the methods and throwing an exception if the array is non associative - The
#[HasNamedArgument]attribute is also removed from Symfony 8, so that attribute and the BC layer in ConstraintManager/ConstraintFactory will need to be removed as well - Any other relevant clean up
Steps to reproduce
Proposed resolution
Remaining tasks
Test MR branch with a Symfony 8 update to see if there any remaining incompatibilities.
User interface changes
Introduced terminology
API changes
Data model changes
Release notes snippet
Issue fork drupal-3569092
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:
- 3569092-12.x-update-method
changes, plain diff MR !14602
Comments
Comment #2
godotislateComment #4
godotislateAll instances of HasNamedArgument attribute have been removed.
To make things simpler, I also made
ExtensionNameConstraintnot have any required parameters.Also, I left the ComplexData constraint deprecations in
FieldConfigBase::getItemDefinition()andBaseFieldDefinition::getPropertyConstraints()because they might be better handled in #3570464: ComplexDataConstraint does not work correctly with typed data having a property named properties.Couple of thoughts for follow ups:
Constraintclass be deprecated?$field_definition->getConstraint('UniqueField')should probably be changed to$field_definition->getConstraint('UniqueField') !== NULL.DataDefinitionInterface::getConstraintdocumentation should probably updated to includeNULLin its return type and that it returns the constraint options (e.g., passed in fromaddConstraint()). And StringItemTest::testGenerateSampleValue should also be updated to matchComment #5
godotislateBumping to at least Major, since this is a Symfony 8 blocker.
Comment #6
smustgrave commentedMay be related? https://www.drupal.org/project/drupal/issues/3553503
Comment #7
godotislateComment #8
godotislateRebased for merge conflict.
Linking to #3570077: Update to Symfony 8 because it's either a blocker or a lot of the changes here need to be added there.
Last commit for the script byte changes were to get tests passing, because its seems like HEAD was broken upstream: #3443571-85: Mobile version of Navigation should have focus trap. Upstream fixed and MR rebased.Comment #9
smustgrave commentedNot entirely sure how to test this one. Fact the pipeline is green?
Comment #10
godotislateYes. And check that there are no remaining usages of HasNamedArguments.
Comment #11
godotislateAll deprecation references to
https://www.drupal.org/node/3554746should be gone as well.Comment #12
smustgrave commentedGoing to go on a limb then. Tests are passing and all instances of HasNamedArguments are gone.
Comment #13
godotislateThanks!
Separately, noting that this is not a Symfony 8 blocker, at least not anymore, because AFAICT everything needed from here is already in the MR for #3570077: Update to Symfony 8. Downgrading to Normal.
Comment #14
quietone commentedComment #15
godotislateRebased for merge conflict.
Comment #16
catchCommitted/pushed to main, thanks!