• Resolved Nino Mihovilic

    (@ninomiho)


    When using The Events Calendar plugin and visiting the customizer /wp-admin/customize.php?return=%2Fwp-admin%2Fthemes.php with any theme that supports the customizer, I encounter the “Allowed memory size” error in /wp-includes/class-wpdb.php. I attempted to set the memory limit to 512MB, but the error still occurs. I tested it with the Astra theme and other themes on a clean install. As soon as I disable the plugin it works again.

    Hi!

    System information:

    • This topic was modified 6 months ago by Yui. Reason: pi removed
Viewing 3 replies - 1 through 3 (of 3 total)
  • Atousa Najafi

    (@atousanajafi)

    Hi @ninomiho,

    Please do not share any sensitive information, including system information, in WordPress Forums; this is for us to follow the WordPress Forum Guidelines. If possible, edit the ticket and remove the system information, or ask the moderator to do this.

    I’m unable to reproduce this issue on my website with Astra or other themes, so there could be a server-related issue. Have you tried contacting your hosting provider? Are there any other errors in the log file?
    Does increasing the memory to 1024M solve the problem?

    Thread Starter Nino Mihovilic

    (@ninomiho)

    Hi Atousa!

    The issue occurs because I have over 2,000 events in the plugin. I’ve limited the tribe_events per page to 10 in the customizer, and now it works. Here is the code in case someone else encounters the same issue.

    /**
    * Cap Events Calendar queries for customizer preview for memory issues.
    *
    * @param WP_Query $current_query The current query object.
    *
    * @return void
    */
    function mc_limit_tribe_queries( $current_query ) {
    if ( ! ( $current_query instanceof WP_Query ) ) {
    return;
    }
    if ( 'tribe_events' !== $current_query->get( 'post_type' ) ) {
    return;
    }

    if ( ! is_customize_preview() ) {
    return;
    }

    $posts_per_page = (int) $current_query->get( 'posts_per_page' );
    if ( $posts_per_page <= 0 || $posts_per_page > 10 ) {
    $current_query->set( 'posts_per_page', 10 );
    }

    $current_query->set( 'no_found_rows', true );
    $current_query->set( 'update_post_meta_cache', false );
    $current_query->set( 'update_post_term_cache', false );
    }
    add_action( 'pre_get_posts', 'mc_limit_tribe_queries', 9 );

    I’ve reported the topics to the moderators to remove the system information from my first message.

    Plugin Support tristan083

    (@tristan083)

    Hi @ninomiho ,

    Thank you for your message.

    We’re glad to hear that you were able to sort this one out, and we appreciate you sharing your code/solution.

    I’ll be closing this thread, as there are no further actions needed, but please do not hesitate to bump a new thread on our way if you have further questions/concerns. This is for us to track down topics/issues efficiently and for us to adhere to the WordPress Forum Guidelines.

    If you have some time to review, that would be amazing!
    https://ww.wp.xz.cn/support/plugin/the-events-calendar/reviews/

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Customizer Memory Error’ is closed to new replies.