• Resolved massimomegistus

    (@massimomegistus)


    Hello!
    In single tribe_events pages, Query Monitor reports that this query occurs from 50 to 60 times:
    SELECT meta_value FROM wdws923_postmeta WHERE post_id = {$post->ID} AND meta_key = ‘_EventVenueID’

    Caller:
    Tribe__Events__Integrations__WPML__Meta

    tribe_has_venue()
    4 calls
    Tribe__Events__JSON_LD__Event->get_data()
    1 calls
    Tribe__Template->template_safe_include()
    2 calls
    tribe_get_phone()
    2 calls
    tribe_get_venue_website_link()
    2 calls
    tribe_get_venue_link()
    2 calls
    tribe_get_address()
    10 calls
    tribe_get_full_address()
    2 calls
    tribe_get_city()
    8 calls
    tribe_get_region()
    5 calls
    tribe_get_zip()
    8 calls
    tribe_get_country()
    8 calls
    tribe_get_venue()
    6 calls
Viewing 11 replies - 1 through 11 (of 11 total)
  • Thread Starter massimomegistus

    (@massimomegistus)

    A possibile dirty solution could be cashing the main event venue id in a global variable: this way, tribe_get_event_meta is called once instead of sixty times.

    src/functions/template-tags/venue.php

    function tribe_get_venue_id( $postId = null ) {
    $postId = Tribe__Events__Main::postIdHelper( $postId );
    if ( tribe_is_venue( $postId ) ) {
    return $postId;
    } else {
    /**
    * Allow for customizing the Venue ID retrieved for this item.
    *
    * @since ??
    * @since 4.5.12 Added docblock and venue ID to filter.
    *
    * @param int $venue_id The Venue ID for the specified event.
    * @param int $postId The ID of the event whose venue is being looked for.
    */

    /*
    * bnkr: cash current post venue_id
    */
    global $wp_query, $main_post_venue_id;
    if (is_singular( Tribe__Events__Main::POSTTYPE ) && $wp_query->query_vars[‘p’] === $postId) {
    if (!$main_post_venue_id) {
    $main_post_venue_id = apply_filters( ‘tribe_get_venue_id’, tribe_get_event_meta( $postId, ‘_EventVenueID’, true ), $postId );
    }
    return $main_post_venue_id;
    } else {
    return apply_filters( ‘tribe_get_venue_id’, tribe_get_event_meta( $postId, ‘_EventVenueID’, true ), $postId );
    }

    // return apply_filters( ‘tribe_get_venue_id’, tribe_get_event_meta( $postId, ‘_EventVenueID’, true ), $postId );
    }
    }

    Without this snippet:
    Memory usage:
    94.225.144 byte (89,9 MB)
    70,2% of 128 MB WordPress limit
    Database queries
    0,0265s
    Total: 220
    With this snippet:
    Memory usage:
    92.065.728 byte (87,8 MB)
    68,6% of 128 MB WordPress limit
    Database queries
    0,0219s
    Total: 161

    Plugin Support Abz

    (@abzlevelup)

    Hi @massimomegistus, thanks for reaching out to us. Appreciate you providing more information and findings here.

    Could you try reaching out to WPML Support Team as well in regard to this? Rest assured that we’d be helping you out on our end as well, and I already shared with our team the information you provided here.

    I’d get back to you as soon as I know more.
    Have a great day.

    Best,
    Abz

    Thread Starter massimomegistus

    (@massimomegistus)

    Hello @abzlevelup, glad to hear that.
    I haven’t contacted the wpml team yet but I will for sure.

    I’ve just noticed that, whether WPML is active, when updating an Event (using Gutenberg Editor) this warning appears:

    “Aggiornamento fallito. Impossibile aggiornare il valore meta di _EventVenueID nel database.”

    In english:
    “Update failed. Failed to update _EventVenueID meta value in database.”

    Is this a known issue?

    Thank you.

    Thread Starter massimomegistus

    (@massimomegistus)

    Hello,
    after further tests I can say that the exact warning in english is “Update failed. Could not update the meta value of _EventVenueID in database.”.
    It occurs only when the event date or time are updated, but not when updating Event content. Anyway, everything is saved as expected.
    As a side note: I’m using WPML Advanced Translation Editor (default and recommended option)
    https://wpml.org/documentation/translating-your-contents/translation-editor-options/
    The connected Venue is translated in both the languages on the site, and so the event.
    The warning appears even in events that exist in primary language only and doesn’t occurs if WPML is not active.

    Massimo

    Thread Starter massimomegistus

    (@massimomegistus)

    Php warnings in debug.log

    1) After opening a Edit Event Screen (Gutenberg editor)
    [08-Jul-2022 06:50:03 UTC] PHP Notice: Undefined index: post_id in /wp-content/plugins/the-events-calendar/src/views/blocks/event-website.php on line 29

    2) After changing Event end time and updating the event
    [08-Jul-2022 06:50:47 UTC] PHP Warning: array_filter() expects parameter 1 to be array, bool given in /wp-content/plugins/the-events-calendar/src/Tribe/Editor/Meta.php on line 150
    [08-Jul-2022 06:50:51 UTC] PHP Notice: Undefined index: post_id in /wp-content/plugins/the-events-calendar/src/views/blocks/event-website.php on line 29

    3) The warning “Update failed. Could not update the meta value of _EventVenueID in database.” appears in the Edit Event Screen

    Thread Starter massimomegistus

    (@massimomegistus)

    I’ve cloned the application on stage server (php 7.4.30, 7.4.21 in local dev)

    The warning appears in the same way, but php logs are different

    1) After opening a Edit Event Screen (Gutenberg editor)
    [08-Jul-2022 07:54:08 UTC] PHP Notice: Undefined index: post_id in /wp-content/plugins/the-events-calendar/src/views/blocks/event-website.php on line 29

    2) After changing Event end time and updating the event
    [08-Jul-2022 07:54:09 UTC] PHP Notice: Undefined property: stdClass::$status_id in /wp-content/plugins/sitepress-multilingual-cms/classes/ATE/class-wpml-tm-ate.php on line 57
    [08-Jul-2022 07:54:58 UTC] PHP Notice: Undefined index: post_id in /wp-content/plugins/the-events-calendar/src/views/blocks/event-website.php on line 29
    [08-Jul-2022 07:54:59 UTC] PHP Notice: Undefined property: stdClass::$status_id in /wp-content/plugins/sitepress-multilingual-cms/classes/ATE/class-wpml-tm-ate.php on line 57

    3) The warning “Update failed. Could not update the meta value of _EventVenueID in database.” appears in the Edit Event Screen`

    Plugin Support Abz

    (@abzlevelup)

    Hello @massimomegistus, appreciate your patience here and for investigating further of this issue. I would definitely pass along these details to our team and devs.

    Moreover, as a workaround could you try updating the file here:
    src/Tribe/Integrations/WPML/Meta.php
    with this code here:
    https://github.com/the-events-calendar/the-events-calendar/pull/3888/commits/281ab670a46124915427eb3b8c918a8262ca6b9a

    One of the WPML dev suggested a fix that could potentially help resolve this issue.

    Let me know how it goes on your end.

    Best,
    Abz

    Thread Starter massimomegistus

    (@massimomegistus)

    Hello @abzlevelup ,
    I confirm that the fix solves the issue!

    Good job!
    Thank you!

    Plugin Support Abz

    (@abzlevelup)

    Hi @massimomegistus, that’s awesoooome! Good to know, and appreciate you confirming this.

    If you have some time to review, that would be amazing.
    https://www.ads-software.com/support/plugin/the-events-calendar/reviews/

    Have a great day!

    Best,
    Abz

    Plugin Support Abz

    (@abzlevelup)

    Hi @massimomegistus,

    We haven’t heard from you in a while, so I’m going to mark this as resolved. Feel free to start a new thread if you have any more questions.

    If you have some time to review, that would be amazing.
    https://www.ads-software.com/support/plugin/the-events-calendar/reviews/

    Have a great week ahead.

    Best,
    Abz

    Plugin Support Gladys

    (@greventscalendar)

    We wanted to let you know with our latest release of?The Events Calendar 6.0.1; we resolved an issue that was causing the duplicate queries reported in Query Monitor. Be sure to review our full?Release Notes?for more details and update your plugin at your earliest convenience.
    ?
    As always, we suggest testing updates on a staging site first and having a recent backup, but it should all be smooth sailing. If you implemented any workarounds, you may remove them after updating the plugins.
    ?
    If you still have issues after updating to the latest releases, please open a new support thread and include any specific details, with any screenshots if possible.
    ?
    Have a great day,?
    Gladys

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘Single event page: duplicate query’ is closed to new replies.