Skip to:
Content

bbPress.org

Opened 3 years ago

Closed 3 years ago

#3015 closed defect (fixed)

`get_blog_details()` will be deprecated in WordPress 4.8

Reported by: netweb Owned by: netweb
Milestone: 2.6 Priority: normal
Severity: normal Version:
Component: Tools - Unit Tests Keywords: needs-patch
Cc:

Description (last modified by netweb)

Via https://make.wordpress.org/core/2016/11/04/multisite-focused-changes-in-4-7/


get_blog_details() replaced with get_site()
A lot of progress has been made over the last few releases to get things in place for this transition. Now that WP_Site and WP_Network objects exist and are accessible with functions like get_site() and get_network(), they can be implemented throughout core.

In WordPress 4.7, get_blog_details() was replaced throughout core code with the modern get_site(). The roadmap for this includes deprecating get_blog_details() in WordPress 4.8, so take this cycle as a chance to move your code in that direction.

get_site() is often a direct replacement, though get_sites() can also be used to query for sites when an ID is not available.

See #WP37102 for details on this change.

The bbPress PHPUnit test suite uses get_blog_details() in the following locations:

https://bbpress.trac.wordpress.org/browser/trunk/tests/phpunit/includes/testcase.php#L282
https://bbpress.trac.wordpress.org/browser/trunk/tests/phpunit/includes/testcase.php#L287

Related: #BuddyPress7326

Change History (4)

#1 @netweb
3 years ago

  • Description modified (diff)

#2 follow-up: @johnjamesjacoby
3 years ago

For our tests, get_sites() is comparable, but this means tests will fail on lesser WordPress versions without that function.

Thoughts? Should we duplicate the tests for each, or just add function_exists checks?

#3 in reply to: ↑ 2 @netweb
3 years ago

  • Milestone changed from Awaiting Review to 2.6

Replying to johnjamesjacoby:

For our tests, get_sites() is comparable, but this means tests will fail on lesser WordPress versions without that function.

Thoughts? Should we duplicate the tests for each, or just add function_exists checks?

We've now a minimum WordPress version of 4.7, so that's not an issue anymore.

That said, I'll follow BP's lead per buddypress:changeset:11254 and rely on WPs go_to() method.

#4 @netweb
3 years ago

  • Owner set to netweb
  • Resolution set to fixed
  • Status changed from new to closed

In 6231:

Tests: Rely on WP Core's version of go_to().

Our version of go_to(), inherited from BuddyPress was very messy, and since it was copied a few years ago, it has been refactored in WordPress. We can remove this duplication which makes for a cleaner method, and rely on the upstream version.

This also helps avoid false positives in tools that check for use of deprecated WordPress functions.

There was a conditional block in the old go_to() that was for compatibility with WordPress <3.9.

See also: buddypress:changeset:11254

Fixes #3015.
Props DJPaul, netweb.

Note: See TracTickets for help on using tickets.