Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
The \Drupal\Tests\user\Unit\Plugin\Validation\Constraint\ProtectedUserFieldConstraintValidatorTest
changing undefined _skipProtectedUserFieldConstraint
on user account
Also there's some usage found in other places
$ git grep _skipProtectedUserFieldConstraint
core/lib/Drupal/Core/ParamConverter/EntityConverter.php:141: unset($account->_skipProtectedUserFieldConstraint);
core/modules/user/src/AccountForm.php:384: $account->_skipProtectedUserFieldConstraint = $form_state->get('user_pass_reset');
core/modules/user/src/ContextProvider/CurrentUserContext.php:55: $current_user->_skipProtectedUserFieldConstraint = TRUE;
core/modules/user/src/Plugin/Validation/Constraint/ProtectedUserFieldConstraintValidator.php:66: if (!isset($account) || !empty($account->_skipProtectedUserFieldConstraint)) {
core/modules/user/tests/src/Unit/Plugin/Validation/Constraint/ProtectedUserFieldConstraintValidatorTest.php:91: $account->_skipProtectedUserFieldConstraint = TRUE;
Steps to reproduce
https://dispatcher.drupalci.org/job/drupal_patches/139050/testReport/jun...
Proposed resolution
define property or refactor usage
Remaining tasks
fix/commit
User interface changes
no
API changes
no
Data model changes
no
Release notes snippet
Comment | File | Size | Author |
---|---|---|---|
#4 | 3298923-4.patch | 1.34 KB | andypost |
| |||
#4 | interdiff.txt | 453 bytes | andypost |
#2 | 3298923-2.patch | 1.79 KB | andypost |
Comments
Comment #2
andypostworkaround
Comment #3
BerdirFWIW, this is solely a mock problem, because on the actual user entity, this goes through __get()/__set().
Just changing the mock to the class and either not overriding __get()/__set() or mocking them should resolve this too.
new properties on content entities are tricky around translations for example which need special handling to sync the flag between translations.
Comment #4
andypostChecked and that's enough to use
User
entity for mockComment #5
borisson_Change looks simple enough, is testonly and we need it for php 8.2, +1
Comment #7
andypostre-queued as failed
Drupal\Tests\quickedit\FunctionalJavascript\LayoutBuilderQuickEditTest
is unrelatedComment #8
alexpottFixing the issue title.
Comment #9
alexpottCommitted and pushed 5433842cad to 10.1.x and 4d2cc81dff to 10.0.x and 8cbba0551f to 9.5.x and 3bc7d53d06 to 9.4.x. Thanks!
Backported to 9.4.x because test only and to keep everything in sync.
Comment #14
alexpott