Viewing 18 posts - 1 through 18 (of 18 total)
  • Author
    Posts
  • #909605

    Hi – I’m running Enfold 4.2.2 with Events Calendar Pro and Event Tickets Pro (latest versions). When I attempt to update / save an event that has tickets, I get a blank -1 screen. If I deactivate Enfold and instead use Twenty Seventeen, it works.

    How do I figure out what the root cause of the conflict is? I don’t see anything useful in my logs.

    #909620

    Hey TJ,

    Please send us a temporary admin login and login URL so that we can have a closer look. You can post the details in the Private Content section of your reply. Also please point out how and where we can reproduce the problem.

    Best regards,
    Rikard

    #910041

    I have the same issue with a customer and investigate since 10 hours. It is an Enfold issue but it is not the Calendar Integration.

    #910208

    Getting closer to it ;-)

    Twenty Seventeen:
    If you hook into wp_insert_post_data to dump data for debugging purpose you will see wp_insert_post_data is triggered twice if a woocommerce product (the ticket) is attached to event.

    Enfold:
    The second call to wp_insert_post_data for the product (the ticket) is not executed. Therefore my strong guess is the error happens during the first call to wp_insert_post_data which returns -1.

    Comparing the $_POST data there are 3 main differences between Enfold and Twenty Seventeen while saving the event:

    Twenty Seventeen:
    [_wp_http_referer] => /wp-admin/post.php?post=7245&action=edit&message=1
    [referredby] => https://domain.tld/wp-admin/post.php?post=7245&action=edit
    [_wp_original_http_referer] => https://domain.tld/wp-admin/post.php?post=7245&action=edit

    Enfold:
    [_wp_http_referer] => /wp-admin/post.php?post=7245&action=edit
    [referredby] => https://domain.tld/wp-admin/edit.php?post_type=tribe_events
    [_wp_original_http_referer] => https://domain.tld/wp-admin/edit.php?post_type=tribe_events

    But there are no differences in the query object (global $wp_query).

    The big question:
    – Does Enfold change something that Events Tickets Plus needs to save the product data
    or
    – Does Events Tickets Plus modify something to prevent Enfold from saving

    #910298

    I’ve also filed a bug over on Event Tickets Pro. They’ve reproduced the issue too: https://theeventscalendar.com/support/forums/topic/getting-a-1-screen-when-trying-to-publish-an-event-with-tickets/

    I also came across this issue in which they state that they are actively fixing the issue (I think): https://theeventscalendar.com/support/forums/topic/events-tickets-plus-15/#dl_post-1443869

    #910318

    @TJ i filled the report on behalf of my customer two weeks ago https://theeventscalendar.com/support/forums/topic/adding-new-event-causes-whites-screen/ and I am afraid Tribe is reffering to my report for the known bug :-(

    #910437

    Issue isolated.

    tl;dr
    1. Open /enfold/config-templatebuilder/avia-template-builder/php/meta-box.class.php
    2. Locate function handler_wp_insert_post_data near line 223
    3. Locate the code block if( ‘revision’ == $data[‘post_type’] ) { return $data; } within function handler_wp_insert_post_data
    4. Add the following code block after the code block located in #3:

    /*
     * Temporary fix for Enfold triggering the non catchable error -1 
     * after executing the check_ajax_referer (wordpress core function)
     * if a tribe event has a ticket attached (woocommerce product).
     *
     * @see https://kriesi.at/support/topic/error-saving-event-events-calendar-pro-event-tickets-pro/
     *
     * @todo Kriesi needs to implement a permanent fix
     */
    if( $_POST['post_type'] == 'tribe_events' && $postarr['post_type'] == 'product' ) {
    	$product_id = $postarr['ID'];
    	$ticket_product_ids = isset( $_POST['tribe-tickets']['list']) ? array_keys($_POST['tribe-tickets']['list']) : array();
    	if( in_array( $product_id, $ticket_product_ids ) ) {
    		return $data;
    	}
    }

    5. Save the file. You tribe events with attached tickets will save again.

    Short description

    Enfold introduced the function handler_wp_insert_post_data() in version 4.2.1. The call to check_ajax_referer() from within returns -1

    Detailed description

    The function handler_wp_insert_post_data() introduced in Enfold version 4.2.1 cares about Advanced Layout Builder Metaboxes attached to posts/pages. Posts/pages without ALB metaboxes are ignored. By default the posttype tribe_events does not support Enfold metaboxes and gets ignored by handler_wp_insert_post_data(). The plugin Tribe Event Tickets Plus allows to add tickets to events using WooCommerce. The posttype product used by WooCommerce supports Enfold metaboxes by default and gets handled by handler_wp_insert_post_data(). This is where the issue stems from.

    Saving an event with attached ticket will trigger the WordPress core filter wp_insert_post_data two times. The first call is for the event (tribe_events). The second call is for the ticket (product). The function handler_wp_insert_post_data() is hooked into the filter wp_insert_post_data and parses both save actions. The first call is ignored because the posttype tribe_events has no ALB metaboxes attached. The second call gets processed because the posttype product has ALB metaboxes attached. But because the save action has been initiated from an event (tribe_events) the nonce needed to pass the call to check_ajax_referer() is missing. Therefore the result of check_ajax_referer() is false and because check_ajax_referer() is set to die by default ($die = true) instead of returning the result WordPress dies and returns -1.

    Solution

    As a quick fix you can modify the function handler_wp_insert_post_data() in class MetaBoxBuilder as described above. What it does it to check the original posttype where the save action has been invoked from (tribe_events) and the posttype passed to handler_wp_insert_post_data(). If the original posttype is tribe_events and the posttype seen in $postarr is product a second check is performed. It will test whether the ID of the product matches any of the ticket (product) IDs attached to the event. If this is true the processing of function handler_wp_insert_post_data() is aborted and the original data are returned.

    Another solution might be to add ALB metaboxes to the posttype tribe_events using the filter avf_builder_boxes. However I did not test it because this won’t solve the root cause of the issue.

    @kriesi

    A permanent fix must work for tribe events with attached tickets regardless whether ALB metaboxes are attached or not. One way would be to introduce a new filter before calling check_ajax_referer() and to execute check_ajax_referer() conditionally. This would allow to move the logic of my fix into the config.php files of your plugin integrations.

    #910664

    Hi!

    We have open a ticket with our developers, so they can see if we will integrate on Core, or if they have to provide a different workaround.
    We will also update you with any results!

    Best regards,
    Basilis

    #912330

    Hi,

    Thank you for reporting this.

    I added a fix for the next update.

    Meanwhile please update /enfold/config-templatebuilder/avia-template-builder/php/meta-box.class.php around line 262

    
                check_ajax_referer( 'avia_nonce_save', 'avia-save-nonce' );
    

    with

    
    			if( false === check_ajax_referer( 'avia_nonce_save', 'avia-save-nonce', false ) )
    			{
    			     return $data;
    			}
    		
    

    Best regards,
    Günter

    #913674

    Thanks @mensmaximus and @guenter! Implemented temp fix from @guenter and it works.

    • This reply was modified 6 years, 10 months ago by TJ.
    #913769

    Hi,

    Great, glad you got it working and sorry for the problems. Please let us know if you should need any further help on the topic.

    Best regards,
    Rikard

    #915906

    This has been fixed by the Enfold Theme in version “2018 February 21st – Version 4.2.4” (https://kriesi.at/documentation/enfold/enfold-changelog/)

    #915921

    I don’t see an entry in the changelog regarding this issue

    #915922

    But the fix is there and I guess the changelog line is “- fixed: issue with 3rd party custom post types saving and ALB”

    #915925

    This would be absolutely inappropriate. It neither describes the issue nor does it contain any props to the person who found the core reason and provided a solution. (me ;-))

    #918086

    Hi,


    @kmindi
    Thanks for sharing and yes, that line refers to fix of this issue as well.


    @mensmaximus
    I believe our devs chose this description as the issue was affecting not only Events Calendar Pro but also other custom post types and we always appreciate your continuous contribution to our forum. You are usually the first one to come up with a solution when a sudden bug is introduced :) Would you like me to bring props matter to Kriesi’s attention?

    Cheers!
    Yigit

    #918102
    This reply has been marked as private.
    #918539

    Hi,


    @mensmaximus
    will inform Kriesi about this :)

    Best regards,
    Yigit

Viewing 18 posts - 1 through 18 (of 18 total)
  • You must be logged in to reply to this topic.