summaryrefslogtreecommitdiffstats
path: root/wp-includes
diff options
context:
space:
mode:
authordonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2007-02-05 11:49:12 +0000
committerdonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2007-02-05 11:49:12 +0000
commit6ef7b48c2da1ad9731e1f4734be86ed3ae5afca0 (patch)
tree0a0c0a8c8146ef18a1aa87016c9a3f7e3ced1618 /wp-includes
parent4c4e0fc82e70e810472721ad23aac64ba2c5b6e1 (diff)
downloadwordpress-mu-6ef7b48c2da1ad9731e1f4734be86ed3ae5afca0.tar.gz
wordpress-mu-6ef7b48c2da1ad9731e1f4734be86ed3ae5afca0.tar.xz
wordpress-mu-6ef7b48c2da1ad9731e1f4734be86ed3ae5afca0.zip
WP Merge to rev 4865
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@879 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-includes')
-rw-r--r--wp-includes/cache.php16
-rw-r--r--wp-includes/functions.php100
-rw-r--r--wp-includes/pluggable.php10
-rw-r--r--wp-includes/post-template.php4
-rw-r--r--wp-includes/script-loader.php1
-rw-r--r--wp-includes/version.php2
-rw-r--r--wp-includes/wp-db.php14
7 files changed, 109 insertions, 38 deletions
diff --git a/wp-includes/cache.php b/wp-includes/cache.php
index 2232e15..b5a2b9d 100644
--- a/wp-includes/cache.php
+++ b/wp-includes/cache.php
@@ -217,22 +217,8 @@ class WP_Object_Cache {
$this->cache[$this->key( $catt->cat_ID, 'category' )] = $catt;
}
}
- } else
- if ('options' == $group) {
- $wpdb->hide_errors();
- if (!$options = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options WHERE autoload = 'yes'")) {
- $options = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options");
- }
- $wpdb->show_errors();
-
- if ( ! $options )
- return;
+ }
- foreach ($options as $option) {
- $this->cache['options'][$option->option_name] = $option->option_value;
- $this->cache[$this->key( $option->option_name, 'options' )] = $option->option_value;
- }
- }
}
function make_group_dir($group, $perms) {
diff --git a/wp-includes/functions.php b/wp-includes/functions.php
index c59062a..3ab25e5 100644
--- a/wp-includes/functions.php
+++ b/wp-includes/functions.php
@@ -209,16 +209,25 @@ function get_option($setting) {
return $pre;
if ( $switched == false && defined('WP_INSTALLING') == false ) {
+ // prevent non-existent options from triggering multiple queries
+ $notoptions = wp_cache_get('notoptions', 'options');
+ if ( isset($notoptions[$setting]) )
+ return false;
+
+ $alloptions = wp_load_alloptions();
+
+ if ( isset($alloptions[$setting]) ) {
+ $value = $alloptions[$setting];
+ } else {
$value = wp_cache_get($setting, 'options');
+ }
} else {
$value = false;
wp_cache_delete($setting, 'options');
}
-
// Uncomment if we get any page not found or rewrite errors
// if( $setting == 'rewrite_rules' )
// $value = false;
-
if ( $value == 'novalueindb' )
return false;
if ( $value == 'emptystringindb' )
@@ -233,10 +242,11 @@ function get_option($setting) {
if( is_object( $row) ) { // Has to be get_row instead of get_var because of funkiness with 0, false, null values
$value = $row->option_value;
- wp_cache_set($setting, ($value=='')?'emptystringindb':$value, 'options');
- } else {
- wp_cache_set($setting, 'novalueindb', 'options');
- return false;
+ wp_cache_set($setting, $value, 'options');
+ } else { // option does not exist, so we must cache its non-existence
+ $notoptions[$setting] = true;
+ wp_cache_set('notoptions', $notoptions, 'options');
+ return false;
}
}
@@ -252,6 +262,12 @@ function get_option($setting) {
return apply_filters( 'option_' . $setting, maybe_unserialize($value) );
}
+function wp_protect_special_option($option) {
+ $protected = array('alloptions', 'notoptions');
+ if ( in_array($option, $protected) )
+ die(sprintf(__('%s is a protected WP option and may not be modified'), wp_specialchars($option)));
+}
+
function form_option($option) {
echo attribute_escape(get_option($option));
}
@@ -279,9 +295,29 @@ function get_alloptions() {
return apply_filters('all_options', $all_options);
}
+function wp_load_alloptions() {
+ global $wpdb;
+
+ $alloptions = wp_cache_get('alloptions', 'options');
+
+ if ( !$alloptions ) {
+ $wpdb->hide_errors();
+ if ( !$alloptions_db = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options WHERE autoload = 'yes'") )
+ $alloptions_db = $wpdb->get_results("SELECT option_name, option_value FROM $wpdb->options");
+ $wpdb->show_errors();
+ $alloptions = array();
+ foreach ( (array) $alloptions_db as $o )
+ $alloptions[$o->option_name] = $o->option_value;
+ wp_cache_set('alloptions', $alloptions, 'options');
+ }
+ return $alloptions;
+}
+
function update_option($option_name, $newvalue) {
global $wpdb;
+ wp_protect_special_option($option_name);
+
if ( is_string($newvalue) )
$newvalue = trim($newvalue);
@@ -296,10 +332,22 @@ function update_option($option_name, $newvalue) {
return true;
}
+ $notoptions = wp_cache_get('notoptions', 'options');
+ if ( isset($notoptions[$option_name]) ) {
+ unset($notoptions[$option_name]);
+ wp_cache_set('notoptions', $notoptions, 'options');
+ }
+
$_newvalue = $newvalue;
$newvalue = maybe_serialize($newvalue);
- wp_cache_delete($option_name, 'options');
+ $alloptions = wp_load_alloptions();
+ if ( isset($alloptions[$option_name]) ) {
+ $alloptions[$option_name] = $newvalue;
+ wp_cache_set('alloptions', $alloptions, 'options');
+ } else {
+ wp_cache_set($option_name, $newvalue, 'options');
+ }
$newvalue = $wpdb->escape($newvalue);
$option_name = $wpdb->escape($option_name);
@@ -315,13 +363,26 @@ function update_option($option_name, $newvalue) {
function add_option($name, $value = '', $description = '', $autoload = 'yes') {
global $wpdb;
- // Make sure the option doesn't already exist
- if ( false !== get_option($name) )
- return;
+ wp_protect_special_option($name);
+
+ // Make sure the option doesn't already exist we can check the cache before we ask for a db query
+ $notoptions = wp_cache_get('notoptions', 'options');
+ if ( isset($notoptions[$name]) ) {
+ unset($notoptions[$name]);
+ wp_cache_set('notoptions', $notoptions, 'options');
+ } elseif ( false !== get_option($name) ) {
+ return;
+ }
$value = maybe_serialize($value);
- wp_cache_delete($name, 'options');
+ if ( 'yes' == $autoload ) {
+ $alloptions = wp_load_alloptions();
+ $alloptions[$name] = $value;
+ wp_cache_set('alloptions', $alloptions, 'options');
+ } else {
+ wp_cache_set($name, $value, 'options');
+ }
$name = $wpdb->escape($name);
$value = $wpdb->escape($value);
@@ -333,11 +394,22 @@ function add_option($name, $value = '', $description = '', $autoload = 'yes') {
function delete_option($name) {
global $wpdb;
+
+ wp_protect_special_option($name);
+
// Get the ID, if no ID then return
- $option_id = $wpdb->get_var("SELECT option_id FROM $wpdb->options WHERE option_name = '$name'");
- if ( !$option_id ) return false;
+ $option = $wpdb->get_row("SELECT option_id, autoload FROM $wpdb->options WHERE option_name = '$name'");
+ if ( !$option->option_id ) return false;
$wpdb->query("DELETE FROM $wpdb->options WHERE option_name = '$name'");
- wp_cache_delete($name, 'options');
+ if ( 'yes' == $option->autoload ) {
+ $alloptions = wp_load_alloptions();
+ if ( isset($alloptions[$name]) ) {
+ unset($alloptions[$name]);
+ wp_cache_set('alloptions', $alloptions, 'options');
+ }
+ } else {
+ wp_cache_delete($name, 'options');
+ }
return true;
}
diff --git a/wp-includes/pluggable.php b/wp-includes/pluggable.php
index a4bb24b..0442789 100644
--- a/wp-includes/pluggable.php
+++ b/wp-includes/pluggable.php
@@ -96,8 +96,7 @@ function get_userdata( $user_id ) {
$user->user_description = $user->description;
wp_cache_add($user_id, $user, 'users');
- wp_cache_add($user->user_login, $user, 'userlogins');
-
+ wp_cache_add($user->user_login, $user_id, 'userlogins');
return $user;
}
endif;
@@ -116,7 +115,9 @@ function get_userdatabylogin($user_login) {
if ( empty( $user_login ) )
return false;
- $userdata = wp_cache_get($user_login, 'userlogins');
+ $user_id = wp_cache_get($user_login, 'userlogins');
+ $userdata = wp_cache_get($user_id, 'users');
+
if ( $userdata )
return $userdata;
@@ -153,8 +154,7 @@ function get_userdatabylogin($user_login) {
}
wp_cache_add($user->ID, $user, 'users');
- wp_cache_add($user->user_login, $user, 'userlogins');
-
+ wp_cache_add($user->user_login, $user->ID, 'userlogins');
return $user;
}
diff --git a/wp-includes/post-template.php b/wp-includes/post-template.php
index 4951baa..7a22c3e 100644
--- a/wp-includes/post-template.php
+++ b/wp-includes/post-template.php
@@ -273,6 +273,7 @@ function wp_list_pages($args = '') {
$r = array_merge($defaults, $r);
$output = '';
+ $current_page = 0;
// sanitize, mostly to keep spaces out
$r['exclude'] = preg_replace('[^0-9,]', '', $r['exclude']);
@@ -288,7 +289,8 @@ function wp_list_pages($args = '') {
$output .= '<li class="pagenav">' . $r['title_li'] . '<ul>';
global $wp_query;
- $current_page = $wp_query->get_queried_object_id();
+ if ( is_page() )
+ $current_page = $wp_query->get_queried_object_id();
$output .= walk_page_tree($pages, $r['depth'], $current_page, $r);
if ( $r['title_li'] )
diff --git a/wp-includes/script-loader.php b/wp-includes/script-loader.php
index 1669944..983556b 100644
--- a/wp-includes/script-loader.php
+++ b/wp-includes/script-loader.php
@@ -79,6 +79,7 @@ class WP_Scripts {
$ver .= '&amp;' . $this->args[$handle];
$src = 0 === strpos($this->scripts[$handle]->src, 'http://') ? $this->scripts[$handle]->src : get_option( 'siteurl' ) . $this->scripts[$handle]->src;
$src = add_query_arg('ver', $ver, $src);
+ $src = apply_filters( 'script_loader_src', $src );
echo "<script type='text/javascript' src='$src'></script>\n";
}
$this->printed[] = $handle;
diff --git a/wp-includes/version.php b/wp-includes/version.php
index 1d485b5..26435a2 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -3,6 +3,6 @@
// This holds the version number in a separate file so we can bump it without cluttering the SVN
$wp_version = 'wordpress-mu-1.1.1'; // Let's just avoid confusion
-$wp_db_version = 4772;
+$wp_db_version = 4860;
?>
diff --git a/wp-includes/wp-db.php b/wp-includes/wp-db.php
index 1ed50b4..233b569 100644
--- a/wp-includes/wp-db.php
+++ b/wp-includes/wp-db.php
@@ -28,8 +28,6 @@ class wpdb {
var $post2cat;
var $comments;
var $links;
- var $link2cat;
- var $linkcategories;
var $options;
var $optiontypes;
var $optionvalues;
@@ -37,6 +35,9 @@ class wpdb {
var $optiongroup_options;
var $postmeta;
+ var $charset;
+ var $collate;
+
/**
* Connects to the database server and selects a database
* @param string $dbuser
@@ -53,6 +54,12 @@ class wpdb {
function __construct($dbuser, $dbpassword, $dbname, $dbhost) {
register_shutdown_function(array(&$this, "__destruct"));
+ if ( defined('DB_CHARSET') )
+ $this->charset = DB_CHARSET;
+
+ if ( defined('DB_COLLATE') )
+ $this->collate = DB_COLLATE;
+
$this->dbh = @mysql_connect($dbhost, $dbuser, $dbpassword);
if (!$this->dbh) {
$this->bail("
@@ -67,6 +74,9 @@ class wpdb {
");
}
+ if ( !empty($this->charset) && version_compare(mysql_get_server_info(), '4.1.0', '>=') )
+ $this->query("SET NAMES '$this->charset'");
+
$this->select($dbname, $this->dbh);
}