- Issue created by @andrew robinson
Attempting to add an empty mercury editor template to a page results in an ajax error thrown with the following error:
Error: count(): Argument #1 ($value) must be of type Countable|array, null given in count() (line 77 of modules/contrib/mercury_editor/modules/mercury_editor_templates/src/Controller/InsertTemplateController.php)
Lines 76-77 of the above file are:
// Append to the end of the list if no sibling uuid is provided.
$delta = count($source_components);
- Create an mercury editor template. Assign it a label but no content. Save.
- Create a new page and add the mercury editor template into the page.
- Observe browser console messages.
Either or both of the following:
- Update the line that runs `count($source_components);` to be more robust - test that $source_components is not empty and assign an appropriate value to $delta if it is empty.
- Add validation to the me_template entity create/edit forms to prevent me_template with empty content from being saved.
Active
2.2
Code