Title: Duplicate Event &#8211; _oembed_ Postmeta Causing Database Error
Last modified: May 3, 2025

---

# Duplicate Event – _oembed_ Postmeta Causing Database Error

 *  [P.E.A. Lutz](https://wordpress.org/support/users/misfist/)
 * (@misfist)
 * [1 year, 1 month ago](https://wordpress.org/support/topic/duplicate-event-_oembed_-postmeta-causing-database-error/)
 * I’m getting an error when using the duplicate function to duplicate an event 
   that contains a YouTube video block.
 * **Problem Seems to Be**
 * The `_oembed_...` meta key contains **unescaped HTML** with **apostrophes and
   quotes**, and the SQL statement being constructed likely does something like:
 * `INSERT INTO wp_postmeta (post_id, meta_key, meta_value) VALUES (123, '_oembed_...','
   Video can't be...')`
 * That **`'`** in `can't` isn’t escaped, so it breaks the query.
 * **Error Log**
 *     ```wp-block-code
       WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 't be loaded because JavaScript is disabled:22448, '_oembed_674b1ab4ab02f7731dd6c3290b28c534', '<div class="container-lazyload preview-lazyload container-youtube js-lazyload--not-loaded"><a href="https://www.youtube.com/watch?v=QOgzEHWwR6I" class="lazy-load-youtube preview-lazyload preview-youtube" data-video-title="War Journalism from Vietnam to Gaza – How War Coverage Impacts U.S. Foreign Policy" title="Play video &quot;War Journalism from Vietnam to Gaza – How War Coverage Impacts U.S. Foreign Policy&quot;">https://www.youtube.com/watch?v=QOgzEHWwR6I</a><noscript>Video can't be loaded because JavaScript is disabled: <a href="https://www.youtube.com/watch?v=QOgzEHWwR6I" title="War Journalism from Vietnam to Gaza – How War Coverage Impacts U.S. Foreign Policy">War Journalism from Vietnam to Gaza – How War Coverage Impacts U.S. Foreign Policy (https://www.youtube.com/watch?v=QOgzEHWwR6I)</a></noscript></div>'), (22448, '_oembed_time_674b1ab4ab02f7731dd6c3290b28c534', '1746134347') made by require_once('wp-admin/admin.php'), require_once('wp-load.php'), require_once('wp-config.php'), require_once('wp-settings.php'), do_action('wp_loaded'), WP_Hook->do_action, WP_Hook->apply_filters, em_init_actions_start, EM_Event->duplicate
       ```
   
 * **Temporary Fix**
 * I added a filter to prevent duplicating `_oembed_` postmeta fields (they aren’t
   needed anyway), which seems to be working.
 *     ```wp-block-code
       /*** Remove oembed postmeta* Don't duplicate postmeta with key _oembed_ when duplicating an event** @param \EM_Event $original* @param \EM_Event $duplicate** @return void*/function remove_oembed_meta( \EM_Event $original, \EM_Event $duplicate ): void {   $meta_keys = get_post_custom_keys( $duplicate->post_id );   if ( empty( $meta_keys ) ) {      return;   }   foreach ( $meta_keys as $meta_key ) {      if ( strpos( $meta_key, '_oembed_' ) === 0 ) {        delete_post_meta( $duplicate->post_id, $meta_key );     }   }}\add_action( 'em_event_duplicate_pre', __NAMESPACE__ . '\remove_oembed_meta', 10, 2 );
       ```
   
    -  This topic was modified 1 year, 1 month ago by [P.E.A. Lutz](https://wordpress.org/support/users/misfist/).

The topic ‘Duplicate Event – _oembed_ Postmeta Causing Database Error’ is closed
to new replies.

 * ![](https://ps.w.org/events-manager/assets/icon-256x256.png?rev=3550347)
 * [Events Manager - Calendar, Bookings, Tickets, and more!](https://wordpress.org/plugins/events-manager/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/events-manager/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/events-manager/)
 * [Active Topics](https://wordpress.org/support/plugin/events-manager/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/events-manager/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/events-manager/reviews/)

## Tags

 * [database](https://wordpress.org/support/topic-tag/database/)
 * [duplicate](https://wordpress.org/support/topic-tag/duplicate/)

 * 0 replies
 * 1 participant
 * Last reply from: [P.E.A. Lutz](https://wordpress.org/support/users/misfist/)
 * Last activity: [1 year, 1 month ago](https://wordpress.org/support/topic/duplicate-event-_oembed_-postmeta-causing-database-error/)
 * Status: not resolved