Problem/Motivation
An <ace> tag without attributes raises a warning every time the text is rendered:
Warning: foreach() argument must be of type array|object, false given in Drupal\ace_editor\Plugin\Filter\AceFilter->process() (line 141 of src/Plugin/Filter/AceFilter.php). Drupal\ace_editor\Plugin\Filter\AceFilter->process() (Line: 122) Drupal\filter\Element\ProcessedText::preRenderText()
tagAttributes() returns FALSE when the tag carries no attributes, and process() iterates over that return value without a guard.
A tag with no attributes is the documented basic usage - docs/index.md and docs/1-users/3-filter.md both introduce the filter as <ace> ... </ace> - so the warning appears on the simplest case the module offers. The snippet itself still renders; the attribute loop is skipped, which is correct when there are no attributes, so the effect is a warning on every render rather than broken output.
The existing unit test testNoAttributesReturnsFalse() asserted the FALSE return, so the contract was locked in by a test while no caller could handle it.
Steps to reproduce
- Enable the Ace Filter on a text format.
- Put a tag with no attributes in a node body:
<ace>const value = 1;</ace> - View the node with error reporting set to show warnings.
Reproduced on Drupal 11.4.5, PHP 8.4. tagAttributes('ace', '<ace>code</ace>') returns false, and so does '<ace >code</ace>'.
Proposed resolution
Return an empty array from tagAttributes() when the tag carries no attributes. An accessor with nothing to report returns an empty set, iterating it is a no-op, and an existing if (!$attributes) check keeps behaving the same because an empty array is falsy.
The unit test is updated to assert the empty array, and a kernel test covers processing a bare tag, an attributed tag, both together, and text with no tag, asserting that nothing is raised in each case.
Screenshots
The same node, carrying a tag with no attributes, before and after the fix.

Remaining tasks
- ✅ File an issue
- ✅ Addition/Change/Update/Fix
- ✅ Testing to ensure no regression
- ✅ Automated unit/functional testing coverage
- ➖ Developer Documentation support
- ➖ User Guide Documentation support
- ➖ UX/UI designer responsibilities
- ➖ Accessibility and Readability
- ❌ Reviewed by a human
- ❌ Code review by maintainers
- ❌ Full testing and approval
- ❌ Credit contributors
- ❌ Review with the product owner
- ❌ Update Release Notes
- ❌ Release
User interface changes
- N/A
API changes
AceFilter::tagAttributes()returns an empty array instead ofFALSEwhen a tag carries no attributes.
Data model changes
- N/A
Release notes snippet
- Fixed a warning raised on every render of an
<ace>tag that carries no attributes.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | ace-baretag-comparison.png | 58.44 KB | rajab natshah |
Issue fork ace_editor-3618865
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
Comment #2
rajab natshahComment #5
rajab natshahAdded a before and after screenshot of a bare tag on a node page.
Comment #6
rajab natshahComment #8
rajab natshah✅ Released ace_editor-2.0.4