[wp-trac] [WordPress Trac] #36456: oEmbeds containing Emojis aren't cached if the meta_value column's charset is utf8 and not utf8mb4

WordPress Trac noreply at wordpress.org
Sat Apr 9 17:50:17 UTC 2016


#36456: oEmbeds containing Emojis aren't cached if the meta_value column's charset
is utf8 and not utf8mb4
--------------------------+------------------------------
 Reporter:  birgire       |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Embeds        |     Version:  4.4.2
 Severity:  normal        |  Resolution:
 Keywords:                |     Focuses:
--------------------------+------------------------------

Comment (by birgire):

 We could additionally look at the {{{$cache}}} value to see if
 {{{$cachekey}}} already exists.

 The two updated suggestions are now:

 1)

 {{{
 // Maybe cache the result
 if ( $html ) {

     $updated_cachekey = update_post_meta( $post_ID, $cachekey, $html );

     if( ! $updated_cachekey && ! $cache ) {
         update_post_meta( $post_ID, $cachekey, '{{unknown}}' );
     }

     update_post_meta( $post_ID, $cachekey_time, time() );

 } elseif ( ! $cache ) {
     update_post_meta( $post_ID, $cachekey, '{{unknown}}' );
 }

 }}}


 or 2)

 {{{
 // Maybe cache the result
 if ( $html ) {

     global $wpdb;

     // Encode Emojis if the charset of the meta_value column is 'utf8'
 instead of 'utf8mb4'
     if (    method_exists( $wpdb, 'get_col_charset' )
          && 'utf8' === $wpdb->get_col_charset( $wpdb->postmeta,
 'meta_value' )
          && function_exists( 'wp_encode_emoji' )
     ) {
         $html = wp_encode_emoji( $html );
     }

     $updated_cachekey = update_post_meta( $post_ID, $cachekey, $html );

     if( ! $updated_cachekey && ! $cache ) {
         update_post_meta( $post_ID, $cachekey, '{{unknown}}' );
     }

     update_post_meta( $post_ID, $cachekey_time, time() );

 } elseif ( ! $cache ) {
     update_post_meta( $post_ID, $cachekey, '{{unknown}}' );
 }

 }}}

--
Ticket URL: <https://core.trac.wordpress.org/ticket/36456#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list