MU Advanced: Issues and Discussion
Welcome Guest
  • Good evening, Guest.
    Please log in, or register.
  • July 31, 2010, 05:45:46 PM
Home Forums Contact Tags FAQ Links News Login Register
* *
Navigation Menu
Search

Random Quotes
Those who cannot remember the past are condemned to repeat it.
- George Santayana
Pages: [1]   Go Down
  Print  
Author Topic: get_option() and get_blog_option() not as similar as you might expect  (Read 799 times)
0 Members and 1 Guest are viewing this topic.
ZappoMan
Full Member
***

Karma: 1
Offline Offline

Posts: 157



View Profile
« on: September 04, 2008, 11:56:31 AM »

So I was just debugging some crazy behavior, and I stumbled into the code to find something I very much did not expect.

I always assumed that:

Code:
switch_to_blog(1);
$val = get_option("foo");
restore_current_blog();

would be return the SAME values as:

Code:
$val = get_blog_option(1,"foo");

And in mu 1.0, it did... but somewhere along the way... things changed...

and now, it turns out that they do not do the same thing...

No, sometime around 1.5 (maybe sooner) the code changed so that when using the cache, these go to totally different cache groups.

the get_option() version goes to the "alloptions" cache, while the get_blog_option() goes to the "site-option" cache (with the blog ID preprended).

This seems like a problem to me... since I can imagine code that assumes that these two calls would return the same semantic object... but alas... you could easily get these things out of sync.

Does anyone else think this is a problem?

Should I report this as a bug in trac?




Logged

Yep, that's me... riding my bike 204 miles in one day.
drmike
Gate Keeper
*****

Karma: 3
Offline Offline

Posts: 2228



View Profile WWW
« Reply #1 on: September 04, 2008, 12:57:45 PM »

I would bring it up on the support forums at least and ask for Donncha's input.  Stuff like that, he usually will pop in and answer.
Logged

Andrea_R
Key Master
*****

Karma: 5
Offline Offline

Posts: 1626


The spiky-haired mistress of homeschooling. (R)


View Profile WWW
« Reply #2 on: September 04, 2008, 05:23:57 PM »

I would totally mention it to get his input.
Logged

Am I the only one with a sig?
Ah well, might as well read my blog for lols.
ron_r
Key Master
*****

Karma: 4
Offline Offline

Posts: 1143



View Profile WWW
« Reply #3 on: September 04, 2008, 08:10:11 PM »

The switch to blog version of the function was commented out in 1.3. I didn't check earlier versions.
Logged

The key to problem solving is identifying the problem.
ZappoMan
Full Member
***

Karma: 1
Offline Offline

Posts: 157



View Profile
« Reply #4 on: September 04, 2008, 08:52:25 PM »

@ron_r: I think this issue is also related to how the cache is implemented and also whether or not plugins use get_options() or get_blog_options() exclusively.

It's funny because I only found this bug because I had to reimplement some stuff, and in the process of debugging other issues, I noticed this code was written this way. The code itself wasn't actually causing problems for me.

As of now, my code is working fine, because I'm explicitly doing the switch_to_blog() because I've got other things I need to do in the blog context.

But I can just imagine the bugs that could pop up from this.

Logged

Yep, that's me... riding my bike 204 miles in one day.
ron_r
Key Master
*****

Karma: 4
Offline Offline

Posts: 1143



View Profile WWW
« Reply #5 on: September 05, 2008, 01:01:27 PM »

It's funny because I only found this bug because I had to reimplement some stuff, and in the process of debugging other issues, I noticed this code was written this way. The code itself wasn't actually causing problems for me.

I could see the potential for issues if update_option was used in contexts where both are being used. update_blog_option updates both. But, I expect update_option is not even aware the other is there.
Logged

The key to problem solving is identifying the problem.
Tags:

Pages: [1]   Go Up
  Print  
 
Jump to:  


Login
 
 
Recent Posts
Recent Topics
No new topics.
Hot Tags
Whos Online
7 Guests, 0 Users
Home Forums Contact Tags FAQ Links News Login Register