[wp-hackers] Alternative or reactivation for get_blog_info()
Frank Bueltge
frank at bueltge.de
Thu Jul 25 08:05:50 UTC 2013
Hi Nacin,
thanks for the feedback and declare the points to deprecated.
I think a Query was the best solution, useful and flexible.
But maybe it is a small chance to reduce the get_blog_list() to the
important parts, get blog list ID and not more to reduce to a fast simple
function.
Best
Frank
On Thu, Jul 25, 2013 at 8:37 AM, Andrew Nacin <wp at andrewnacin.com> wrote:
> On Wed, Jul 24, 2013 at 5:18 AM, Malte Witt <m.witt at ia-sh.de> wrote:
>
> > I stumbled upon this a few days ago, too.
> >
> > In my opinion get_blog_list() is perfectly fine. The Codex and the source
> > is just saying: "For performance reasons this function is not
> recommended."
> > That's true for installations with thousands of blogs. But I think most
> > multisite installations out there in the real world have 3 to 100 sites
> and
> > they have a perfect valid usecase for get_blog_list().
> >
> > If there is a no other reason why the function is deprecated (and I can't
> > see any) I would say just reactivate it and place a big warning sign in
> the
> > Codex, that this function shouldn't be used in super-large multisite
> > installations.
> >
> > In short: +1 for reactivation of get_blog_list().
>
>
> It's really just a poorly written function. No caching, no LIMIT (but does
> "limiting" with an array_slice()), hits every site's posts table, etc. This
> is one of the more dangerous functions performance-wise in core (probably
> the most dangerous) because of how nasty it can be. If you have thousands
> of sites, you'll run out of memory. If you have hundreds of sites, it could
> take a long while to run. Even if you only have a few dozen sites, if you
> have large post tables, this could take a few seconds to calculate. If it
> actually did a proper LIMIT for both $start and $num, it'd be a lot better
> off, but it's still pretty lame.
>
> I've always had in my head a more robust WP_Site_Query, to be modeled after
> WP_User_Query, WP_Comment_Query, and WP_Query. Fully functional arguments,
> proper limiting, only touching the blogs table (post count is superflous —
> query it yourself only if or when you need it), having numerous filters and
> built-in caching (WP_Comment_Query does this well, IIRC), declining to do
> anything when wp_is_large_network(), etc. Even though we've yet to get
> around to making such a replacement, I have no regrets for us marking
> get_blog_list() deprecated. What a terrible function.
>
> Nacin
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
More information about the wp-hackers
mailing list