[wp-trac] [WordPress Trac] #38866: Custom CSS generates an update SQL query on every front end request

WordPress Trac noreply at wordpress.org
Sat Nov 19 19:56:29 UTC 2016


#38866: Custom CSS generates an update SQL query on every front end request
--------------------------+------------------------------
 Reporter:  bradyvercher  |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Themes        |     Version:
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |     Focuses:
--------------------------+------------------------------
Changes (by bradyvercher):

 * keywords:   => has-patch


Comment:

 [attachment:38866.diff] does a few things:

 * Checks to make sure `$post_id` is not `-1` before calling `get_post()`
 to eliminate an extra SELECT query.
 * Checks to be sure the cached post ID hasn't changed before calling
 `set_theme_mod()`, which eliminates the UPDATE query and a SHOW FULL
 COLUMNS query.
 * Changes the `number` query arg to `posts_per_page`. Neither seem to do
 anything when `is_singular` is true, but I don't think `number` is valid.

 To test the patch:

 1. Set a header image and ensure the `header_image_data` theme mod exists.
 2. Delete the `custom_css` post.

 Every request on the front end should execute an UPDATE query. From what I
 can tell, this would affect any install that upgrades to 4.7 with a header
 image, as well as new installs that set a header image. The extra queries
 would continue running until the custom CSS setting is modified in the
 customizer.

 After applying the patch, the first request will execute the UPDATE query
 if the `custom_css_post_id` doesn't exist or has an invalid post ID, but
 subsequent requests should have 3 fewer queries.

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


More information about the wp-trac mailing list