Make WordPress Core

Opened 14 years ago

Closed 14 years ago

#13043 closed defect (bug) (fixed)

get_site_option should use wpdb->get_row

Reported by: laceous's profile laceous Owned by:
Milestone: 3.0 Priority: normal
Severity: normal Version: 3.0
Component: Multisite Keywords: has-patch
Focuses: Cc:

Description

get_option uses the following code when pulling data from the database:

$row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = '%s' LIMIT 1", $option ) );
// Has to be get_row instead of get_var because of funkiness with 0, false, null values
if ( is_object( $row ) ) {

get_site_option uses get_var directly which leads to the funkiness that get_option tries to avoid:

$value = $wpdb->get_var( $wpdb->prepare("SELECT meta_value FROM $wpdb->sitemeta WHERE meta_key = %s AND site_id = %d", $option, $wpdb->siteid ) );
if ( is_null($value) )
  $value = $default;

get_site_option should use get_row instead of get_var

(This was tested with the latest nightly build)

Attachments (1)

functions.php.diff (886 bytes) - added by laceous 14 years ago.
change get_var to get_row

Download all attachments as: .zip

Change History (5)

@laceous
14 years ago

change get_var to get_row

#1 @laceous
14 years ago

  • Keywords has-patch added

#2 @scribu
14 years ago

  • Component changed from General to Multisite

#3 @technosailor
14 years ago

Still applies cleanly.

#4 @nacin
14 years ago

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

(In [14410]) Use get_row instead of get_var in get_site_option, aligning it with get_option, due to funkiness with 0/false/null. fixes #13043. props laceous.

Note: See TracTickets for help on using tickets.