Make WordPress Core

Opened 12 years ago

Closed 11 years ago

Last modified 11 years ago

#22336 closed defect (bug) (invalid)

WP_Theme::get_allowed_on_site() function doesn't work for other blogs

Reported by: npetetin's profile npetetin Owned by:
Milestone: Priority: normal
Severity: major Version: 3.4.2
Component: Themes Keywords:
Focuses: Cc:

Description

On line 1110, the static function WP_Theme::get_allowed_on_site() overwrites the $blog_id argument:

$current = $blog_id == get_current_blog_id();

As a consequence, calling the function for another blog than the current blog is made impossible. It doesn't look fixed in WP 3.5 either.

Change History (4)

#1 @SergeyBiryukov
12 years ago

That line only assigns a boolean value to $current, it doesn't change $blog_id.

#2 @npetetin
12 years ago

My mistake, you're perfectly right. I've been a bit fast in my troubleshooting.

However, there's definitely an issue with the new 3.4 implementation. Why using the static $allowed_themes? For caching purpose? If yes, options and blog options are already fully cached, aren't they?

The issue is that with this additional "caching system", the calls to 'get_option' and 'get_blog_option' are bypassed and then filters are not applied anymore. If for any good reason a plugin adds a filter on 'allowed_themes' option after the static function is called for the first time, the result is never filtered, am I wrong?

Thanks.

#3 @nacin
11 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

::get_allowed_on_site() is complicated, because it has to handle both old and new storage mechanisms. It's pretty painful as it may have to do a switch_to_blog() and back again, and potentially update some options. I honestly don't remember (I wrote this) but I profiled the living heck out of this code, and probably realized I could squeeze out some extra speed here. If I had to guess, it gets called often enough for this kind of caching to make sense.

You are correct that if a plugin adds a filter late, then it wouldn't work. I don't think that's enough to go on here to change this, though.

#4 @npetetin
11 years ago

Hi Nacin.

Thank you for your late reply.

I do think that's enough (in y opinion a core filter is broken here) but you're better judge for this.

Anyway, I've been having a workaround for a long time so it's not critical.

Thanks again.

Note: See TracTickets for help on using tickets.