Running on Drupal Core 9.0 there is one deprecation message:

 1x: Using the "Symfony\Component\Validator\Constraints\Length" constraint with the "min" option without setting the "allowEmptyString" one is deprecated and defaults to true. In 5.0, it will become optional and default to false.

This is produced by TextareaWidgetTest::testValidation in Drupal\Tests\typed_data\Functional\TypedDataFormWidget

I don't know if there is anything that we can do about this? If it is unavoidable I can set SYMFONY_DEPRECATIONS_HELPER=1 when running at core 9.0 so that the test passes, but more importantly I am alerted if/when the job next fails, as that will mean a new deprecation has occurred.

Comments

jonathan1055 created an issue. See original summary.

jonathan1055’s picture

The test in question has

    $context_definition = ContextDefinition::create('text')
      ->setLabel('Test text area')
      ->setDescription('Enter text, minimum 40 characters.')
      ->addConstraint('Length', ['min' => 40]);

I will investigate adding the "allowEmptyString" option.

jonathan1055’s picture

I tried adding
->addConstraint('Length', ['min' => 40, 'allowEmptyString' => FALSE]).

At core 8.8 and 8.9 this gives the error
Symfony\Component\Validator\Exception\InvalidOptionsException: The options "allowEmptyString" do not exist in constraint "Drupal\Core\Validation\Plugin\Validation\Constraint\LengthConstraint". in Symfony\Component\Validator\Constraint->__construct()
This was using Symfony 3.4.

Running tests at core 9.0 work fine, there is no deprecation warning, and they all pass. This was using symfony 4.4

I also found #3117863: [Symfony 5] Using the "Symfony\Component\Validator\Constraints\Length" constraint with the "min" option without setting the "allowEmptyString" one is deprecated which dealt with the problem in Core 9.0 and 9.1

jonathan1055’s picture

This can be fixed, but first to demonstrate the existing behavior here's a patch which adds drupalci.yml with suppress-deprecations: false

jonathan1055’s picture

StatusFileSize
new2.01 KB

That was a bit tedious, but I finally got the right job config for core 9.0 (php7.3 MySql 5.7), and we can see that there are 59 passes and 1 failure, as expected.

Here is a patch which uses the version_compare(\Drupal::VERSION, '9.0', '>=') to make the necessary distinction. I know that these types of hack are not ideal, but it will allow the tests at 9.0 to run without deprecated warnings.

jonathan1055’s picture

That's nice, we have green at 8.8 and 9.0.

I confirm that this also runs with zero deprecation on the Travis builds at core 9.0

jonathan1055’s picture

StatusFileSize
new1.37 KB

So here is the actual patch for review and commit, without the temporary addition of drupalci.yml

  • TR committed 5c960f1 on 8.x-1.x authored by jonathan1055
    Issue #3161000 by jonathan1055: Deprecated Symfony constraint 'min'...
tr’s picture

Status: Needs review » Fixed

Committed. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.