Follow up to Backport [2346893] to Drupal 7.

Problem/Motivation

Duplicate AJAX wrappers are causing some errors to be rendered twice.
Symptoms have been reported around file field and image field.
In #115 @lauriii notes the element prefix and suffix are added in the twig template, as well as in the renderer.

Steps to replicate using the File field:

  • Add a file field to basic page content type.
  • Upload file of any type other than text.
  • Double error is triggered.

Double Error is displayed

Proposed resolution

Fix this at the source in the ajax rendering system, not just at the points where symptoms occur.
Patch at #176

@xjm notes the #render_children property is defined in core/lib/Drupal/Core/Render/Element/RenderElement.php

Remaining tasks

  • Needs theme system maintainer review.
  • Create a follow-up issue to backport this to D7.
  • Fix templates in a non backwards compatible manner for D9.
  • Resolve ongoing discussion of related changes to metadata.
  • Decide whether or not to bubble up the cache and assets here. [See #185 ]

Example of a user interface change

Show error once, instead of twice! :-) This is just one example. There are likely other places that will be impacted by this change.

Before patch:

before patch

Patched:

patched

API changes

When #render_children is set, everything inside render array except children will be ignored.

Data model changes

None.

Discussion Summary

@idimopoulas reports doing a manual review at #177
@Fabianx explains the problem clearly in #134 and provides a patch at #137
@joelpittet manual review with screenshots at #122
@swentel reports symptom is fixed for image fields but still occurring for file fields in #69

See also
#1920886: drupal_render() should check if it's rendering a 'render element' and if so call drupal_render_children() (inline) instead

Original report

If I edit my profile, and upload a picture to Picture field, after that I see the messages but twice all times. (drupal_render() should check if it's rendering a 'render element' and if so call drupal_render_children() (inline) instead (1920886) ) not about the ajax its just rendering the element.

user edit duplicate messages

I find these message only one place (/core/modules/file/file.module;466) and I think somewhere is called twice. István Palócz see that bug, and he said the problem somewhere in ajax response.

Comments

kattekrab created an issue. See original summary.

fabianx’s picture

Title: Duplicate AJAX wrapper around a file field (D7 Backport) » [D7] Duplicate AJAX wrapper around a file field
Issue summary: View changes
joseph.olstad’s picture

Is there a patch available for this? If not, can someone please start a backport for this?

tree2009’s picture

weird, I added a file field to Article content type, and set the field unlimited, but can't reproduce the duplicated ajax wrapper issue. I used 7.61-dev.

Status: Active » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.