[wp-trac] [WordPress Trac] #50617: REST API: Add modified_before and modified_after to WP_REST_Request attributes

WordPress Trac noreply at wordpress.org
Tue Jan 12 17:28:07 UTC 2021


#50617: REST API: Add modified_before and modified_after to WP_REST_Request
attributes
---------------------------+---------------------
 Reporter:  claytoncollie  |       Owner:  (none)
     Type:  enhancement    |      Status:  new
 Priority:  normal         |   Milestone:  5.7
Component:  REST API       |     Version:  4.7
 Severity:  normal         |  Resolution:
 Keywords:  has-patch      |     Focuses:
---------------------------+---------------------
Changes (by johnbillion):

 * keywords:  has-patch dev-feedback => has-patch


Comment:

 The `post_modified` and `post_modified_gmt` fields in the database are not
 indexed. I've run into performance problems in the past when querying by
 these fields, and ended up adding a new index similar to
 `type_status_date` that used `post_modified` in place of `post_date`.
 Worth mentioning in the dev note at least so users are aware.

 With the change to the date query structure there's a slight change to the
 resulting SQL when querying for both `before` and `after`. It does not
 functionally alter the query. The `>` and `<` order is reversed and a
 surrounding bracket pair is removed.

 Before:

 {{{
 SELECT SQL_CALC_FOUND_ROWS wp_posts.ID
 FROM wp_posts
 WHERE 1=1
 AND (
     (
         wp_posts.post_date > '2020-01-01 00:00:00'
         AND wp_posts.post_date < '2020-12-31 23:59:59'
     )
 )
 AND wp_posts.post_type = 'post'
 AND ((wp_posts.post_status = 'publish'))
 ORDER BY wp_posts.post_date DESC
 LIMIT 0, 10
 }}}

 After:

 {{{
 SELECT SQL_CALC_FOUND_ROWS wp_posts.ID
 FROM wp_posts
 WHERE 1=1
 AND (
     wp_posts.post_date < '2020-12-31 23:59:59'
     AND wp_posts.post_date > '2020-01-01 00:00:00'
 )
 AND wp_posts.post_type = 'post'
 AND ((wp_posts.post_status = 'publish'))
 ORDER BY wp_posts.post_date DESC
 LIMIT 0, 10
 }}}

 I don't think this is a problem. WordPress doesn't guarantee that its SQL
 queries never change.

 Going to look at why the CI is failing on the PR.

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


More information about the wp-trac mailing list