Make WordPress Core

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#36707 closed enhancement (fixed)

Add pre_get_blogs_of_user filter.

Reported by: nerrad's profile nerrad Owned by: jeremyfelt's profile jeremyfelt
Milestone: 4.6 Priority: normal
Severity: normal Version: 3.0
Component: Users Keywords: has-patch has-unit-tests
Focuses: multisite Cc:

Description

See original discussion on #31746

The filter has been broken out into its own ticket so that discussion on longer term improvement of get_blogs_of_user() can be continued there.

See https://core.trac.wordpress.org/attachment/ticket/31746/31746.3.diff for patch.

Attachments (1)

36707.diff (1015 bytes) - added by jeremyfelt 8 years ago.

Download all attachments as: .zip

Change History (9)

This ticket was mentioned in Slack in #core-multisite by nerrad. View the logs.


8 years ago

#2 @nerrad
8 years ago

  • Summary changed from Add pre_get_blogs_of_user of user filter. to Add pre_get_blogs_of_user filter.

#3 @jtsternberg
8 years ago

  • Keywords has-patch needs-refresh has-unit-tests added

@jeremyfelt
8 years ago

#4 follow-up: @jeremyfelt
8 years ago

  • Keywords needs-refresh removed
  • Milestone changed from Awaiting Review to 4.6

36707.diff is a riff on/refresh of @jtsternberg's original patch and uses count() rather than empty() to check the returned data from the filter.

Should we start with false instead and allow for the return of an empty array?

#5 in reply to: ↑ 4 ; follow-up: @jtsternberg
8 years ago

Replying to jeremyfelt:

36707.diff is a riff on/refresh of @jtsternberg's original patch and uses count() rather than empty() to check the returned data from the filter.

Should we start with false instead and allow for the return of an empty array?

Actually yah, that seems like a good idea, though it probably should be null in keeping with the precedent of other 'pre_* filters in WordPress.

Also, it looks like the static variable is a no-go?

Version 0, edited 8 years ago by jtsternberg (next)

#6 in reply to: ↑ 5 @jeremyfelt
8 years ago

  • Owner set to jeremyfelt
  • Status changed from new to reviewing

Replying to jtsternberg:

Should we start with false instead and allow for the return of an empty array?

Actually yah, that seems like a good idea, though it probably should be null in keeping with the precedent of other 'pre_* filters in WordPress.

+1

Also, it looks like the static variable is a no-go?

For this ticket, yes. We can continue discussing improvements to get_blogs_of_user() on #31746.

#7 @jeremyfelt
8 years ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 37326:

Multisite: Add the pre_get_blogs_of_user filter

This allows a plugin to short circuit get_blogs_of_user() in cases where the default behavior of the function is unnecessary or slow. (e.g. A user is a member of thousands of sites.)

Props jsternberg.
See #31746, Fixes #36707.

#8 @jtsternberg
8 years ago

Thanks @jeremyfelt!

Note: See TracTickets for help on using tickets.