Don't cache filtered post objects. Set filter when getting sample permalink. Props brianwhite. fixes #8526 for trunk
git-svn-id: http://svn.automattic.com/wordpress/trunk@10213 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
6587bdff8d
commit
d3b9da7025
|
@ -909,6 +909,8 @@ function get_sample_permalink($id, $title=null, $name = null) {
|
||||||
$post->post_name = sanitize_title($name? $name : $title, $post->ID);
|
$post->post_name = sanitize_title($name? $name : $title, $post->ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$post->filter = 'sample';
|
||||||
|
|
||||||
$permalink = get_permalink($post, true);
|
$permalink = get_permalink($post, true);
|
||||||
|
|
||||||
// Handle page hierarchy
|
// Handle page hierarchy
|
||||||
|
@ -926,6 +928,8 @@ function get_sample_permalink($id, $title=null, $name = null) {
|
||||||
$post->post_status = $original_status;
|
$post->post_status = $original_status;
|
||||||
$post->post_date = $original_date;
|
$post->post_date = $original_date;
|
||||||
$post->post_name = $original_name;
|
$post->post_name = $original_name;
|
||||||
|
unset($post->filter);
|
||||||
|
|
||||||
return $permalink;
|
return $permalink;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -92,7 +92,10 @@ function get_permalink($id = 0, $leavename = false) {
|
||||||
$leavename? '' : '%pagename%',
|
$leavename? '' : '%pagename%',
|
||||||
);
|
);
|
||||||
|
|
||||||
$post = &get_post($id);
|
if ( is_object($id) && isset($id->filter) && 'sample' == $id->filter )
|
||||||
|
$post = $id;
|
||||||
|
else
|
||||||
|
$post = &get_post($id);
|
||||||
|
|
||||||
if ( empty($post->ID) ) return false;
|
if ( empty($post->ID) ) return false;
|
||||||
|
|
||||||
|
|
|
@ -215,11 +215,13 @@ function &get_post(&$post, $output = OBJECT, $filter = 'raw') {
|
||||||
$_post = & $GLOBALS['post'];
|
$_post = & $GLOBALS['post'];
|
||||||
else
|
else
|
||||||
return $null;
|
return $null;
|
||||||
} elseif ( is_object($post) ) {
|
} elseif ( is_object($post) && empty($post->filter) ) {
|
||||||
_get_post_ancestors($post);
|
_get_post_ancestors($post);
|
||||||
wp_cache_add($post->ID, $post, 'posts');
|
wp_cache_add($post->ID, $post, 'posts');
|
||||||
$_post = &$post;
|
$_post = &$post;
|
||||||
} else {
|
} else {
|
||||||
|
if ( is_object($post) )
|
||||||
|
$post = $post->ID;
|
||||||
$post = (int) $post;
|
$post = (int) $post;
|
||||||
if ( ! $_post = wp_cache_get($post, 'posts') ) {
|
if ( ! $_post = wp_cache_get($post, 'posts') ) {
|
||||||
$_post = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d LIMIT 1", $post));
|
$_post = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wpdb->posts WHERE ID = %d LIMIT 1", $post));
|
||||||
|
@ -792,12 +794,15 @@ function sanitize_post($post, $context = 'display') {
|
||||||
$post->ID = 0;
|
$post->ID = 0;
|
||||||
foreach ( array_keys(get_object_vars($post)) as $field )
|
foreach ( array_keys(get_object_vars($post)) as $field )
|
||||||
$post->$field = sanitize_post_field($field, $post->$field, $post->ID, $context);
|
$post->$field = sanitize_post_field($field, $post->$field, $post->ID, $context);
|
||||||
|
$post->filter = $context;
|
||||||
} else {
|
} else {
|
||||||
if ( !isset($post['ID']) )
|
if ( !isset($post['ID']) )
|
||||||
$post['ID'] = 0;
|
$post['ID'] = 0;
|
||||||
foreach ( array_keys($post) as $field )
|
foreach ( array_keys($post) as $field )
|
||||||
$post[$field] = sanitize_post_field($field, $post[$field], $post['ID'], $context);
|
$post[$field] = sanitize_post_field($field, $post[$field], $post['ID'], $context);
|
||||||
|
$post['filter'] = $context;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $post;
|
return $post;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue