WordPress.org

Make WordPress Core

Ticket #33885: 33885.5.2.diff

File 33885.5.2.diff, 684 bytes (added by lbenicio, 3 years ago)

add unit test

Line 
1@@ -652,6 +668,10 @@ function meta_form( $post = null ) {
2        $keys = apply_filters( 'postmeta_form_keys', null, $post );
3 
4        if ( null === $keys ) {
5+      $keys = wp_cache_get( 'postmeta_form_keys', 'posts' );
6+       }
7+               
8+       if ( ! $keys ) {
9                /**
10                 * Filters the number of custom fields to retrieve for the drop-down
11                 * in the Custom Fields meta box.
12@@ -668,7 +688,10 @@ function meta_form( $post = null ) {
13                        ORDER BY meta_key
14                        LIMIT %d";
15                $keys  = $wpdb->get_col( $wpdb->prepare( $sql, $wpdb->esc_like( '_' ) . '%', $limit ) );
16+        wp_cache_set( 'postmeta_form_keys', $keys, 'posts' );
17        }
18
19+    assertSame(wp_cache_get( 'postmeta_form_keys', 'posts' );, $keys)