Problem/Motivation

Hello, so after this patch was committed to Drupal core Using ConstraintViolation::$arrayPropertyPath bugs on PHP 8.2

  /**
   * {@inheritdoc}
   */
  public function errorElement(array $element, ConstraintViolationInterface $error, array $form, FormStateInterface $form_state) {
    // Validation errors might be a about a specific (behavior) form element
    // attempt to find a matching element.
    if (!empty($error->arrayPropertyPath) && $sub_element = NestedArray::getValue($element, $error->arrayPropertyPath)) {
      return $sub_element;
    }
    return $element;
  }

This code from paragraphs stops working, and you can never reach $sub_element, because !empty($error->arrayPropertyPath condition every time returns false, even if a value is not empty.

Steps to reproduce

1. Install paragraphs
2. Apply the patch https://www.drupal.org/project/paragraphs/issues/2994660
3. In ConstraintValidator set path ->atPath() to the nested element.
4. !empty($error->arrayPropertyPath) will return false.

Proposed resolution

Add this code to make it work.

  /**
   * {@inheritdoc}
   */
  public function __isset($name) {
    return isset($this->$name);
  }
CommentFileSizeAuthor
#2 3359645-2.patch521 bytesmokys

Comments

Mokys created an issue. See original summary.

mokys’s picture

StatusFileSize
new521 bytes
mokys’s picture

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.