Closed (fixed)
Project:
Recurring Events
Version:
8.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
18 Oct 2019 at 20:57 UTC
Updated:
2 Dec 2019 at 18:29 UTC
Jump to comment: Most recent, Most recent file


Comments
Comment #3
owenbush commentedAttached is a patch to introduce the following different types of recurrence:
Daily - so you do not have to select every day of the week in a weekly event
Consecutive - so you can create events every X seconds/minutes/hours with a buffer of Y seconds/minutes/hours
This patch also allows for other users to create their own recur types so long as their FieldType classes implement the new RecurringEventsFieldTypeInterface.
This patch also allows for administrators to choose which recur types are enabled to give them flexbility to enable/disable ones which are suitable to their user base.
Several new hooks have been added too
- hook_recurring_events_units_alter to allow a user to alter what units (seconds, minutes, hours) are available.
- hook_recurring_events_recur_field_types to allow a user to alter which recur field types (consecutive, daily, weekly, monthly, custom) are available
This patch comes with 2 hook updates needed to bring an existing installation up to date:
8002 - Converts existing series to use the new recur type values (weekly -> weekly_recurring_date, monthly -> monthly_recurring_date)
8003 - Adds some config to enable all the recur types, and adds the new daily and consecutive recur type base fields.
Adding technotim2010 to the credits for surfacing this need and helping construct the idea.
This is ready for testing...
Comment #5
owenbush commentedCrediting mrpauldriver too
Comment #6
owenbush commentedPatch updated to ensure on fresh install that the config is configured to enable all recur types.
Interdiff provided
Comment #7
mrpauldriver commentedI will patch development version: 8.x-1.x-dev updated 18 Oct 2019 at 22:23 UTC
Comment #8
mrpauldriver commentedI'll list my findings in separate posts to this issue.
Comment #9
mrpauldriver commentedBUG/FEATURE: On my first test I overlooked the duration default setting (in seconds) and ended up with an Internal Server Error after 1801 x 1 second consecutive instances had been created. I'm guessing this is a hard limit, a memory thing or a timeout. Whatever it was, wasn't helpful as it resulted in WSOD.
With the potential for unlimited recurrences in a series, all of which have to be generated, this will likely cause problems. So how about capping the number of consecutive instances with a hard limit?
Assuming the most likely use case of event bookings.
- 1440 (1 minute slots in a day) But why would anybody want this?
- 1024 (hinting at a technical limitation)
- 100 (small round number)
- 1000 (big round number)
- 288 (5 minute slots in a day) But why?
- 168 (hours in a week) But why?
Alternatively, generate a fixed number and then add to this incrementally via a batch process. But this sounds like over-engineered development for the sake of it
I like the round number idea. It is clear and unambiguous.
Until that is, until someone comes along, thinking this would make a neat appointments system linked to office hours. But that's another issue.
Comment #10
mrpauldriver commentedUI: Event buffer should have a default value of zero. It is easy to ignore if a buffer is not required and causes a form validation error if not completed.
Comment #11
mrpauldriver commentedTASK: The form validation message "This value should be of the correct primitive type." is somewhat cryptic. This needs humanizing.
Comment #12
mrpauldriver commentedDISCUSS: Further to #9. Unless we are saying that a recurring event is something other than a thing that people would observe, attend or participate in. I'm not sure that having event durations in seconds is a good idea. What might be the use case for this?
What is the smallest granularity for an event for which people might want to register for? For my use case (school parent evening) this would be five minutes or more.
Others might have different ideas. A one minute speed date perhaps?
Comment #13
mrpauldriver commentedBUG: Consecutive and Daily date settings are not preserved when editing a series.
Steps to reproduce.
1. Create a series
2. Edit the series
3. The date inputs are blank
4. Attempting to re-save results in WSOD
Comment #14
mrpauldriver commentedBUG: An invalid form validation error occurs (for the consecutive recur type) when saving an event using a different recur type.
I am guessing the consecutive event form inputs are not disabled when a different recur type is selected
Steps to reproduce.
1. Enable Consecutive Event Recur Field Types and at least one other
2. Create an event using one of the other recur types
3. Save the event
4. Form validation occurs, but not for the currently selected recur type
5. The error belongs to the unselected consecutive event recur type
Screenshots attached. Please note, my UI is customised with field groups and tabs.
Comment #15
mrpauldriver commentedOverall this looks very promising. Thank you for working on this Owen.
Comment #16
owenbush commentedHey Paul,
I'm taking a look at these issues for you now.
Adding a default value for duration, duration units, buffer, and buffer units is simple and will be addressed today.
I've so far been unable to reproduce the issue with Consecutive and Daily settings not being preserved when editing, nor the issue with failing validation when using a different recur type.
Can I ask - did you run database updates after you patched the module and clear all caches? I'm presuming you did, but just wanted to check.
I'm going to spend some time pondering the issue with memory limits and trying to create a lot of events. The reason I added 'seconds' is that I felt that there may be a use-case that I'm not thinking of, or aware of. And it makes sense to add that functionality in now when I added in minutes and hours, rather than having to shoe-horn it in later. But you're right, if some non-sensible values are added to the form, then it will be easy to run into memory issues. Creating the events in batch is a nice idea as you say, but does seem a bit much. I'm tempted rather than forcing the lower limits, to add validation that says something like "By setting such a low value you may run into memory issues". If someone wants to create an event every single second of every day for a month, great - they'll just have to increase their PHP memory limit to a point where that is feasible.
Comment #17
owenbush commentedAttached is a patch (and interdiff) that allows site admins to enable (or disable) an event instance threshold warning. Meaning that if more than X (threshold_count) event instances are going to be created you can show a warning in the widget. Additionally, you can also specify whether exceeding that threshold will prevent event creation altogether. These are configured in the event series setting. There are 4 new config items:
A database update will be required to add the default config values.
Comment #18
the_glitch commentedApplied patch and got this error on page /events/add
Comment #19
mrpauldriver commentedRef #16. Ah. No I hadn't updated. Silly of me.
After doing so, problem at #13 is solved.
Problem at #14 persists and I have narrowed this down to consecutive event recur types's duration and buffer not being populated. This probably should not happen, but I expect default values for these two inputs would negate it.
I'll move on the the next patch now.
BTW. I'm not up to speed with interfdiffs and having read the help page, I'm not sure whether I can apply this on top on the existing patch or whether to remove the old one and apply the new. In the meantime I'll experiment, but it would help me if you could clarify this gap in my understanding. Actually this just one of many gaps in my understanding;-)
----
Edit: I just re-read the help page again and the passage below clarifies the correct usage.
Comment #20
mrpauldriver commented@the_glitch The second patch applied cleanly for me. I did remove the first patch beforehand.
Default settings for duration and buffer work well and fix the bug mention at #14.
The event threshold works nicely, but I found it slightly confusing. I got the impression that I could have a warning with the option to continue, but this was not the case and it me proceed without seeing a warning. Server error follows. Is this a bug or working as designed?
Threshold Prevent Save checkbox works well. Would this be better if enabled by default?
Body field is still mandatory.
Comment #21
the_glitch commented@MrPaulDriver I hadn't applied either of the first 2 patches before. Patch #17 is the only one I've tried.
Comment #22
owenbush commentedI'll review this all later today, but @the_glitch, your composer has deleted the whole module again. You can see in the error that it says the event series entity type doea not exist. That only happens if the module code has been removed. As usual you'll need to run your composer commands again. As Paul said, this patch should apply, and even if it didn't, that error is not what would happen in the event of a failure.
Comment #23
owenbush commentedGlad to hear #13 and #14 are resolved. I'll get to setting the body field as not required - but I may approach that as part of a separate ticket. There is a lot of validation I need to add and I can work that at the same time.
The threshold warning should (if enabled) just display under the duration/duration units fields (injected via AJAX and with default styling may not be super obvious it is there!), and will display whatever message is entered in the settings. Unless 'prevent save' is enabled it won't prevent saving it is more informational. If prevent save is enabled then when the form is submitted a proper validation error is shown at the top and it will not save the series.
I just tested it - it works if editing an existing series but seems to have stopped working for new series. I'll get that resolved....
Comment #24
owenbush commentedAttached is an interdiff and patch to address the warning not displaying on add forms.
Comment #25
mrpauldriver commentedI've installed patch 24 and confirm that the message is displayed when editing an existing series, but I'm still not seeing this for new event series. Nothing coming in via ajax is observed. Screenshots attached.
When this is working, I think visibility of the message might remain be a problem. In the case of an existing series, I think the message should be duplicated along with the dialogue to confirm date changes, because this is where the the site editor's eye will be drawn
Comment #26
mrpauldriver commentedJust reviewing my last post and wondering what would happen to pre-existing registrations in the event of;
Comment #27
owenbush commentedI had to clear caches locally for this change to take effect. Can you confirm if you did that after applying the patch? If so, then I may need to look at this again.
I agree putting it in the confirm date changes section is a good idea. Visibility is a concern for me too, I applied an 'error' class to the message in hope that whatever admin theme is in use would hopefully have some error styles in place. I want to stray away from being too verbose or opinionated as far as theming goes as it might not work well with all themes. Equally I want to ensure the content editor is seeing what they need to see, so I'll explore what other options I have here.
In this circumstance, all event instances in that series, and their registrations are wiped out. Registrants should be emailed with a cancellation notice as this happens. The underlying hope is that event series dont get updated after-the-fact. Once there are registrations etc, any changes needed are applied to the instances themselves, not the whole series. This is pretty fundamental to how everything fits together, because as instances are created by the creation/saving of an event series it is hard to determine whether the instance a registrant has registered for 1) exists at all anymore, 2) is at a different time as so they may no longer be able to go.
Updating date recurrence is a destructive process as mapping existing instances to new ones is extremely difficult.
Comment #28
the_glitch commented@owen yes i realised composer had deleted the module again so I ran require again then got a different error on /events/add
This error also happens with patch #24.
Comment #29
owenbush commented@the_glitch: the definition of the EventCreationService has changed and needs a full cache flush in order to work after patching.
Comment #30
the_glitch commentedI flushed caches and the error is fixed but now the 'Recur Type' field has disappeared.

Comment #31
owenbush commentedLooks like you haven't run database updates, can you run those, clear the cache and then report back?
Comment #32
the_glitch commentedI ran
drush updbthendrush crand it's still the same. No 'Recur Type' field.Terminal is saying:
Drupal\Component\Plugin\Exception\PluginNotFoundException: The "weekly" plugin does not exist. Valid [error]Comment #33
the_glitch commentedPatch #24 applied after having to delete the all series nodes that were causing a 'Weekly' plugin error when
drush updb.Now 'Inline Entity Form - Complex' fields in Event Series don't work.
Comment #34
the_glitch commentedPatch #24 applied after having to delete the all series nodes that were causing a 'Weekly" plugin error when
drush updb.All 'Recur Types' are now in the form and functioning but has now created a bug with 'Inline Entity Form - Complex' fields in Event Series causing the IEF-Complex 'Add Existing Node' and 'Add New Node' buttons to not work due to what seems to be an AJAX error each time those buttons are clicked that all says this:

Comment #35
mrpauldriver commentedRef #27. Cache cleared but still not seeing the ajax warning.
Comment #36
the_glitch commenteddo you have any inline_entity_form fields in Series? If not, install the inline_entity_form module and add an entity reference field and in Manage Form Display use the 'Inline Entity Form - Complex' widget and you'll probably get the same issue.
Comment #37
owenbush commentedLet's try and deal with one issue per thread. The IEF problem should be raised as a separate issue so I can review if it is RE's end or not. I'd prefer to deal with just the daily and consecutive recur types here to keep things clear.
Comment #38
the_glitch commentedYeh I wasn't sure if to raise a separate issue or not because the problem only started after applying the patch in this issue.
Comment #39
owenbush commentedI found the issue causing the problem with IEF. So attached is an interdiff and another patch.
Comment #40
the_glitch commentedTested and working with IEF. Thank you
Comment #41
owenbush commentedPaul - are you still not seeing the warning via AJAX when setting a consecutive event? I've been unable to recreate that issue locally and would like to get this merge done if it is working as it is a bit of a blocker for other items.
Comment #42
mrpauldriver commentedWith patch #39 . Still not seeing ajax warning when 'Event Instance Threshold Prevent Save' is not checked.
Comment #43
owenbush commentedPaul - have you made any changes to the form layout using field groups or tabs or anything? Or is the form display all as it is out of the box? Thinking about this if any changes were made then the message will likely be appearing somewhere completely random, so I may need to actually attach it to one of the fields to make sure it shows up in the right place.
Comment #44
mrpauldriver commentedI did have some field groups on the node form and had similar thoughts myself. After getting rid of them I still don't see the ajax warning. I have also uninstalled, reinstalled.
Please could you post a screenshot of what I should be seeing? Bartik theme.
Comment #45
owenbush commentedHere is a screenshot of what it should look like out of the box with Bartik.
Comment #46
mrpauldriver commentedSorry, it's not present. Nor is it seen for a completely fresh installation on simplytest.me See screenshot attached
Patched with https://www.drupal.org/files/issues/2019-10-30/recurring_events-daily_co...
Comment #47
owenbush commentedLooks like I have work to do then. I'll report back when I know more. Thanks for persisting with this.
Comment #48
owenbush commentedHey Paul
I've done some more testing and even went on simplytest.me like you did and applied patch 39.
I think what may be the issue here is that in order for the check to take place, one of the values of Duration or Duration Units needs to be updated. This wasn't necessarily a problem when there was no default value for duration, but now that it defaults to 5 minutes, I may need to run the validation immediately on page load too. Can you test modifying one of those values to see if you get the message as expected?
Comment #49
owenbush commentedAttached is an interdiff between patches 39 and 49. It shows that I've made the error more visible by using the standard `form-item--error-message` class. Not only that, but I've also set the checks to kick in when the start date, end date, start time, and end time fields are modified, not just the duration and duration units fields. I also added the error message to the diff that gets shown at the top of the form when you are updating an existing event.
Hopefully, this will draw more attention to the messages.
Here is a screenshot

Comment #50
mrpauldriver commentedI now see a warning in the date range area when first creating an extended series, and also in the confirmation area when extending an existing series.
Looks good to me.
Comment #51
mrpauldriver commentedOne small inconsistency. The form order is different for consecutive events with the radios appearing below the date range. With other recurrence types the radios appear above.
Please see screenshots.
Comment #52
mrpauldriver commentedSorry, Dreditor embeds screenshot in opening post. Must figure out how to avoid that
Comment #53
owenbush commentedHey Paul thanks for all the testing. I really appreciate it.
Were you seeing the field ordering inconsistency in a fresh install like simplytest.me or on an existing site that was patched? I'm going to take a look to see what is going on for you, but the extra info would be much appreciated.
Comment #54
mrpauldriver commentedTested on my patched local, but also seen on simplytest.me
Comment #55
owenbush commentedI have modified the patch a little to hopefully fix the issue with ordering of fields. Please let me know if this does not work.
Comment #56
owenbush commentedBah, I inadvertently added some registration related stuff into the configs which I should not have. Updated the patch.
Comment #57
mrpauldriver commented#56 Fixed. Big job, done well. Marking RTBC.
I am now left wondering whether consecutive slots can be plugged into to the other recurrence types? For example; recurring 30min slots, between 9am and 5pm, Monday-Friday. #appointment_system
Comment #59
owenbush commentedThanks all, especially Paul (good rhymes) for getting this over the finish line. I've merged it into 8.x-1.x-dev.
Paul, plugging the consecutive slots into the other types is probably best placed into a different issue so it can be tracked, if you are interested in that sort of functionality.
Marking as fixed.
Comment #60
mrpauldriver commentedI don't think I will be needing the extra functionality, but would not be surprised if others did and I agree it should be another issue.