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

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

andypost created an issue. See original summary.

andypost’s picture

Status: Active » Needs review
FileSize
1.79 KB

workaround

Berdir’s picture

FWIW, 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.

andypost’s picture

borisson_’s picture

Status: Needs review » Reviewed & tested by the community

Change looks simple enough, is testonly and we need it for php 8.2, +1

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 4: 3298923-4.patch, failed testing. View results

andypost’s picture

Status: Needs work » Reviewed & tested by the community

re-queued as failed Drupal\Tests\quickedit\FunctionalJavascript\LayoutBuilderQuickEditTest is unrelated

alexpott’s picture

Title: Declare $_skipProtectedUserFieldConstraint for user account for PHP 8.2 » Fix ProtectedUserFieldConstraintValidatorTest to not trigger deprecations on PHP 8.2

Fixing the issue title.

alexpott’s picture

Committed 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.

  • alexpott committed 5433842 on 10.1.x
    Issue #3298923 by andypost, Berdir: Fix...

  • alexpott committed 4d2cc81 on 10.0.x
    Issue #3298923 by andypost, Berdir: Fix...

  • alexpott committed 8cbba05 on 9.5.x
    Issue #3298923 by andypost, Berdir: Fix...

  • alexpott committed 3bc7d53 on 9.4.x
    Issue #3298923 by andypost, Berdir: Fix...
alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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