[wp-trac] [WordPress Trac] #40201: Use get_site in clean_blog_cache

WordPress Trac noreply at wordpress.org
Tue Apr 4 21:52:56 UTC 2017


#40201: Use get_site in clean_blog_cache
-------------------------------------------------+-------------------------
 Reporter:  spacedmonkey                         |       Owner:
     Type:  enhancement                          |      Status:  new
 Priority:  normal                               |   Milestone:  Awaiting
Component:  Networks and Sites                   |  Review
 Severity:  normal                               |     Version:
 Keywords:  has-patch has-unit-tests dev-        |  Resolution:
  feedback                                       |     Focuses:  multisite
-------------------------------------------------+-------------------------

Comment (by flixos90):

 +1 for this enhancement.

 I just reviewed the latest patch and noticed that it doesn't handle the
 case where a site has just been deleted (`get_site()` will return null
 when passing an ID to it then). To fix that, we can use the logic that is
 currently part of `refresh_blog_details()`. It could probably be removed
 from that function afterwards.
 Also I don't think we need to check `is_object( $blog ) || is_int( $blog
 )` - due to the documented parameter we can simply pass `$blog` through
 `get_site()`. If the result is empty and `$blog` is numeric, the logic I
 mentioned above can be used to create a fake object.

 There's something else to consider though: Maybe we should hold off with
 that enhancement until the changes for `get_blog_details()` have been
 merged (see #40180 and #40228 for background). With that, and with
 removing the `blog-id-cache` lookup in `get_blog_id_from_url()` (which
 doesn't make sense to have in there anymore, now that `WP_Site_Query`
 results are cached anyway; there's no ticket for that yet though) we don't
 need to use any of those weird caches anymore that consist of domain and
 path. That means that the only part of `clean_blog_cache()` that needs a
 full object would be the action hook. Not sure if we can work around it
 completely, but we could definitely optimize the `clean_blog_cache()`
 function even more once those changes are in place.

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


More information about the wp-trac mailing list