From cc83ad3fc583dc8492842143d030ebb15275b02b Mon Sep 17 00:00:00 2001 From: donncha Date: Tue, 20 Dec 2005 15:12:04 +0000 Subject: WP Merge Cache fixes git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@477 7be80a69-a1ef-0310-a953-fb0f7c49ff36 --- wp-inst/wp-admin/admin-db.php | 2 +- wp-inst/wp-admin/admin-functions.php | 2 +- wp-inst/wp-admin/inline-uploading.php | 14 +++++------ wp-inst/wp-content/themes/default/attachment.php | 4 ++- wp-inst/wp-includes/cache.php | 2 +- wp-inst/wp-includes/comment-functions.php | 2 ++ wp-inst/wp-includes/functions.php | 4 +-- wp-inst/wp-includes/pluggable-functions.php | 6 ++--- wp-inst/wp-includes/registration-functions.php | 2 +- wp-inst/wp-includes/template-functions-post.php | 2 +- wp-inst/wp-includes/wpmu-functions.php | 31 ++++++++++++++++-------- 11 files changed, 43 insertions(+), 28 deletions(-) (limited to 'wp-inst') diff --git a/wp-inst/wp-admin/admin-db.php b/wp-inst/wp-admin/admin-db.php index f764d3f..73b59f3 100644 --- a/wp-inst/wp-admin/admin-db.php +++ b/wp-inst/wp-admin/admin-db.php @@ -242,7 +242,7 @@ function wp_delete_user($id, $reassign = 'novalue') { $wpdb->query("DELETE FROM $wpdb->usermeta WHERE user_id = $id AND meta_key = '{$wpdb->prefix}capabilities'"); wp_cache_delete($id, 'users'); - wp_cache_delete($user->user_login, 'users'); + wp_cache_delete($user->user_login, 'userlogins'); do_action('delete_user', $id); diff --git a/wp-inst/wp-admin/admin-functions.php b/wp-inst/wp-admin/admin-functions.php index cd7f083..d0d08d2 100644 --- a/wp-inst/wp-admin/admin-functions.php +++ b/wp-inst/wp-admin/admin-functions.php @@ -93,7 +93,7 @@ function fix_attachment_links($post_ID) { return; $i = 0; - $search = "# id=(\"|)(\d+)\\1#i"; + $search = "# id=(\"|')p(\d+)\\1#i"; foreach ( $anchor_matches[0] as $anchor ) { if ( 0 == preg_match($search, $anchor, $id_matches) ) continue; diff --git a/wp-inst/wp-admin/inline-uploading.php b/wp-inst/wp-admin/inline-uploading.php index 053746c..065855a 100644 --- a/wp-inst/wp-admin/inline-uploading.php +++ b/wp-inst/wp-admin/inline-uploading.php @@ -235,7 +235,7 @@ srcb[{$ID}] = '{$image['guid']}'; $xpadding = (128 - $image['uwidth']) / 2; $ypadding = (96 - $image['uheight']) / 2; $style .= "#target{$ID} img { padding: {$ypadding}px {$xpadding}px; }\n"; - $script .= "aa[{$ID}] = ''; + $script .= "aa[{$ID}] = ''; ab[{$ID}] = ''; imga[{$ID}] = '\"{$image['post_title']}\"'; imgb[{$ID}] = '\"{$image['post_title']}\"'; @@ -258,15 +258,15 @@ imgb[{$ID}] = '\"{$image['po$__using_title"; - $script .= "aa[{$ID}] = '{$attachment['post_title']}'; -ab[{$ID}] = '{$attachment['post_title']}'; + $script .= "aa[{$ID}] = '{$attachment['post_title']}'; +ab[{$ID}] = '{$attachment['post_title']}'; title[{$ID}] = '{$attachment['post_title']}'; filename[{$ID}] = '{$filename}'; icon[{$ID}] = '{$icon}'; "; $html .= "
{$noscript}
@@ -349,7 +349,7 @@ function toggleLink(n) { function toggleOtherLink(n) { od=document.getElementById('div'+n); ol=document.getElementById('L'+n); - oi=document.getElementById(n); + oi=document.getElementById('p'+n); ih=oi.innerHTML; if ( ol.innerHTML == linkedtofile ) { od.innerHTML = aa[n]; @@ -358,7 +358,7 @@ function toggleOtherLink(n) { od.innerHTML = ab[n]; ol.innerHTML = linkedtofile; } - oi=document.getElementById(n); + oi=document.getElementById('p'+n); oi.innerHTML = ih; } function toggleImage(n) { @@ -374,7 +374,7 @@ function toggleImage(n) { } function toggleOtherIcon(n) { od = document.getElementById('div'+n); - o = document.getElementById(n); + o = document.getElementById('p'+n); oi = document.getElementById('I'+n); if ( oi.innerHTML == usingtitle ) { o.innerHTML = filename[n]; diff --git a/wp-inst/wp-content/themes/default/attachment.php b/wp-inst/wp-content/themes/default/attachment.php index 559a8e4..b8f3347 100644 --- a/wp-inst/wp-content/themes/default/attachment.php +++ b/wp-inst/wp-content/themes/default/attachment.php @@ -8,10 +8,12 @@
 
 
+ID, true, array(450, 800)); // This also populates the iconsize for the next line ?> +ID); $classname = ($_post->iconsize[0] <= 128 ? 'small' : '') . 'attachment'; // This lets us style narrow icons specially ?>

post_parent); ?> »

- +


guid); ?>

Read the rest of this entry »

'); ?> diff --git a/wp-inst/wp-includes/cache.php b/wp-inst/wp-includes/cache.php index 3dba09a..ffb6756 100644 --- a/wp-inst/wp-includes/cache.php +++ b/wp-inst/wp-includes/cache.php @@ -58,7 +58,7 @@ class WP_Object_Cache { var $cache = array (); var $dirty_objects = array (); var $non_existant_objects = array (); - var $global_groups = array ('users', 'usermeta', 'site-options'); + var $global_groups = array ('users', 'userlogins', 'usermeta', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details'); var $blog_id; var $cold_cache_hits = 0; var $warm_cache_hits = 0; diff --git a/wp-inst/wp-includes/comment-functions.php b/wp-inst/wp-includes/comment-functions.php index a056835..21b9a99 100644 --- a/wp-inst/wp-includes/comment-functions.php +++ b/wp-inst/wp-includes/comment-functions.php @@ -74,6 +74,8 @@ function wp_insert_comment($commentdata) { $comment_date = current_time('mysql'); if ( ! isset($comment_date_gmt) ) $comment_date_gmt = gmdate('Y-m-d H:i:s', strtotime($comment_date) ); + if ( ! isset($comment_parent) ) + $comment_parent = 0; $result = $wpdb->query("INSERT INTO $wpdb->comments (comment_post_ID, comment_author, comment_author_email, comment_author_url, comment_author_IP, comment_date, comment_date_gmt, comment_content, comment_approved, comment_agent, comment_type, comment_parent, user_id) diff --git a/wp-inst/wp-includes/functions.php b/wp-inst/wp-includes/functions.php index d4b5f78..8cd8503 100644 --- a/wp-inst/wp-includes/functions.php +++ b/wp-inst/wp-includes/functions.php @@ -2219,7 +2219,7 @@ function update_usermeta( $user_id, $meta_key, $meta_value ) { $user = get_userdata($user_id); wp_cache_delete($user_id, 'users'); - wp_cache_delete($user->user_login, 'users'); + wp_cache_delete($user->user_login, 'userlogins'); return true; } @@ -2241,7 +2241,7 @@ function delete_usermeta( $user_id, $meta_key, $meta_value = '' ) { $user = get_userdata($user_id); wp_cache_delete($user_id, 'users'); - wp_cache_delete($user->user_login, 'users'); + wp_cache_delete($user->user_login, 'userlogins'); return true; } diff --git a/wp-inst/wp-includes/pluggable-functions.php b/wp-inst/wp-includes/pluggable-functions.php index f30db71..6a99d69 100644 --- a/wp-inst/wp-includes/pluggable-functions.php +++ b/wp-inst/wp-includes/pluggable-functions.php @@ -58,7 +58,7 @@ function get_userdata( $user_id ) { } //end if wp_cache_add($user_id, $user, 'users'); - wp_cache_add($user->user_login, $user, 'users'); + wp_cache_add($user->user_login, $user, 'userlogins'); return $user; } @@ -78,7 +78,7 @@ function get_userdatabylogin($user_login) { if ( empty( $user_login ) ) return false; - $userdata = wp_cache_get($user_login, 'users'); + $userdata = wp_cache_get($user_login, 'userlogins'); if ( $userdata ) return $userdata; @@ -106,7 +106,7 @@ function get_userdatabylogin($user_login) { } wp_cache_add($user->ID, $user, 'users'); - wp_cache_add($user->user_login, $user, 'users'); + wp_cache_add($user->user_login, $user, 'userlogins'); return $user; diff --git a/wp-inst/wp-includes/registration-functions.php b/wp-inst/wp-includes/registration-functions.php index bafce85..3adc184 100644 --- a/wp-inst/wp-includes/registration-functions.php +++ b/wp-inst/wp-includes/registration-functions.php @@ -70,7 +70,7 @@ function wp_insert_user($userdata) { } wp_cache_delete($user_id, 'users'); - wp_cache_delete($user_login, 'users'); + wp_cache_delete($user_login, 'userlogins'); if ( $update ) do_action('profile_update', $user_id); diff --git a/wp-inst/wp-includes/template-functions-post.php b/wp-inst/wp-includes/template-functions-post.php index c851947..a13fa87 100644 --- a/wp-inst/wp-includes/template-functions-post.php +++ b/wp-inst/wp-includes/template-functions-post.php @@ -534,7 +534,7 @@ function get_attachment_icon($id = 0, $fullsize = false, $max_dims = false) { } } - $icon = "post_title}\" {$constraint}/>"; + $icon = "post_title}\" alt=\"{$post->post_title}\" {$constraint}/>"; return apply_filters('attachment_icon', $icon, $post->ID); } diff --git a/wp-inst/wp-includes/wpmu-functions.php b/wp-inst/wp-includes/wpmu-functions.php index fc376c9..e23b3ef 100644 --- a/wp-inst/wp-includes/wpmu-functions.php +++ b/wp-inst/wp-includes/wpmu-functions.php @@ -8,10 +8,9 @@ function wpmu_update_blogs_date() { global $wpdb; $wpdb->query( "UPDATE {$wpdb->blogs} SET last_updated = NOW() WHERE blog_id = '{$wpdb->blogid}'" ); - $blog = $wpdb->get_row( "SELECT * FROM {$wpdb->blogs} WHERE blog_id = '{$wpdb->blogid}'" ); - $key = md5( $blog->domain . $blog->path ); - wp_cache_set($key, serialize( $blog ), 'blog-lookup'); + refresh_blog_details( $wpdb->blogid ); } + add_action('comment_post', 'wpmu_update_blogs_date'); add_action('delete_post', 'wpmu_update_blogs_date'); add_action('delete_comment', 'wpmu_update_blogs_date'); @@ -395,9 +394,25 @@ function get_blog_details( $id ) { $details = $wpdb->get_row( "SELECT * FROM $wpdb->blogs WHERE blog_id = '$id'" ); $details->blogname = stripslashes( $wpdb->get_var( "SELECT option_value FROM {$wpmuBaseTablePrefix}{$id}_options WHERE option_name = 'blogname'" ) ); $details->siteurl = $wpdb->get_var( "SELECT option_value FROM {$wpmuBaseTablePrefix}{$id}_options WHERE option_name = 'siteurl'" ); - wp_cache_set( $id, serialize( $details ), 'blog-details' ); + $key = md5( $details->domain . $details->path ); + wp_cache_set( $key, serialize( $details ), 'blog-lookup' ); + + return $details; +} + +function refresh_blog_details( $id ) { + global $wpdb, $wpmuBaseTablePrefix; + + $details = $wpdb->get_row( "SELECT * FROM $wpdb->blogs WHERE blog_id = '$id'" ); + $details->blogname = stripslashes( $wpdb->get_var( "SELECT option_value FROM {$wpmuBaseTablePrefix}{$id}_options WHERE option_name = 'blogname'" ) ); + $details->siteurl = $wpdb->get_var( "SELECT option_value FROM {$wpmuBaseTablePrefix}{$id}_options WHERE option_name = 'siteurl'" ); + wp_cache_set( $id , serialize( $details ), 'blog-details' ); + + $key = md5( $details->domain . $details->path ); + wp_cache_set( $key , serialize( $details ), 'blog-lookup' ); + return $details; } @@ -642,9 +657,7 @@ function is_archived( $id ) { function update_archived( $id, $archived ) { global $wpdb; $wpdb->query( "UPDATE {$wpdb->blogs} SET archived = '{$archived}' WHERE blog_id = '$id'" ); - $blog = $wpdb->get_row( "SELECT * FROM {$wpdb->blogs} WHERE blog_id = '$id'" ); - $key = md5( $blog->domain . $blog->path ); - wp_cache_set($key, serialize( $blog ), 'blog-lookup'); + refresh_blog_details( $id ); return $archived; } @@ -652,9 +665,7 @@ function update_archived( $id, $archived ) { function update_blog_status( $id, $pref, $value ) { global $wpdb; $wpdb->query( "UPDATE {$wpdb->blogs} SET {$pref} = '{$value}' WHERE blog_id = '$id'" ); - $blog = $wpdb->get_row( "SELECT * FROM {$wpdb->blogs} WHERE blog_id = '$id'" ); - $key = md5( $blog->domain . $blog->path ); - wp_cache_set($key, serialize( $blog ), 'blog-lookup'); + refresh_blog_details( $id ); return $value; } -- cgit