recurrence description lost in update

Home Forums Calendar Products Events Calendar PRO recurrence description lost in update

Viewing 15 posts - 1 through 15 (of 41 total)
  • Author
    Posts
  • #1096103
    Steve
    Participant

    I’m experimenting with a long-overdue update to 4.1 on my dev machine. The first thing I’ve noticed is that the Recurrence Description isn’t being output. When I edit the event, the description isn’t there either. It is, however, there in the serialised _EventRecurrence array… until I press Update on the edit screen.

    It looks like the structure of this array has changed considerably. Now, I appreciate there’s been an overhaul / revamp of the recurrence system. But I thought old data would be carried forward?

    It looks like $recurrence['recurrence-description'] is now just $recurrence['description']. The rest of the array has been completely re-done, but I’m assuming old-style gets converted to new-style?

    Is the neglect of the change in the description’s key the only oversight here? If so, is there a way to easily preserve all current recurrence descriptions when you update?

    • This topic was modified 8 years, 1 month ago by Steve.
    • This topic was modified 8 years, 1 month ago by Nico.
    • This topic was modified 8 years ago by Nico.
    #1097279
    Nico
    Member

    Hi Mike,

    Thanks a lot for the detailed report on this issue and sorry to hear about it 🙁

    From which version are you trying to update? Have you tried to do a progressive update (3.10 > 3.12 > 4.0 > 4.1 > 4.1.1)? Also which plugins are you updating?

    I’m not sure about the technical details on this, but if needed I can share this with someone on the dev team…

    Please let me know about it,
    Best,
    Nico

    #1097372
    Steve
    Participant

    Ah, the version was in the question title but it got cut out. I’m updating from 3.11.2 (main plugin), 3.11.1 (PRO), 3.11 (Filter Bar). I’ll try progressively updating. Let me know if you think of anything else.

    #1097477
    Steve
    Participant

    OK, so I downloaded every single release of all three plugins greater than the versions currently running on live (detailed above), up to the very latest. I updated them all, in synch, one step up at a time. After each step up I:

    1. Refreshed the plugins page to check the versions, and let any update scripts be run.
    2. Refreshed the edit screen of a certain recurring event to see what things looked like in the admin.
    3. Looked at the _EventRecurrence value directly in the database.

    Fun! Not 😉

    What I noticed was:

    • At 3.12, the ‘Recurrence description’ field on the event edit screen vanished, but the ‘recurrence-description’ key and value inside the serialised _EventRecurrence value for the event remained.
    • At 3.12.5, the ‘Recurrence description’ field returned to the edit screen, but not populated with the value in the database. Looking at the data, the ‘recurrence-description’ key and value remained.
    • Nothing else changed with respect to the recurrence description all the way up to the latest versions.
    • I tried entering something in the new (empty) field on the edit screen, updated the event, and when I looked in the data, the serialised array was in the new format, with ‘description’ instead of ‘recurrence-description’, with the old value gone.

    I’m finding it hard to believe you actually wiped all that recurrence description data from everyone’s installations – or left it to people to manually re-populate before they saved individual events in admin?

    On the other hand, nothing seemed to be in place on any of the updates to convert the old array format to the new one. It’s just left to when you save an event next – and the old value for the recurrence description is simply lost.

    Please let me know how you think we can best approach this update process without losing data. Again, I realise having left things not updated for a while isn’t normal (it was out of our hands!). But having done the updating sequentially, it looks like this may have been an omission in the process which updating as each new release came out wouldn’t have helped with.

    #1098066
    Nico
    Member

    Hey Mike,

    Thanks fro following up and sorry to hear this is still an issue.

    As you say the stepped update should have worked, but this issue seems as bit old as well. If the data in the db then it’s a matter of reformatting it. I guess the best would be to develop an update script to migrate this data into the new format. Do you think you can manage to do this? Probably a SQL query to change the array key will be enough. I mean if you manually change the key from recurrence-description to description, does it work as expected.

    Please let me know about it,
    Best,
    Nico

    #1098232
    Steve
    Participant

    Sure, I can develop an update script. I just didn’t want to reinvent the wheel with a limited budget, and I assumed this issue must have been addressed along the way by your code. If there’s literally nothing you can point me to that already handles this, I’ll crack on with a custom script.

    #1098240
    Steve
    Participant

    I just tried manually changing ‘recurrence-description’ to ‘recurrence’ in an event’s _EventRecurrence field (I properly updated the serialized key length as well). Going back to the event’s edit screen, the field wasn’t being populated, and on updating, the recurrence data got converted but again, the description is lost.

    Looking at the old and new format for _EventRecurrence, I’m not sure I know exactly what’s going on. Here’s the old format:

    Array
    (
        [type] => Every Week
        [end-type] => On
        [end] => 2016-05-27
        [end-count] => 1
        [custom-type] => Daily
        [custom-interval] => 
        [custom-type-text] => 
        [occurrence-count-text] => events
        [custom-month-number] => First
        [custom-month-day] => 1
        [custom-year-month-number] => 1
        [custom-year-month-day] => 1
        [recurrence-description] => every Friday in term-time.
        [EventStartDate] => 2016-04-15 16:00:00
        [EventEndDate] => 2016-04-15 18:30:00
    )

    When I update the event (with latest plugins installed), it becomes this:

    Array
    (
        [rules] => Array
            (
                [0] => Array
                    (
                        [type] => Every Week
                        [end-type] => On
                        [end] => 2016-05-27
                        [end-count] => 1
                        [EventStartDate] => 2016-04-15 16:00:00
                        [EventEndDate] => 2016-04-15 18:30:00
                    )
    
            )
    
        [exclusions] => Array
            (
            )
    
        [description] => 
    )

    As you can see, as well as the description value being lost, a number of key/values are lost completely. I’m not sure if this data is simply irrelevant now, or if it should be being factored in some other way in the new system.

    Ideally, it’d be good if you could point me to some code or documentation about these changes. Surely such a radical change in your data schema would have been documented, and would have involved some conversion code which would indicate exactly what’s going on?

    I guess my last resort would be to write scripts which:

    1. Store the recurrence description in a separate, temporary meta field
    2. Programmatically updated every event (not sure if this is possible? would the new format be constructed from the edit screen’s form inputs rather than converted directly?)
    3. Added the recurrence description back into the new format

    But again, I’m not sure about all that data that’s being dropped. Any ideas?

    #1099204
    Steve
    Participant

    I’m keen to get started on the conversion script here, I’m just a bit wary of the changes above. Could one of your engineers confirm the conversion that happened? Can all those ‘custom-*’ key/values, plus the ‘occurrence-count-text’ one, which aren’t in the new format, simply be dropped?

    #1099472
    Nico
    Member

    Hi Mike,

    Thanks for following up on this, and sorry for the delay in my reply!

    I’ll explore the case with someone on the dev team and will let you know about it.

    Best,
    Nico

    #1099558
    Nico
    Member

    Hey Mike,

    Barry crafted this snippet to update the recurrence meta:

    https://gist.github.com/niconerd/695104169a1cdb6f62c5ee2a3635dba7

    Some notes on it:

    • It’s just an outline! You might need to tweak it.
    • With lots of events it would take a long time to complete. Breaking it up so it does things in stages may be preferable.
    • It doesn’t remove some of the old, no longer required entries, but that shouldn’t present any problems in practice.

    Hope this helps you out,
    Best,
    Nico

    #1099971
    Steve
    Participant

    Oh wow, I just wanted word on what needs keeping and what doesn’t, and you went and wrote the script! Thanks. I’ll get testing and let you know if there’s any issues.

    #1099976
    Steve
    Participant

    Unfortunately this doesn’t seem to work. I’m running it on single events to test.

    An event with this meta:

    Array
    (
        [type] => Every Week
        [end-type] => On
        [end] => 2016-05-21
        [end-count] => 1
        [custom-type] => Daily
        [custom-interval] => 
        [custom-type-text] => 
        [occurrence-count-text] => events
        [custom-month-number] => First
        [custom-month-day] => 1
        [custom-year-month-number] => 1
        [custom-year-month-day] => 1
        [recurrence-description] => every Saturday in term-time.
        [EventStartDate] => 2016-04-16 11:00:00
        [EventEndDate] => 2016-04-16 13:00:00
    )

    Seemed to get successfully converted to this:

    Array
    (
        [recurrence] => Array
            (
                [rules] => Array
                    (
                        [0] => Array
                            (
                                [type] => Every Week
                                [end-type] => On
                                [end] => 2016-05-21
                                [end-count] => 1
                                [custom-type] => Daily
                                [custom-interval] => 
                                [custom-type-text] => 
                                [occurrence-count-text] => events
                                [custom-month-number] => First
                                [custom-month-day] => 1
                                [custom-year-month-number] => 1
                                [custom-year-month-day] => 1
                                [recurrence-description] => every Saturday in term-time.
                                [EventStartDate] => 2016-04-16 11:00:00
                                [EventEndDate] => 2016-04-16 13:00:00
                            )
    
                    )
    
                [description] => every Saturday in term-time.
            )
    
    )

    However, there was an event with this meta:

    Array
    (
        [type] => Custom
        [end-type] => Never
        [end] => 2015-10-01
        [end-count] => 1
        [custom-type] => Weekly
        [custom-interval] => 1
        [custom-type-text] => Week(s) on:
        [occurrence-count-text] => events
        [custom-month-number] => First
        [custom-month-day] => 1
        [custom-year-month-number] => 1
        [custom-year-month-day] => 1
        [recurrence-description] => Weekly
        [EventStartDate] => 2015-09-14 15:30:00
        [EventEndDate] => 2015-09-14 17:30:00
        [custom-week-day] => Array
            (
                [0] => 1
                [1] => 2
                [2] => 4
                [3] => 5
            )
    
        [excluded-dates] => Array
            (
                [0] => 2016-01-15 16:30:00
                [1] => 2016-01-18 16:30:00
                [2] => 2016-01-19 16:30:00
                [3] => 2016-01-21 16:30:00
                [4] => 2016-01-22 16:30:00
                [5] => 2016-01-25 16:30:00
                [6] => 2016-01-26 16:30:00
                [7] => 2016-01-28 16:30:00
                [8] => 2016-01-29 16:30:00
                [9] => 2016-02-01 16:30:00
                [10] => 2016-02-02 16:30:00
                [11] => 2016-02-04 16:30:00
                [12] => 2016-02-05 16:30:00
                [13] => 2016-02-08 16:30:00
                [14] => 2016-02-09 16:30:00
                [15] => 2016-02-11 16:30:00
                [16] => 2016-02-12 16:30:00
                [17] => 2016-02-15 16:30:00
                [18] => 2016-02-16 16:30:00
                [19] => 2016-02-18 16:30:00
                [20] => 2016-02-19 16:30:00
                [21] => 2016-02-22 16:30:00
                [22] => 2016-02-23 16:30:00
                [23] => 2016-02-25 16:30:00
                [24] => 2016-02-26 16:30:00
                [25] => 2016-02-29 16:30:00
                [26] => 2016-03-01 16:30:00
            )
    
        [exclusions] => Array
            (
                [0] => Array
                    (
                        [type] => Custom
                        [custom] => Array
                            (
                                [type] => Date
                                [date] => Array
                                    (
                                        [date] => 2016-03-03 16:30:00
                                    )
    
                            )
    
                    )
    
                [1] => Array
                    (
                        [type] => Custom
                        [custom] => Array
                            (
                                [type] => Date
                                [date] => Array
                                    (
                                        [date] => 2016-03-04 16:30:00
                                    )
    
                            )
    
                    )
    
                [2] => Array
                    (
                        [type] => Custom
                        [custom] => Array
                            (
                                [type] => Date
                                [date] => Array
                                    (
                                        [date] => 2016-03-07 16:30:00
                                    )
    
                            )
    
                    )
    
            )
    
    )

    After the conversion, I dumped the new _EventRecurrence meta and got this:

    Array
    (
        [rules] => Array
            (
            )
    
        [exclusions] => Array
            (
            )
    
        [description] => Weekly
    )

    I’m trying to follow the logic, but I guess the issue is in the format of the data that’s passed to tribe_update_event() ? Let me know if you spot anything obvious from your end.

    #1099998
    Steve
    Participant

    I’m not quite sure about the exclusions here. I wondered about this kind of modification to your script:

    $data = [
    	'recurrence'  => [
    		'rules'			=> [ $recurrence ],
    		'exclusions'	=> [ $recurrence['exclusions'] ],
    		'description'	=> $recurrence['recurrence-description']
    	]
    ];

    But I’ve just created a new event with exclusions to look at the data format and it looks like this:

    Array
    (
        [rules] => Array
            (
                [0] => Array
                    (
                        [type] => Every Week
                        [end-type] => On
                        [end] => 2016-06-30
                        [end-count] => 
                        [EventStartDate] => 2016-04-24 08:00:00
                        [EventEndDate] => 2016-04-24 17:00:00
                    )
    
            )
    
        [exclusions] => Array
            (
                [0] => Array
                    (
                        [custom] => Array
                            (
                                [type] => Date
                                [date] => Array
                                    (
                                        [date] => 2016-05-29
                                    )
    
                                [interval] => 1
                                [start-time] => Array
                                    (
                                        [hour] => 08
                                        [minute] => 00
                                    )
    
                                [duration] => Array
                                    (
                                        [days] => 
                                        [hours] => 
                                        [minutes] => 
                                    )
    
                            )
    
                        [EventStartDate] => 2016-04-24 08:00:00
                        [EventEndDate] => 2016-04-24 17:00:00
                    )
    
            )
    
        [description] => it's weird
    )

    Looking back at the data I’m trying to convert (above), I’m not sure where those ‘excluded dates’ have gone?

    #1100172
    Nico
    Member

    Hey Mike,

    Thanks for following up and glad to hear to this worked for events without exclusions.

    The script Barry put together wasn’t taking in account exclusions. You can go a head and ‘convert’ the exclusions to the new format as you are seeing in the new event you generated.

    Please let me know if I’m missing something here!

    Have a great weekend,
    Nico

    #1100779
    Steve
    Participant

    My questions was, if you look at the data I posted above (https://theeventscalendar.com/support/forums/topic/updating-to/#post-1099976) you’ll see that as well as ‘exclusions’, there’s also a load of ‘excluded-dates’. I’m not sure how (or if) these need mapping to the new data structure, as I don’t see any equivalent (see second code snippet above, https://theeventscalendar.com/support/forums/topic/updating-to/#post-1099998).

Viewing 15 posts - 1 through 15 (of 41 total)
  • The topic ‘recurrence description lost in update’ is closed to new replies.