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:
ryan 2008-12-16 23:50:39 +00:00
parent 6587bdff8d
commit d3b9da7025
3 changed files with 14 additions and 2 deletions

View File

@ -909,6 +909,8 @@ function get_sample_permalink($id, $title=null, $name = null) {
$post->post_name = sanitize_title($name? $name : $title, $post->ID);
}
$post->filter = 'sample';
$permalink = get_permalink($post, true);
// Handle page hierarchy
@ -926,6 +928,8 @@ function get_sample_permalink($id, $title=null, $name = null) {
$post->post_status = $original_status;
$post->post_date = $original_date;
$post->post_name = $original_name;
unset($post->filter);
return $permalink;
}

View File

@ -92,6 +92,9 @@ function get_permalink($id = 0, $leavename = false) {
$leavename? '' : '%pagename%',
);
if ( is_object($id) && isset($id->filter) && 'sample' == $id->filter )
$post = $id;
else
$post = &get_post($id);
if ( empty($post->ID) ) return false;

View File

@ -215,11 +215,13 @@ function &get_post(&$post, $output = OBJECT, $filter = 'raw') {
$_post = & $GLOBALS['post'];
else
return $null;
} elseif ( is_object($post) ) {
} elseif ( is_object($post) && empty($post->filter) ) {
_get_post_ancestors($post);
wp_cache_add($post->ID, $post, 'posts');
$_post = &$post;
} else {
if ( is_object($post) )
$post = $post->ID;
$post = (int) $post;
if ( ! $_post = wp_cache_get($post, 'posts') ) {
$_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;
foreach ( array_keys(get_object_vars($post)) as $field )
$post->$field = sanitize_post_field($field, $post->$field, $post->ID, $context);
$post->filter = $context;
} else {
if ( !isset($post['ID']) )
$post['ID'] = 0;
foreach ( array_keys($post) as $field )
$post[$field] = sanitize_post_field($field, $post[$field], $post['ID'], $context);
$post['filter'] = $context;
}
return $post;
}