Recurring events – unable to empty trash

Home Forums Calendar Products Events Calendar PRO Recurring events – unable to empty trash

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1346280
    Mathew
    Participant

    I have found an issue with regards to emptying the trash containing RECURRING events. In the front-end, you get a white screen. In the back-end, it is throwing an error in the server logs.

    PHP Fatal error: Uncaught Error: Cannot use string offset as an array in…. /wp-content/plugins/events-calendar-pro/src/Tribe/Recurrence/Meta.php:420

    I have isolated it to PHP version 7.1 (7.1.6). The issue is NOT present in PHP 7.0 (7.0.15).

    Adding $recurrence_meta = array(); resolves the issue, as illustrated below.

    public static function add_date_exclusion_to_recurrence( $recurrence_meta, $date ) {
    if ( ! isset( $recurrence_meta['exclusions'] ) ) {
    $recurrence_meta['exclusions'] = array();
    }

    $recurrence_meta = array();
    $recurrence_meta['exclusions'][] = array(
    'type' => 'Custom',
    'custom' => array(
    'type' => 'Date',
    'date' => array(
    'date' => $date,
    ),
    ),
    );

    return $recurrence_meta;
    }

    As a side note, I am able to reproduce the issue in a clean sandbox.

    #1347666
    Patricia
    Member

    Hey Mathew,

    Welcome back and thank you for reaching out to us!

    I’m running PHP 7.1 and couldn’t replicate the issue you are experiencing from here. Can you please let me know what is the version of The Events Calendar and Events Calendar PRO you are running?

    Thanks,

    Patricia

    #1347709
    Mathew
    Participant

    Patricia,

    I just created an new sandbox to repro the issue and I could reproduce the issue. Here’s the exact steps I took.

    MAMP Server running PHP 7.1.6.
    Created new WP 4.8.1 install.
    Installed TEC 4.5.12.2
    Installed TEC Pro version 4.4.17

    Make no setting changes whatsoever.

    Create an event (leave default time/date) with a weekly recurrence (7 weeks). Publish event.
    From admin view, hover over FIRST event date and select TRASH SERIES.
    Select TRASH from the admin menu. Select EMPTY trash button.
    White screen will appear.

    Check server error logs.


    [11-Sep-2017 20:16:56 UTC] PHP Warning: Illegal string offset 'exclusions' in /Users/Mathew/Sites/tribetest/wp-content/plugins/events-calendar-pro/src/Tribe/Recurrence/Meta.php on line 417
    [11-Sep-2017 20:16:56 UTC] PHP Warning: Illegal string offset 'exclusions' in /Users/Mathew/Sites/tribetest/wp-content/plugins/events-calendar-pro/src/Tribe/Recurrence/Meta.php on line 420
    [11-Sep-2017 20:16:56 UTC] PHP Fatal error: Uncaught Error: Cannot use string offset as an array in /Users/Mathew/Sites/tribetest/wp-content/plugins/events-calendar-pro/src/Tribe/Recurrence/Meta.php:420
    Stack trace:
    #0 /Users/Mathew/Sites/tribetest/wp-content/plugins/events-calendar-pro/src/Tribe/Recurrence/Meta.php(400): Tribe__Events__Pro__Recurrence__Meta::add_date_exclusion_to_recurrence('A', '2017-09-18 08:0...')
    #1 /Users/Mathew/Sites/tribetest/wp-includes/class-wp-hook.php(298): Tribe__Events__Pro__Recurrence__Meta::handle_delete_request('10')
    #2 /Users/Mathew/Sites/tribetest/wp-includes/class-wp-hook.php(323): WP_Hook->apply_filters(NULL, Array)
    #3 /Users/Mathew/Sites/tribetest/wp-includes/plugin.php(453): WP_Hook->do_action(Array)
    #4 /Users/Mathew/Sites/tribetest/wp-includes/post.php(2460): do_action('before_delete_p...', '10')
    #5 /Users/Mathew/Sites/tribetest/wp-admin/edit.php(146): wp_delete_post('10')
    #6 {main}
    thrown in /Users/Mathew/Sites/tribetest/wp-content/plugins/events-calendar-pro/src/Tribe/Recurrence/Meta.php on line 420

    #1348035
    Patricia
    Member

    Hi Mathew,

    Thanks for sharing with us the steps to replicate the issue. I still can’t reproduce the error from here (I’m runnning PHP 7.1.8), but one of my colleagues could reproduce it with PHP 7.1.4 and the problem was solved by adding the following line in Meta.php as you suggested:

    $recurrence_meta = array();

    It seems that PHP 7.1.(4 and 6) is not converting string to arrays the first time a value is assigned with square bracket notation (although I can confirm it works on 7.1.8). I’ve logged an internal bug report and our developers will review it as soon as they can, but I believe that for now we will leave things as they are because adding this line $recurrence_meta = array(); would cause problems for any PHP earlier than 5.4 and ~30% of people using WordPress are running PHP < 5.4, while only 3% are running PHP 7.1.

    Thanks for sharing your finding and solution with us. Let me know if you need anything else in the mean time and I’ll be happy to assist!

    Best regards,

    Patricia

    #1359021
    Support Droid
    Keymaster

    Hey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.

    Thanks so much!
    The Events Calendar Support Team

    #1572183
    Victor
    Keymaster

    Hi Mathew!

    Just wanted to share with you that a new release of our plugins is out, in which this issue is no longer present.

    Find out more about this release → https://theeventscalendar.com/maintenance-release-for-the-week-of-9-july-2018/

    Please update the plugins and let us know if it works for you.

    Best,
    Victor

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Recurring events – unable to empty trash’ is closed to new replies.