diff options
author | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2008-09-15 15:45:31 +0000 |
---|---|---|
committer | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2008-09-15 15:45:31 +0000 |
commit | 0bea7c7ad2ee8e82a86919b1cd2fea517cc67ec8 (patch) | |
tree | 5b95d4a59dbb761f8da80c9e894d22a7a547b00c /wp-includes | |
parent | 66b0871abeef45cdbe757c97a643076503b6c656 (diff) | |
download | wordpress-mu-0bea7c7ad2ee8e82a86919b1cd2fea517cc67ec8.tar.gz wordpress-mu-0bea7c7ad2ee8e82a86919b1cd2fea517cc67ec8.tar.xz wordpress-mu-0bea7c7ad2ee8e82a86919b1cd2fea517cc67ec8.zip |
Merge with WP 2.6.2
git-svn-id: http://svn.automattic.com/wordpress-mu/branches/2.6@1471 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-includes')
-rw-r--r-- | wp-includes/formatting.php | 3 | ||||
-rw-r--r-- | wp-includes/pluggable.php | 44 | ||||
-rw-r--r-- | wp-includes/post.php | 25 | ||||
-rw-r--r-- | wp-includes/query.php | 67 | ||||
-rw-r--r-- | wp-includes/version.php | 4 | ||||
-rw-r--r-- | wp-includes/widgets.php | 8 |
6 files changed, 105 insertions, 46 deletions
diff --git a/wp-includes/formatting.php b/wp-includes/formatting.php index e2b969a..eeafe0b 100644 --- a/wp-includes/formatting.php +++ b/wp-includes/formatting.php @@ -332,6 +332,9 @@ function sanitize_user( $username, $strict = false ) { if ( $strict ) $username = preg_replace('|[^a-z0-9 _.\-@]|i', '', $username); + // Consolidate contiguous whitespace + $username = preg_replace('|\s+|', ' ', $username); + return apply_filters('sanitize_user', $username, $raw_username, $strict); } diff --git a/wp-includes/pluggable.php b/wp-includes/pluggable.php index 0007633..8ca7ba1 100644 --- a/wp-includes/pluggable.php +++ b/wp-includes/pluggable.php @@ -1295,11 +1295,53 @@ function wp_generate_password($length = 12, $special_chars = true) { $password = ''; for ( $i = 0; $i < $length; $i++ ) - $password .= substr($chars, mt_rand(0, strlen($chars) - 1), 1); + $password .= substr($chars, wp_rand(0, strlen($chars) - 1), 1); return $password; } endif; +if ( !function_exists('wp_rand') ) : + /** + * Generates a random number + * + * @since 2.6.2 + * + * @param int $min Lower limit for the generated number (optional, default is 0) + * @param int $max Upper limit for the generated number (optional, default is 4294967295) + * @return int A random number between min and max + */ +function wp_rand( $min = 0, $max = 0 ) { + global $rnd_value; + + $seed = get_option('random_seed'); + + // Reset $rnd_value after 14 uses + // 32(md5) + 40(sha1) + 40(sha1) / 8 = 14 random numbers from $rnd_value + if ( strlen($rnd_value) < 8 ) { + $rnd_value = md5( uniqid(microtime() . mt_rand(), true ) . $seed ); + $rnd_value .= sha1($rnd_value); + $rnd_value .= sha1($rnd_value . $seed); + $seed = md5($seed . $rnd_value); + update_option('random_seed', $seed); + } + + // Take the first 8 digits for our value + $value = substr($rnd_value, 0, 8); + + // Strip the first eight, leaving the remainder for the next call to wp_rand(). + $rnd_value = substr($rnd_value, 8); + + $value = abs(hexdec($value)); + + // Reduce the value to be within the min - max range + // 4294967295 = 0xffffffff = max random number + if ( $max != 0 ) + $value = $min + (($max - $min + 1) * ($value / (4294967295 + 1))); + + return abs(intval($value)); +} +endif; + if ( !function_exists('wp_set_password') ) : /** * Updates the user's password with a new encrypted one. diff --git a/wp-includes/post.php b/wp-includes/post.php index bf7d922..54ce668 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -465,7 +465,7 @@ function get_posts($args = null) { 'order' => 'DESC', 'include' => '', 'exclude' => '', 'meta_key' => '', 'meta_value' =>'', 'post_type' => 'post', - 'post_parent' => 0 + 'post_parent' => 0, 'suppress_filters' => true ); $r = wp_parse_args( $args, $defaults ); @@ -594,27 +594,20 @@ function get_post_meta($post_id, $key, $single = false) { $meta_cache = wp_cache_get($post_id, 'post_meta'); + if ( !$meta_cache ) { + update_postmeta_cache($post_id); + $meta_cache = wp_cache_get($post_id, 'post_meta'); + } + if ( isset($meta_cache[$key]) ) { if ( $single ) { return maybe_unserialize( $meta_cache[$key][0] ); } else { - return maybe_unserialize( $meta_cache[$key] ); + return array_map('maybe_unserialize', $meta_cache[$key]); } } - if ( !$meta_cache ) { - update_postmeta_cache($post_id); - $meta_cache = wp_cache_get($post_id, 'post_meta'); - } - - if ( $single ) { - if ( isset($meta_cache[$key][0]) ) - return maybe_unserialize($meta_cache[$key][0]); - else - return ''; - } else { - return maybe_unserialize($meta_cache[$key]); - } + return ''; } /** @@ -3297,7 +3290,7 @@ function _wp_put_post_revision( $post = null, $autosave = false ) { if ( !$post || empty($post['ID']) ) return; - if ( isset($post['post_type']) && 'revision' == $post_post['type'] ) + if ( isset($post['post_type']) && 'revision' == $post['post_type'] ) return new WP_Error( 'post_type', __( 'Cannot create a revision of a revision' ) ); $post = _wp_post_revision_fields( $post, $autosave ); diff --git a/wp-includes/query.php b/wp-includes/query.php index 35e53f3..e318020 100644 --- a/wp-includes/query.php +++ b/wp-includes/query.php @@ -775,7 +775,7 @@ class WP_Query { if ( !empty($qv['post_status']) )
$qv['post_status'] = preg_replace('|[^a-z0-9_,-]|', '', $qv['post_status']);
- if ( $this->is_posts_page && !$qv['withcomments'] )
+ if ( $this->is_posts_page && ( ! isset($qv['withcomments']) || ! $qv['withcomments'] ) )
$this->is_comment_feed = false;
$this->is_singular = $this->is_single || $this->is_page || $this->is_attachment;
@@ -829,7 +829,12 @@ class WP_Query { $join = '';
$search = '';
$groupby = '';
+ $fields = "$wpdb->posts.*";
$post_status_join = false;
+ $page = 1;
+
+ if ( !isset($q['suppress_filters']) )
+ $q['suppress_filters'] = false;
if ( !isset($q['post_type']) ) {
if ( $this->is_search )
@@ -1361,8 +1366,10 @@ class WP_Query { // Apply filters on where and join prior to paging so that any
// manipulations to them are reflected in the paging by day queries.
- $where = apply_filters('posts_where', $where);
- $join = apply_filters('posts_join', $join);
+ if ( !$q['suppress_filters'] ) {
+ $where = apply_filters('posts_where', $where);
+ $join = apply_filters('posts_join', $join);
+ }
// Paging
if ( empty($q['nopaging']) && !$this->is_singular ) {
@@ -1394,9 +1401,11 @@ class WP_Query { $cgroupby = '';
}
- $cjoin = apply_filters('comment_feed_join', $cjoin);
- $cwhere = apply_filters('comment_feed_where', $cwhere);
- $cgroupby = apply_filters('comment_feed_groupby', $cgroupby);
+ if ( !$q['suppress_filters'] ) {
+ $cjoin = apply_filters('comment_feed_join', $cjoin);
+ $cwhere = apply_filters('comment_feed_where', $cwhere);
+ $cgroupby = apply_filters('comment_feed_groupby', $cgroupby);
+ }
$this->comments = (array) $wpdb->get_results("SELECT $distinct $wpdb->comments.* FROM $wpdb->comments $cjoin $cwhere $cgroupby ORDER BY comment_date_gmt DESC LIMIT " . get_option('posts_per_rss'));
$this->comment_count = count($this->comments);
@@ -1414,28 +1423,33 @@ class WP_Query { $where = "AND 0";
}
+ $orderby = $q['orderby'];
+
// Apply post-paging filters on where and join. Only plugins that
// manipulate paging queries should use these hooks.
-
- $where = apply_filters('posts_where_paged', $where);
- $groupby = apply_filters('posts_groupby', $groupby);
- $join = apply_filters('posts_join_paged', $join);
- $orderby = apply_filters('posts_orderby', $q['orderby']);
- $distinct = apply_filters('posts_distinct', $distinct);
- $fields = apply_filters('posts_fields', "$wpdb->posts.*");
- $limits = apply_filters( 'post_limits', $limits );
+ if ( !$q['suppress_filters'] ) {
+ $where = apply_filters('posts_where_paged', $where);
+ $groupby = apply_filters('posts_groupby', $groupby);
+ $join = apply_filters('posts_join_paged', $join);
+ $orderby = apply_filters('posts_orderby', $orderby);
+ $distinct = apply_filters('posts_distinct', $distinct);
+ $fields = apply_filters('posts_fields', $fields);
+ $limits = apply_filters( 'post_limits', $limits );
+ }
// Announce current selection parameters. For use by caching plugins.
do_action( 'posts_selection', $where . $groupby . $orderby . $limits . $join );
// Filter again for the benefit of caching plugins. Regular plugins should use the hooks above.
- $where = apply_filters('posts_where_request', $where);
- $groupby = apply_filters('posts_groupby_request', $groupby);
- $join = apply_filters('posts_join_request', $join);
- $orderby = apply_filters('posts_orderby_request', $orderby);
- $distinct = apply_filters('posts_distinct_request', $distinct);
- $fields = apply_filters('posts_fields_request', $fields);
- $limits = apply_filters( 'post_limits_request', $limits );
+ if ( !$q['suppress_filters'] ) {
+ $where = apply_filters('posts_where_request', $where);
+ $groupby = apply_filters('posts_groupby_request', $groupby);
+ $join = apply_filters('posts_join_request', $join);
+ $orderby = apply_filters('posts_orderby_request', $orderby);
+ $distinct = apply_filters('posts_distinct_request', $distinct);
+ $fields = apply_filters('posts_fields_request', $fields);
+ $limits = apply_filters( 'post_limits_request', $limits );
+ }
if ( ! empty($groupby) )
$groupby = 'GROUP BY ' . $groupby;
@@ -1445,12 +1459,14 @@ class WP_Query { if ( !empty($limits) )
$found_rows = 'SQL_CALC_FOUND_ROWS';
- $request = " SELECT $found_rows $distinct $fields FROM $wpdb->posts $join WHERE 1=1 $where $groupby $orderby $limits";
- $this->request = apply_filters('posts_request', $request);
+ $this->request = " SELECT $found_rows $distinct $fields FROM $wpdb->posts $join WHERE 1=1 $where $groupby $orderby $limits";
+ if ( !$q['suppress_filters'] )
+ $this->request = apply_filters('posts_request', $this->request);
$this->posts = $wpdb->get_results($this->request);
// Raw results filter. Prior to status checks.
- $this->posts = apply_filters('posts_results', $this->posts);
+ if ( !$q['suppress_filters'] )
+ $this->posts = apply_filters('posts_results', $this->posts);
if ( !empty($this->posts) && $this->is_comment_feed && $this->is_singular ) {
$cjoin = apply_filters('comment_feed_join', '');
@@ -1497,7 +1513,8 @@ class WP_Query { }
}
- $this->posts = apply_filters('the_posts', $this->posts);
+ if ( !$q['suppress_filters'] )
+ $this->posts = apply_filters('the_posts', $this->posts);
update_post_caches($this->posts);
diff --git a/wp-includes/version.php b/wp-includes/version.php index 38e145a..bd8f64c 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -8,7 +8,7 @@ * * @global string $wp_version */ -$wp_version = '2.6.1'; +$wp_version = '2.6.2'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. @@ -17,5 +17,5 @@ $wp_version = '2.6.1'; */ $wp_db_version = 8204; -$wpmu_version = '2.6.1'; +$wpmu_version = '2.6.2'; ?> diff --git a/wp-includes/widgets.php b/wp-includes/widgets.php index 2a71a02..73e1f6e 100644 --- a/wp-includes/widgets.php +++ b/wp-includes/widgets.php @@ -1162,8 +1162,12 @@ function wp_widget_rss_output( $rss, $args = array() ) { $author = ' <cite>' . wp_specialchars( strip_tags( $item['author_name'] ) ) . '</cite>'; } - echo "<li><a class='rsswidget' href='$link' title='$desc'>$title</a>{$date}{$summary}{$author}</li>"; - } + if ( $link == '' ) { + echo "<li>$title{$date}{$summary}{$author}</li>"; + } else { + echo "<li><a class='rsswidget' href='$link' title='$desc'>$title</a>{$date}{$summary}{$author}</li>"; + } +} echo '</ul>'; } else { echo '<ul><li>' . __( 'An error has occurred; the feed is probably down. Try again later.' ) . '</li></ul>'; |