[wp-hackers] wp_get_sites cache/transient

Tom Barrett tcbarrett at gmail.com
Wed Feb 19 13:04:02 UTC 2014


No caching plugins active to my knowledge.

This is the list of all directories in /plugins/

all-in-one-seo-pack
broken-site-checker
debug-bar
debug-bar-extender
force-strong-passwords
gplus-comments
image-widget
limit-login-attempts
mce-table-buttons
media-links
meta-box
multiple-post-thumbnails
option-tree
plugin-toggle
posts-to-posts
redirection
regenerate-thumbnails
social-media-icons
user-switching
wordpress-importer
gravityforms
my-blog-management

Not all are in use. There are no mu-plugins. The bottom one is the plugin
calling wp_get_sites() (I grepped /wp-content/).

Anyway, I see that I have hit some edge case of my own making. Thanks for
trying to help. I'll be quiet now.

Hopefully I'll get the time to either move off the edge, or make it
re-creatable and submit as a bug (be that core, plugin or theme).




On 19 February 2014 12:48, Dion Hulse (dd32) <wordpress at dd32.id.au> wrote:

> Well, if there's no caches defined, then it's not a WordPress caching issue
> :)
>
> Looking at wp_get_sites(), there is indeed no caching at all (as Otto
> rightly pointed out), so even if WordPress DID have caching enabled it
> wouldn't do anything.
>
> So you've got a fault in either:
> a) MySQL returning the wrong data - or caching the return (unlikely)
> or
> b) Something loaded in WordPress which is caching the query.
> WordPress doesn't have query caching, so that points to a plugin or custom
> DB dropin. W3 Total cache comes to mind as one plugin which does do query
> caching.
>
>
>
>
> On 19 February 2014 23:33, Tom Barrett <tcbarrett at gmail.com> wrote:
>
> > There are no cache defines in wp-config.php
> >
> > Neither memcache, nor apc are installed on the host.
> >
> > I used the example of deleting table rows to emphasize that there is no
> row
> > (with 'deleted'=1) in the database.
> >
> > So, I can see no reason why anything other than WordPress is caching the
> > existence of the blog.
> >
> >
> > On 19 February 2014 12:21, Dion Hulse (dd32) <wordpress at dd32.id.au>
> wrote:
> >
> > > If the database has been manually altered, and you're running an object
> > > cache.. the simplest solution is to just reload your object cache (ie.
> > > reload php-fpm, clear memcache, clear apc, whatever) and let WordPress
> > fill
> > > the caches back up.
> > >
> > > If it's a development platform that shouldn't be an issue - and tell
> the
> > > other developers not to alter raw data while there's caching involved
> > next
> > > time..
> > >
> > >
> > > On 19 February 2014 23:16, Tom Barrett <tcbarrett at gmail.com> wrote:
> > >
> > > > It's not that it is set to be deleted, it is that the row in the
> > database
> > > > has been deleted and the tables dropped (probably via the 'delete
> site'
> > > > network admin menu, but it's a dev environment with other
> developers).
> > > >
> > > > I've not had time to look into something re-createable, but to
> > illustrate
> > > > my point, this would be the pseudo-code steps to replicate the issue
> > (the
> > > > aim being here to explain that there is no row in wp_blogs to match
> the
> > > > blogid that the function returns).
> > > >
> > > > 1. Set up WP Network
> > > > 2. Create 2 new blogs (you now have blog IDs 1,2,3)
> > > > 3. DELETE from wp_blogs WHERE blog_id=2
> > > > 4. DROP tables like 'wp_2%'
> > > > 5. $sites = wp_get_sites();
> > > >
> > > > At this point, assuming the issue is that simple, $sites=array( 1,
> 2, 3
> > > ),
> > > > even though blog 2 has been deleted.
> > > >
> > > > That's why I assumed that the SQL cached somewhere.
> > > >
> > > > I'll add a little context here, for any googling:
> > > > This is the code:
> > > > function tcb_find_blogs_to_archive(){
> > > >   $blogs   = wp_get_sites();
> > > >   $archive = array();
> > > >   foreach( $blogs as $blogid => $blog ){
> > > >     $state = get_blog_option( $blogid, 'my_blog_state', 'live' );
> > > >     if( $state == 'archive' ){
> > > >       $archive[$blogid] = $blog;
> > > >     }
> > > >   }
> > > >
> > > >   return $archive;
> > > > }
> > > >
> > > > Generates this error:
> > > > WordPress database error Table 'testdb.wp_4_options' doesn't exist
> for
> > > > query SELECT option_value FROM wp_4_options WHERE option_name =
> > > > 'my_blog_state' LIMIT 1 made by require_once('wp-admin/admin.php')...
> > > >
> > > > I don't understand how the 'deleted' argument would make any
> difference
> > > in
> > > > this case (unless it is being cached somewhere)?
> > > >
> > > > Or am I just not grokking this? ;p
> > > >
> > > >
> > > >
> > > >
> > > > On 19 February 2014 09:55, Otto <otto at ottodestruct.com> wrote:
> > > >
> > > > > The wp_get_sites function isn't cached. It selects the data
> directly
> > > from
> > > > > the database. You can see the code yourself at the bottom of
> > > > > wp-includes/ms-functions.php.
> > > > >
> > > > > If you want it to not return deleted sites, you need to pass it
> > > deleted=0
> > > > > as an argument.
> > > > >
> > > > > -Otto
> > > > >
> > > > >
> > > > >
> > > > > On Wed, Feb 19, 2014 at 3:46 AM, Tom Barrett <tcbarrett at gmail.com>
> > > > wrote:
> > > > >
> > > > > > Can anyone point me to where the data returned by this function
> is
> > > > > cached?
> > > > > >
> > > > > > It is continuing to include a blog that was deleted days ago, I'm
> > > > having
> > > > > to
> > > > > > check against get_blog_details() in order to stop SQL errors
> trying
> > > to
> > > > > look
> > > > > > up against tables that don't exist.
> > > > > >
> > > > > > Thanks!
> > > > > >
> > > > > > --
> > > > > > http://www.tcbarrett.com | http://gplus.to/tcbarrett |
> > > > > > http://twitter.com/tcbarrett
> > > > > > _______________________________________________
> > > > > > wp-hackers mailing list
> > > > > > wp-hackers at lists.automattic.com
> > > > > > http://lists.automattic.com/mailman/listinfo/wp-hackers
> > > > > >
> > > > > _______________________________________________
> > > > > wp-hackers mailing list
> > > > > wp-hackers at lists.automattic.com
> > > > > http://lists.automattic.com/mailman/listinfo/wp-hackers
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > http://www.tcbarrett.com | http://gplus.to/tcbarrett |
> > > > http://twitter.com/tcbarrett
> > > > _______________________________________________
> > > > wp-hackers mailing list
> > > > wp-hackers at lists.automattic.com
> > > > http://lists.automattic.com/mailman/listinfo/wp-hackers
> > > >
> > > _______________________________________________
> > > wp-hackers mailing list
> > > wp-hackers at lists.automattic.com
> > > http://lists.automattic.com/mailman/listinfo/wp-hackers
> > >
> >
> >
> >
> > --
> > http://www.tcbarrett.com | http://gplus.to/tcbarrett |
> > http://twitter.com/tcbarrett
> > _______________________________________________
> > wp-hackers mailing list
> > wp-hackers at lists.automattic.com
> > http://lists.automattic.com/mailman/listinfo/wp-hackers
> >
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>



-- 
http://www.tcbarrett.com | http://gplus.to/tcbarrett |
http://twitter.com/tcbarrett


More information about the wp-hackers mailing list