Make WordPress Core

Ticket #10758: 10758.patch

File 10758.patch, 16.5 KB (added by hakre, 14 years ago)

consolidated patch

  • wp-admin/includes/post.php

    Property changes on: .
    ___________________________________________________________________
    Added: svn:ignore
       + wp-config.php
    
    
     
    925925 *
    926926 * @since unknown
    927927 *
    928  * @param unknown_type $id
    929  * @param unknown_type $title
    930  * @param unknown_type $name
    931  * @return unknown
     928 * @param int|object $id    Post ID or post object.
     929 * @param string $title (optional) Title
     930 * @param string $name (optional) Name
     931 * @return array With two entries of type string
    932932 */
    933933function get_sample_permalink($id, $title = null, $name = null) {
    934934        $post = &get_post($id);
     
    943943        // drafts, so we will fake, that our post is published
    944944        if (in_array($post->post_status, array('draft', 'pending'))) {
    945945                $post->post_status = 'publish';
    946                 $post->post_name = sanitize_title($post->post_name? $post->post_name : $post->post_title, $post->ID);
     946                $post->post_name = sanitize_title($post->post_name ? $post->post_name : $post->post_title, $post->ID);
    947947        }
    948948
    949949        $post->post_name = wp_unique_post_slug($post->post_name, $post->ID, $post->post_status, $post->post_type, $post->post_parent);
     
    951951        // If the user wants to set a new name -- override the current one
    952952        // Note: if empty name is supplied -- use the title instead, see #6072
    953953        if (!is_null($name)) {
    954                 $post->post_name = sanitize_title($name? $name : $title, $post->ID);
     954                $post->post_name = sanitize_title($name ? $name : $title, $post->ID);
    955955        }
    956956
    957957        $post->filter = 'sample';
     
    979979}
    980980
    981981/**
    982  * {@internal Missing Short Description}}
     982 * sample permalink html
    983983 *
     984 * intended to be used for the inplace editor of the permalink post slug on in the post (and page?) editor.
     985 *
    984986 * @since unknown
    985987 *
    986  * @param unknown_type $id
    987  * @param unknown_type $new_title
    988  * @param unknown_type $new_slug
    989  * @return unknown
     988 * @param int|object $id Post ID or post object.
     989 * @param string $new_title (optional) New title 
     990 * @param string $new_slug (optional) New slug
     991 * @return string intended to be used for the inplace editor of the permalink post slug on in the post (and page?) editor.
    990992 */
    991993function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) {
    992994        $post = &get_post($id);
  • wp-admin/includes/widgets.php

     
    180180        </div>
    181181        <input type="hidden" name="widget-id" class="widget-id" value="<?php echo esc_attr($id_format); ?>" />
    182182        <input type="hidden" name="id_base" class="id_base" value="<?php echo esc_attr($id_base); ?>" />
    183         <input type="hidden" name="widget-width" class="widget-width" value="<?php echo esc_attr($control['width']); ?>" />
    184         <input type="hidden" name="widget-height" class="widget-height" value="<?php echo esc_attr($control['height']); ?>" />
     183        <input type="hidden" name="widget-width" class="widget-width" value="<?php if (isset( $control['width'] )) echo esc_attr($control['width']); ?>" />
     184        <input type="hidden" name="widget-height" class="widget-height" value="<?php if (isset( $control['height'] )) echo esc_attr($control['height']); ?>" />
    185185        <input type="hidden" name="widget_number" class="widget_number" value="<?php echo esc_attr($widget_number); ?>" />
    186186        <input type="hidden" name="multi_number" class="multi_number" value="<?php echo esc_attr($multi_number); ?>" />
    187187        <input type="hidden" name="add_new" class="add_new" value="<?php echo esc_attr($add_new); ?>" />
  • wp-admin/admin-footer.php

     
    2929<?php
    3030do_action('admin_footer', '');
    3131do_action('admin_print_footer_scripts');
    32 do_action("admin_footer-$hook_suffix");
     32if (isset($hook_suffix))
     33        do_action("admin_footer-$hook_suffix");
    3334
    3435// get_site_option() won't exist when auto upgrading from <= 2.7
    3536if ( function_exists('get_site_option') ) {
  • wp-admin/upload.php

     
    308308
    309309        if ( $month_count && !( 1 == $month_count && 0 == $arc_result[0]->mmonth ) ) : ?>
    310310<select name='m'>
    311 <option<?php selected( @$_GET['m'], 0 ); ?> value='0'><?php _e('Show all dates'); ?></option>
     311<option<?php selected(isset($_GET['m']) ? $_GET['m'] : null, 0); ?> value='0'><?php _e('Show all dates'); ?></option>
    312312<?php
    313313foreach ($arc_result as $arc_row) {
    314314        if ( $arc_row->yyear == 0 )
  • wp-includes/author-template.php

     
    2222 */
    2323function get_the_author($deprecated = '') {
    2424        global $authordata;
    25         return apply_filters('the_author', $authordata->display_name);
     25        return apply_filters('the_author', is_object($authordata) ? $authordata->display_name : null);
    2626}
    2727
    2828/**
  • wp-includes/capabilities.php

     
    842842                $post_author_data = get_userdata( $post->post_author );
    843843                //echo "current user id : $user_id, post author id: " . $post_author_data->ID . "<br />";
    844844                // If the user is the author...
    845                 if ( $user_id == $post_author_data->ID ) {
     845                if ( is_object($post_author_data) && $user_id == $post_author_data->ID ) {
    846846                        // If the post is published...
    847847                        if ( 'publish' == $post->post_status ) {
    848848                                $caps[] = 'edit_published_posts';
  • wp-includes/comment.php

     
    11221122function wp_new_comment( $commentdata ) {
    11231123        $commentdata = apply_filters('preprocess_comment', $commentdata);
    11241124
    1125         $commentdata['comment_post_ID'] = (int) $commentdata['comment_post_ID'];
    1126         $commentdata['user_ID']         = (int) $commentdata['user_ID'];
     1125        $commentdata['comment_post_ID'] = isset($commentdata['comment_post_ID']) ? (int) $commentdata['comment_post_ID'] : null;
     1126        $commentdata['user_ID']         = isset($commentdata['user_ID'])         ? (int) $commentdata['user_ID']         : null;
    11271127
    1128         $commentdata['comment_parent'] = absint($commentdata['comment_parent']);
     1128        $commentdata['comment_parent'] = isset($commentdata['comment_parent']) ? absint($commentdata['comment_parent']) : null;
    11291129        $parent_status = ( 0 < $commentdata['comment_parent'] ) ? wp_get_comment_status($commentdata['comment_parent']) : '';
    11301130        $commentdata['comment_parent'] = ( 'approved' == $parent_status || 'unapproved' == $parent_status ) ? $commentdata['comment_parent'] : 0;
    11311131
  • wp-includes/functions.wp-styles.php

     
    1111 *
    1212 * @since r79
    1313 * @uses do_action() Calls 'wp_print_styles' hook.
    14  * @global object $wp_styles The WP_Styles object for printing styles.
     14 * @global WP_Styles $wp_styles The WP_Styles object for printing styles.
    1515 *
    1616 * @param array $handles (optional) Styles to be printed.  (void) prints queue, (string) prints that style, (array of strings) prints those styles.
    1717 * @return bool True on success, false on failure.
     
    2121        if ( '' === $handles ) // for wp_head
    2222                $handles = false;
    2323
     24        /* @var $wp_styles WP_Styles */
    2425        global $wp_styles;
    2526        if ( !is_a($wp_styles, 'WP_Styles') ) {
    2627                if ( !$handles )
     
    3738 *
    3839 * @since r79
    3940 * @see WP_Styles::add() For parameter and additional information.
     41 * @global WP_Styles $wp_styles
     42 * @return void
    4043 */
    4144function wp_register_style( $handle, $src, $deps = array(), $ver = false, $media = 'all' ) {
     45        /* @var $wp_styles WP_Styles */
    4246        global $wp_styles;
    4347        if ( !is_a($wp_styles, 'WP_Styles') )
    4448                $wp_styles = new WP_Styles();
     
    5155 *
    5256 * @since r79
    5357 * @see WP_Styles::remove() For parameter and additional information.
     58 * @global WP_Styles $wp_styles
    5459 */
    5560function wp_deregister_style( $handle ) {
     61        /* @var $wp_styles WP_Styles */
    5662        global $wp_styles;
    5763        if ( !is_a($wp_styles, 'WP_Styles') )
    5864                $wp_styles = new WP_Styles();
     
    6571 *
    6672 * @since r79
    6773 * @see WP_Styles::add(), WP_Styles::enqueue()
     74 * @global WP_Styles $wp_styles
    6875 */
    6976function wp_enqueue_style( $handle, $src = false, $deps = array(), $ver = false, $media = false ) {
     77        /* @var $wp_styles WP_Styles */
    7078        global $wp_styles;
    7179        if ( !is_a($wp_styles, 'WP_Styles') )
    7280                $wp_styles = new WP_Styles();
     
    8997 * @param string $handle Handle used to add style.
    9098 * @param string $list Optional, defaults to 'queue'. Others values are 'registered', 'queue', 'done', 'to_do'
    9199 * @return bool
     100 * @global WP_Styles $wp_styles
    92101 */
    93102function wp_style_is( $handle, $list = 'queue' ) {
     103        /* @var $wp_styles WP_Styles */
    94104        global $wp_styles;
    95105        if ( !is_a($wp_styles, 'WP_Styles') )
    96106                $wp_styles = new WP_Styles();
  • wp-includes/pluggable.php

     
    3535 * actions on users who aren't signed in.
    3636 *
    3737 * @since 2.0.3
    38  * @global object $current_user The current user object which holds the user data.
     38 * @global WP_User $current_user User-object of request aka The current user object which holds the user data.
    3939 * @uses do_action() Calls 'set_current_user' hook after setting the current user.
    4040 *
    4141 * @param int $id User ID
     
    4343 * @return WP_User Current user User object
    4444 */
    4545function wp_set_current_user($id, $name = '') {
     46        /* @var $current_user WP_User */
    4647        global $current_user;
    4748
    4849        if ( isset($current_user) && ($id == $current_user->ID) )
     
    6364 * Retrieve the current user object.
    6465 *
    6566 * @since 2.0.3
     67 * @global WP_User $current_user User-object of request aka The current user object which holds the user data.
    6668 *
    6769 * @return WP_User Current user WP_User object
    6870 */
    6971function wp_get_current_user() {
     72        /* @var $current_user WP_User */
    7073        global $current_user;
    7174
    7275        get_currentuserinfo();
     
    8487 * set the current user to 0, which is invalid and won't have any permissions.
    8588 *
    8689 * @since 0.71
    87  * @uses $current_user Checks if the current user is set
     90 * @global WP_User $current_user User-object of request aka The current user object which holds the user data.
    8891 * @uses wp_validate_auth_cookie() Retrieves current logged in user.
    8992 *
    90  * @return bool|null False on XMLRPC Request and invalid auth cookie. Null when current user set
     93 * @return bool|null False on XMLRPC Request and invalid auth cookie. Null when current user set or it was not empty
    9194 */
    9295function get_currentuserinfo() {
     96        /* @var $current_user WP_User */
    9397        global $current_user;
    9498
    9599        if ( defined('XMLRPC_REQUEST') && XMLRPC_REQUEST )
    96100                return false;
    97101
    98102        if ( ! empty($current_user) )
    99                 return;
     103                return null;
    100104
    101105        if ( ! $user = wp_validate_auth_cookie() ) {
    102106                 if ( empty($_COOKIE[LOGGED_IN_COOKIE]) || !$user = wp_validate_auth_cookie($_COOKIE[LOGGED_IN_COOKIE], 'logged_in') ) {
     
    106110        }
    107111
    108112        wp_set_current_user($user);
     113
     114        return null;
    109115}
    110116endif;
    111117
     
    12231229 * @return string The one use form token
    12241230 */
    12251231function wp_create_nonce($action = -1) {
     1232        /* @var $user WP_User */
    12261233        $user = wp_get_current_user();
    1227         $uid = (int) $user->id;
    12281234
     1235        if ( is_object($user) )
     1236                $uid = (int) $user->id;
     1237        else
     1238                $uid = 0;
     1239
    12291240        $i = wp_nonce_tick();
    12301241
    12311242        return substr(wp_hash($i . $action . $uid, 'nonce'), -12, 10);
  • wp-includes/post.php

     
    18111811/**
    18121812 * Given the desired slug and some post details computes a unique slug for the post.
    18131813 *
     1814 * @global wpdb $wpdb
     1815 * @global WP_Rewrite $wp_rewrite
    18141816 * @param string $slug the desired slug (post_name)
    18151817 * @param integer $post_ID
    18161818 * @param string $post_status no uniqueness checks are made if the post is still draft or pending
     
    18221824        if ( in_array( $post_status, array( 'draft', 'pending' ) ) )
    18231825                return $slug;
    18241826
     1827        /* @var $wp_rewrite WP_Rewrite
     1828         * @var $wpdb wpdb */
    18251829        global $wpdb, $wp_rewrite;
     1830       
    18261831        $hierarchical_post_types = apply_filters('hierarchical_post_types', array('page'));
    18271832        if ( 'attachment' == $post_type ) {
    18281833                // Attachment slugs must be unique across all types.
    18291834                $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND ID != %d LIMIT 1";
    18301835                $post_name_check = $wpdb->get_var($wpdb->prepare($check_sql, $slug, $post_ID));
    18311836
    1832                 if ( $post_name_check || in_array($slug, $wp_rewrite->feeds) ) {
     1837                $feeds = $wp_rewrite->feeds;
     1838                if ( is_null($feeds) )
     1839                        $feeds = array();
     1840               
     1841                if ( $post_name_check || in_array($slug, $feeds) ) {
    18331842                        $suffix = 2;
    18341843                        do {
    18351844                                $alt_post_name = substr($slug, 0, 200-(strlen($suffix)+1)). "-$suffix";
     
    18431852                // separate namespace than posts so page slugs are allowed to overlap post slugs.
    18441853                $check_sql = "SELECT post_name FROM $wpdb->posts WHERE post_name = %s AND post_type IN ( '" . implode("', '", esc_sql($hierarchical_post_types)) . "' ) AND ID != %d AND post_parent = %d LIMIT 1";
    18451854                $post_name_check = $wpdb->get_var($wpdb->prepare($check_sql, $slug, $post_ID, $post_parent));
     1855               
     1856                $feeds = $wp_rewrite->feeds;
     1857                if ( is_null($feeds) )
     1858                        $feeds = array();
    18461859
    1847                 if ( $post_name_check || in_array($slug, $wp_rewrite->feeds) ) {
     1860                if ( $post_name_check || in_array($slug, $feeds) ) {
    18481861                        $suffix = 2;
    18491862                        do {
    18501863                                $alt_post_name = substr($slug, 0, 200-(strlen($suffix)+1)). "-$suffix";
  • wp-includes/vars.php

     
    3737// Simple browser detection
    3838$is_lynx = $is_gecko = $is_winIE = $is_macIE = $is_opera = $is_NS4 = $is_safari = $is_chrome = $is_iphone = false;
    3939
     40if ( !isset($_SERVER['HTTP_USER_AGENT']) )
     41        $_SERVER['HTTP_USER_AGENT'] = '';
     42
    4043if (strpos($_SERVER['HTTP_USER_AGENT'], 'Lynx') !== false) {
    4144        $is_lynx = true;
    4245} elseif ( strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'chrome') !== false ) {
  • wp-comments-post.php

     
    1717
    1818nocache_headers();
    1919
    20 $comment_post_ID = (int) $_POST['comment_post_ID'];
     20$comment_post_ID = isset ($_POST['comment_post_ID']) ? (int) $_POST['comment_post_ID'] : null;
    2121
    2222$status = $wpdb->get_row( $wpdb->prepare("SELECT post_status, comment_status FROM $wpdb->posts WHERE ID = %d", $comment_post_ID) );
    2323
  • wp-trackback.php

     
    3636// trackback is done by a POST
    3737$request_array = 'HTTP_POST_VARS';
    3838
    39 if ( !$_GET['tb_id'] ) {
     39if ( !isset($_GET['tb_id']) || !$_GET['tb_id'] ) {
    4040        $tb_id = explode('/', $_SERVER['REQUEST_URI']);
    4141        $tb_id = intval( $tb_id[ count($tb_id) - 1 ] );
    4242}
    4343
    44 $tb_url  = $_POST['url'];
    45 $charset = $_POST['charset'];
     44$tb_url  = isset($_POST['url'])     ? $_POST['url']     : '';
     45$charset = isset($_POST['charset']) ? $_POST['charset'] : '';
    4646
    4747// These three are stripslashed here so that they can be properly escaped after mb_convert_encoding()
    48 $title     = stripslashes($_POST['title']);
    49 $excerpt   = stripslashes($_POST['excerpt']);
    50 $blog_name = stripslashes($_POST['blog_name']);
     48$title     = isset($_POST['title'])     ? stripslashes($_POST['title'])      : '';
     49$excerpt   = isset($_POST['excerpt'])   ? stripslashes($_POST['excerpt'])    : '';
     50$blog_name = isset($_POST['blog_name']) ? stripslashes($_POST['blog_name'])  : '';
    5151
    5252if ($charset)
    5353        $charset = strtoupper( trim($charset) );
     
    7272if ( is_single() || is_page() )
    7373        $tb_id = $posts[0]->ID;
    7474
    75 if ( !intval( $tb_id ) )
     75if ( !isset($tb_id) || !intval( $tb_id ) )
    7676        trackback_response(1, 'I really need an ID for this to work.');
    7777
    7878if (empty($title) && empty($tb_url) && empty($blog_name)) {