summaryrefslogtreecommitdiffstats
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
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
-rw-r--r--wp-admin/upgrade-schema.php28
-rw-r--r--wp-config-sample.php2
-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
-rw-r--r--xmlrpc.php45
10 files changed, 168 insertions, 54 deletions
diff --git a/wp-admin/upgrade-schema.php b/wp-admin/upgrade-schema.php
index 61e1eb4..610ccc9 100644
--- a/wp-admin/upgrade-schema.php
+++ b/wp-admin/upgrade-schema.php
@@ -2,6 +2,14 @@
// Here we keep the DB structure and option values
global $wp_queries;
+$charset_collate = '';
+
+if ( version_compare(mysql_get_server_info(), '4.1.0', '>=') ) {
+ if ( ! empty($wpdb->charset) )
+ $charset_collate = "DEFAULT CHARACTER SET $wpdb->charset";
+ if ( ! empty($wpdb->collate) )
+ $charset_collate .= " COLLATE $wpdb->collate";
+}
$wp_queries="CREATE TABLE $wpdb->categories (
cat_ID bigint(20) NOT NULL auto_increment,
@@ -15,7 +23,7 @@ $wp_queries="CREATE TABLE $wpdb->categories (
links_private tinyint(1) NOT NULL default '0',
PRIMARY KEY (cat_ID),
KEY category_nicename (category_nicename)
-) TYPE=MyISAM;
+) $charset_collate;
CREATE TABLE $wpdb->comments (
comment_ID bigint(20) unsigned NOT NULL auto_increment,
comment_post_ID int(11) NOT NULL default '0',
@@ -35,14 +43,14 @@ CREATE TABLE $wpdb->comments (
PRIMARY KEY (comment_ID),
KEY comment_approved (comment_approved),
KEY comment_post_ID (comment_post_ID)
-) TYPE=MyISAM;
+) $charset_collate;
CREATE TABLE $wpdb->link2cat (
rel_id bigint(20) NOT NULL auto_increment,
link_id bigint(20) NOT NULL default '0',
category_id bigint(20) NOT NULL default '0',
PRIMARY KEY (rel_id),
KEY link_id (link_id,category_id)
-) TYPE=MyISAM;
+) $charset_collate;
CREATE TABLE $wpdb->links (
link_id bigint(20) NOT NULL auto_increment,
link_url varchar(255) NOT NULL default '',
@@ -61,7 +69,7 @@ CREATE TABLE $wpdb->links (
PRIMARY KEY (link_id),
KEY link_category (link_category),
KEY link_visible (link_visible)
-) TYPE=MyISAM;
+) $charset_collate;
CREATE TABLE $wpdb->options (
option_id bigint(20) NOT NULL auto_increment,
blog_id int(11) NOT NULL default '0',
@@ -76,14 +84,14 @@ CREATE TABLE $wpdb->options (
autoload enum('yes','no') NOT NULL default 'yes',
PRIMARY KEY (option_id,blog_id,option_name),
KEY option_name (option_name)
-) TYPE=MyISAM;
+) $charset_collate;
CREATE TABLE $wpdb->post2cat (
rel_id bigint(20) NOT NULL auto_increment,
post_id bigint(20) NOT NULL default '0',
category_id bigint(20) NOT NULL default '0',
PRIMARY KEY (rel_id),
KEY post_id (post_id,category_id)
-) TYPE=MyISAM;
+) $charset_collate;
CREATE TABLE $wpdb->postmeta (
meta_id bigint(20) NOT NULL auto_increment,
post_id bigint(20) NOT NULL default '0',
@@ -92,7 +100,7 @@ CREATE TABLE $wpdb->postmeta (
PRIMARY KEY (meta_id),
KEY post_id (post_id),
KEY meta_key (meta_key)
-) TYPE=MyISAM;
+) $charset_collate;
CREATE TABLE $wpdb->posts (
ID bigint(20) unsigned NOT NULL auto_increment,
post_author bigint(20) NOT NULL default '0',
@@ -121,7 +129,7 @@ CREATE TABLE $wpdb->posts (
PRIMARY KEY (ID),
KEY post_name (post_name),
KEY type_status_date (post_type,post_status,post_date,ID)
-) TYPE=MyISAM;
+) $charset_collate;
CREATE TABLE $wpdb->users (
ID bigint(20) unsigned NOT NULL auto_increment,
user_login varchar(60) NOT NULL default '',
@@ -137,7 +145,7 @@ CREATE TABLE $wpdb->users (
deleted tinyint(2) NOT NULL default '0',
PRIMARY KEY (ID),
KEY user_login_key (user_login)
-);
+) $charset_collate;
CREATE TABLE $wpdb->usermeta (
umeta_id bigint(20) NOT NULL auto_increment,
user_id bigint(20) NOT NULL default '0',
@@ -146,7 +154,7 @@ CREATE TABLE $wpdb->usermeta (
PRIMARY KEY (umeta_id),
KEY user_id (user_id),
KEY meta_key (meta_key)
-);
+) $charset_collate;";
CREATE TABLE $wpdb->blogs (
blog_id bigint(20) NOT NULL auto_increment,
site_id bigint(20) NOT NULL default '0',
diff --git a/wp-config-sample.php b/wp-config-sample.php
index 438728f..8f9d1d2 100644
--- a/wp-config-sample.php
+++ b/wp-config-sample.php
@@ -22,7 +22,7 @@ define ('WPLANG', '');
define( "WP_USE_MULTIPLE_DB", false );
-/* Stop editing */
+/* That's all, stop editing! Happy blogging. */
define('ABSPATH', dirname(__FILE__).'/');
require_once(ABSPATH.'wp-settings.php');
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);
}
diff --git a/xmlrpc.php b/xmlrpc.php
index 7036d6a..90ddc95 100644
--- a/xmlrpc.php
+++ b/xmlrpc.php
@@ -227,7 +227,8 @@ class wp_xmlrpc_server extends IXR_Server {
"wp_page_parent_id" => $page->post_parent,
"wp_page_parent_title" => $parent_title,
"wp_page_order" => $page->menu_order,
- "wp_author_username" => $author->user_login
+ "wp_author_id" => $author->ID,
+ "wp_author_display_username" => $author->display_name
);
return($page_struct);
@@ -947,6 +948,23 @@ class wp_xmlrpc_server extends IXR_Server {
// If an author id was provided then use it instead.
if(!empty($content_struct["wp_author_id"])) {
+ switch($post_type) {
+ case "post":
+ if(!current_user_can("edit_others_posts")) {
+ return(new IXR_Error(401, "You are not allowed to " .
+ "post as this user"));
+ }
+ break;
+ case "page":
+ if(!current_user_can("edit_others_pages")) {
+ return(new IXR_Error(401, "You are not allowed to " .
+ "create pages as this user"));
+ }
+ break;
+ default:
+ return(new IXR_Error(401, "Invalid post type."));
+ break;
+ }
$post_author = $content_struct["wp_author_id"];
}
@@ -1079,6 +1097,23 @@ class wp_xmlrpc_server extends IXR_Server {
// Only set the post_author if one is set.
if(!empty($content_struct["wp_author_id"])) {
+ switch($post_type) {
+ case "post":
+ if(!current_user_can("edit_others_posts")) {
+ return(new IXR_Error(401, "You are not allowed to " .
+ "change the post author as this user."));
+ }
+ break;
+ case "page":
+ if(!current_user_can("edit_others_pages")) {
+ return(new IXR_Error(401, "You are not allowed to " .
+ "change the page author as this user."));
+ }
+ break;
+ default:
+ return(new IXR_Error(401, "Invalid post type."));
+ break;
+ }
$post_author = $content_struct["wp_author_id"];
}
@@ -1199,8 +1234,8 @@ class wp_xmlrpc_server extends IXR_Server {
'mt_allow_pings' => $allow_pings,
'wp_slug' => $postdata['post_name'],
'wp_password' => $postdata['post_password'],
- 'wp_author' => $author->display_name,
- 'wp_author_username' => $author->user_login
+ 'wp_author_id' => $author->ID,
+ 'wp_author_display_name' => $author->display_name
);
return $resp;
@@ -1266,8 +1301,8 @@ class wp_xmlrpc_server extends IXR_Server {
'mt_allow_pings' => $allow_pings,
'wp_slug' => $entry['post_name'],
'wp_password' => $entry['post_password'],
- 'wp_author' => $author->display_name,
- 'wp_author_username' => $author->user_login
+ 'wp_author_id' => $author->ID,
+ 'wp_author_display_name' => $author->display_name
);
}