I had the following functionality programmed. I will provide a patch in the next comment. I hope this can get into the main release, since I'm sure others would love this functionality.
Basically, for an event type system, I needed to create a form of a Holiday date on a node, that would auto repeat forever into the future.
However, choosing "Stop repeating - After: 99999 occurrences" wasn't optimal because it creates all the dates at once, and due to performance implications doesn't work when multiple users are doing this same action at the same time. So instead, the following patch provides a new option "Never" with a "PHP strtotime formatted" field.
If I were to add "1 month" into the field, after hitting save, it would add 1 month of occurrences. Every additional site cron run will pull the offset and keep the "1 month" value always current. So if a week has passed, it will pull any occurrences for that passed week that would be valid within that "1 month".
When testing out the patch, be sure to turn on Date caching.
Also, please note, that I am not very PHP savvy, which is why I had this programmed, so I would love any alterations to the patch.
Comment | File | Size | Author |
---|---|---|---|
#15 | date-stop_repeating_never-2076639-15.patch | 12.96 KB | dsouza_rohan |
| |||
#13 | date-stop_repeating_never-2076639-13.patch | 12.91 KB | jmuzz |
Comments
Comment #1
NWOM CreditAttribution: NWOM commentedHere is the patch based on the current dev shown on the project page (7.x-2.6+2-dev).
Comment #2.0
(not verified) CreditAttribution: commentedSpelling and typos corrected.
Comment #3
shortspoken CreditAttribution: shortspoken commentedAny news? Has anyone tested the patch?
Comment #4
cameron prince CreditAttribution: cameron prince commentedHere's a re-roll of the patch against the current version of date, but sadly it doesn't work. There are no errors, but when you create a date and then come back and edit it, the values that were entered don't appear to have been saved.
For now I'm going to just go with a high repeat count.
Comment #5
Road Kill CreditAttribution: Road Kill commentedI am also looking for a feature like this it would be awesome if it makes into the next release.
Comment #6
vtcore CreditAttribution: vtcore commentedHere is an updated patch. It's not tested thoroughly, but it seems to work.
Comment #7
laurelstreng CreditAttribution: laurelstreng commentedApplied the updated patch, and the 'Never' option appears, but I don't think it's working any more? Using the calendar module as well the node only appears once in the calendar even though it's been set to repeat & never stop repeating.
Using the latest Drupal 7.50
Comment #8
DamienMcKennaThis needs minor improvements to adhere to the Drupal coding standards, specifically whitespace around brackets, comments before new functions, etc.
Comment #9
jmuzz CreditAttribution: jmuzz commentedCleaned it up, tweaked the help text, and added a default value that should have it working for most use cases.
Comment #11
DamienMcKenna@jmuzz: When you create patches please make sure they are created correctly otherwise the testbot can't test them.
Here's #9 fixed up so it should apply cleanly.
Comment #13
jmuzz CreditAttribution: jmuzz commentedMy bad.
Not sure this will fix the test failure but it does fix my migration problem.
Comment #15
dsouza_rohan CreditAttribution: dsouza_rohan as a volunteer commentedComment #16
dsouza_rohan CreditAttribution: dsouza_rohan as a volunteer commentedComment #17
dsouza_rohan CreditAttribution: dsouza_rohan at TATA Consultancy Services commentedAdding credit comments
Comment #18
Aracon CreditAttribution: Aracon commentedWill this patch be added to the module? The function is really helpful for endless repeating events.
Comment #19
NWOM CreditAttribution: NWOM commented@Aracon: The status is "Needs Review".
If you have tested #15, and it applies cleanly to "7.x-2.x-dev" HEAD of the module, you can mark it as "Reviewed by the Community". Only then will it have a chance of being committed.
Comment #20
aitala CreditAttribution: aitala commentedInstalled and tested. It seems to do the job.
Comment #21
Chris Matthews CreditAttribution: Chris Matthews commentedThe patch in #15 works great for me. Would be awesome to get this in 7.x-2.11.
Comment #22
DamienMcKennaThis needs a bit of work.
It'd also be nice to have tests to confirm the functionality works as intended.
Comment #23
pyrello CreditAttribution: pyrello at Covenant Web Design commented@DamienMcKenna - As far as I can tell, the usage of array_key_exists in the patch in #15 is consistent with similar lines of code. While I agree with you that isset is the better option for checking whether the key exists, wouldn't it make sense to package code cleanup unrelated to this issue as a separate patch?
Comment #24
DamienMcKennaThe major issue with #15 is that the queries need work.
Comment #25
DamienMcKennaI also think it'd be useful to add at least *some* test coverage, to make sure this doesn't break again.
Comment #26
Neo13 CreditAttribution: Neo13 commentedHi guys,
The proposed cron solution didn't work for me at all. So I removed it and also all the helper functions. Other parts work good (e.g. field widget, etc.).
I ended up doing a custom cron function:
It works for me. There is only one ugly select left and that's easy to correct. Downsides are that this updates nodes on each cron run which could have high performance consequences especially with higher node count. Also node changed timestamp is updated every time.
On my site I am using Elysia cron to run this only once daily and my node count is in low double digits so that's not an issue for me.