Problem/Motivation

When a paragraphs field is configured with a cardinality of 1, Drupal does not render an "Add more" button. As a result, the add_more key is absent from the widget element array. paragraphs_ee.module accesses this key unconditionally triggering a PHP warning during PHPUnit test runs:

Warning: Undefined array key "add_more" in paragraphs_ee/paragraphs_ee.module on line 85

PHPUnit treats unexpected output — including PHP warnings — as an error, causing the test to fail even though the underlying functionality may work correctly.

Steps to reproduce

  • Install paragraphs and paragraphs_ee.
  • Create a content type with a paragraphs field and set its cardinality to 1.
  • Optionally pre-fill the field with a paragraph item (e.g. via default value).
  • Write a PHPUnit ExistingSite test that renders the paragraph add/edit form for that paragraph type.
  • Run the test and observe the failure mentioned above

Proposed resolution

  • check for existence of add_more key before accessing it

User interface changes

  • none

API changes

  • none

Data model changes

  • none
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

steffenr created an issue. See original summary.

steffenr’s picture

Issue summary: View changes

steffenr’s picture

Assigned: steffenr » Unassigned
Status: Active » Needs review
stborchert’s picture

Status: Needs review » Fixed

Thank you! Merged into 10.1.x-dev.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • steffenr committed eb46dd87 on 10.1.x
    #3590093: check for existence of $elements['add_more'] before loading
    

Status: Fixed » Closed (fixed)

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