Problem/Motivation

The website encountered an unexpected error. Try again later.

TypeError: implode(): Argument #2 ($array) must be of type ?array, string given in implode() (line 214 of modules/contrib/recurring_events/src/Plugin/Field/FieldType/YearlyRecurringDate.php).
Drupal\recurring_events\Plugin\Field\FieldType\YearlyRecurringDate::buildDiffArray() (Line: 390)

Steps to reproduce

Create a new Event Series with the following setup:
1. Recur Type: “Yearly”
2. Create Events Between: “2025-12-25"
3. And: “2025-12-25”
4. Event Start Time: “8:30 PM”
5. Event Duration: “3.5 hours”
6. Event Recurrence Schedule: “Recur on Day of Month”
7. Days of the Month: “25th”

Other settings:
- Registration: Enabled - Scheduled Registration - Custom Schedule - 10 days before the event starts
- Location:
, In Person

Save the node and check if an Event Instance is created, for this case is not created.

If not, edit the Event Series and try to re-save the node, the error happens.

if (($entity_config['months'] ?? []) !== ($form_config['months'] ?? [])) {
        $diff['months'] = [
          'label' => t('Months'),
          'stored' => implode(',', ($entity_config['months'] ?? [])),
          'override' => implode(',', ($form_config['months'] ?? [])),
        ];
}

The validation for ?? is not working as it's passing an empty string to it.

CommentFileSizeAuthor
#3 3565683-3.patch1.04 KBaurora.luzzardi
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

aluzzardi created an issue. See original summary.

aurora.luzzardi’s picture

We are using on: 2.x-dev#400e300
With those patches:

This file was automatically generated by Composer Patches (https://github.com/cweagans/composer-patches)
Patches applied to this directory:

3483283: Unexpected error when adding reference field into event instance.
Source: patches/recurring_events/3483283.patch

3484209: EventSeriesForm breaks when editing an empty entity.
Source: patches/recurring_events/3484209.patch

3090186: Registration quantity widget
Source: patches/recurring_events_registration/3090186-multiple-registration-MR111-Oct29.patch

Fix token replacement issue
Source: patches/recurring_events_registration/tokens_replacement.patch

Remove waitlisted users email alerts
Source: patches/recurring_events_registration/remove_waitlisted_alert.patch

Event Instace Update Notification
Source: patches/recurring_events_registration/event_instance_update.patch

Waitlist promotion - duplicating email
Source: patches/recurring_events_registration/watilist_duplicate_email.patch

3496270: Deprecated: Optional parameter $entity_type_bundle_info declared before required parameter
Source: patches/recurring_events_registration/3496270-deprecated-optional-parameter.patch

3178696: Make compatible with Scheduler
Source: patches/recurring_events/3178696.patch

3499792: Improve warning message when updating Event Series date
Source: patches/recurring_events/3499792.patch

3500920: The 'Contact Registrant' and 'Resend Mail' forms are not replacing the subject and message tokens
Source: patches/recurring_events_registration/3500920.patch

Add a revision log message if the instance was updated by the event series entity
Source: patches/recurring_events/revision_log_message.patch

3550534: Add Registration open-close time
Source: patches/recurring_events_registration/custom_registration_time.patch

3498718: retrieveRegisteredParties() should never get all of the registrants for the whole site
Source: patches/recurring_events_registration/3498718-retrieveRegisteredParties_should_not_return_all_registrants.patch

aurora.luzzardi’s picture

StatusFileSize
new1.04 KB

Here a patch to solve that directly on the check, but we migth want to rework it to make the data to be stored in the correct format on the db to not receive an empty string.

aurora.luzzardi’s picture

Status: Active » Needs work
aurora.luzzardi’s picture

This might be related to the "Months" not being required and the first save for the Yearly event is not selecting any month, which is storing an empty value.

aurora.luzzardi’s picture

After some additional testing, regarding the Yearly recurrence type, I believe the Month selection and the Day of the Week / Day of the Month options should use radio buttons instead of checkboxes.

Since a Yearly event is expected to occur once per year, allowing multiple months or multiple days results in multiple instances being created within the same year. For scenarios that require multiple occurrences per year, the Daily, Weekly, or Monthly recurrence types would be more appropriate.

I opened a new Plan issue so that could be properly discussed: https://www.drupal.org/project/recurring_events/issues/3565700

aurora.luzzardi’s picture

muriqui’s picture

Version: 2.0.x-dev » 3.0.x-dev

Confirmed still occurs on 3.0.x:

TypeError: implode(): Argument #2 ($array) must be of type ?array, string given in implode() (line 217 of /var/www/html/src/Plugin/Field/FieldType/YearlyRecurringDate.php).

Drupal\recurring_events\Plugin\Field\FieldType\YearlyRecurringDate::buildDiffArray() (Line: 301)
Drupal\recurring_events\EventCreationService->buildDiffArray() (Line: 127)
Drupal\recurring_events\Form\EventSeriesForm->buildForm()

muriqui’s picture

While the patch does fix the exception, it would be great to also address the root cause here; i.e., that the recurrence fields allow you to submit an invalid schedule that yields zero instances.

Also, the fix should be rerolled as an MR, not a patch file.

muriqui’s picture

Assigned: Unassigned » muriqui

muriqui’s picture

muriqui’s picture

On second thought, no need to complicate matters here for what is otherwise a simple fix. Going to add a test to validate the fix and then call this one good. Work to address the root cause will happen on #3605486: Add constraint validator to prevent invalid recurrence patterns instead.

  • muriqui committed bb13fb43 on 3.0.x
    fix: #3565683 TypeError: implode(): Argument #2 ($array) must be of type...
muriqui’s picture

Status: Needs work » Fixed

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.

Status: Fixed » Closed (fixed)

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