Ticket #21309: 21309.9.diff

File 21309.9.diff, 14.6 KB (added by ryan, 9 months ago)

Make sure get_default_post_to_edit() always returns WP_Post. Remove ref returns.

  • wp-includes/post-template.php

     
    101101 * @return string 
    102102 */ 
    103103function get_the_title( $id = 0 ) { 
    104         $post = &get_post($id); 
     104        $post = get_post($id); 
    105105 
    106106        $title = isset($post->post_title) ? $post->post_title : ''; 
    107107        $id = isset($post->ID) ? $post->ID : (int) $id; 
     
    148148 * @return string 
    149149 */ 
    150150function get_the_guid( $id = 0 ) { 
    151         $post = &get_post($id); 
     151        $post = get_post($id); 
    152152 
    153153        return apply_filters('get_the_guid', $post->guid); 
    154154} 
     
    276276 * @return bool 
    277277 */ 
    278278function has_excerpt( $id = 0 ) { 
    279         $post = &get_post( $id ); 
     279        $post = get_post( $id ); 
    280280        return ( !empty( $post->post_excerpt ) ); 
    281281} 
    282282 
     
    11381138 */ 
    11391139function wp_get_attachment_link( $id = 0, $size = 'thumbnail', $permalink = false, $icon = false, $text = false ) { 
    11401140        $id = intval( $id ); 
    1141         $_post = & get_post( $id ); 
     1141        $_post = get_post( $id ); 
    11421142 
    11431143        if ( empty( $_post ) || ( 'attachment' != $_post->post_type ) || ! $url = wp_get_attachment_url( $_post->ID ) ) 
    11441144                return __( 'Missing Attachment' ); 
  • wp-includes/taxonomy.php

     
    30733073 * @return array 
    30743074 */ 
    30753075function get_the_taxonomies($post = 0, $args = array() ) { 
    3076         if ( is_int($post) ) 
    3077                 $post =& get_post($post); 
    3078         elseif ( !is_object($post) ) 
    3079                 $post =& $GLOBALS['post']; 
     3076        $post = get_post( $post ); 
    30803077 
    30813078        $args = wp_parse_args( $args, array( 
    30823079                'template' => '%s: %l.', 
     
    31223119 * @return array 
    31233120 */ 
    31243121function get_post_taxonomies($post = 0) { 
    3125         $post =& get_post($post); 
     3122        $post = get_post( $post ); 
    31263123 
    31273124        return get_object_taxonomies($post); 
    31283125} 
  • wp-includes/post.php

     
    586586 * @return bool|string False on failure or returns the mime type 
    587587 */ 
    588588function get_post_mime_type($ID = '') { 
    589         $post = & get_post($ID); 
     589        $post = get_post($ID); 
    590590 
    591591        if ( is_object($post) ) 
    592592                return $post->post_mime_type; 
     
    37163716        if (strpos($url, home_url('/?attachment_id=')) !== false) 
    37173717                return true; 
    37183718        if ( $id = url_to_postid($url) ) { 
    3719                 $post = & get_post($id); 
     3719                $post = get_post($id); 
    37203720                if ( 'attachment' == $post->post_type ) 
    37213721                        return true; 
    37223722        } 
     
    40124012 */ 
    40134013function wp_get_attachment_metadata( $post_id = 0, $unfiltered = false ) { 
    40144014        $post_id = (int) $post_id; 
    4015         if ( !$post =& get_post( $post_id ) ) 
     4015        if ( !$post = get_post( $post_id ) ) 
    40164016                return false; 
    40174017 
    40184018        $data = get_post_meta( $post->ID, '_wp_attachment_metadata', true ); 
     
    40344034 */ 
    40354035function wp_update_attachment_metadata( $post_id, $data ) { 
    40364036        $post_id = (int) $post_id; 
    4037         if ( !$post =& get_post( $post_id ) ) 
     4037        if ( !$post = get_post( $post_id ) ) 
    40384038                return false; 
    40394039 
    40404040        $data = apply_filters( 'wp_update_attachment_metadata', $data, $post->ID ); 
     
    40524052 */ 
    40534053function wp_get_attachment_url( $post_id = 0 ) { 
    40544054        $post_id = (int) $post_id; 
    4055         if ( !$post =& get_post( $post_id ) ) 
     4055        if ( !$post = get_post( $post_id ) ) 
    40564056                return false; 
    40574057 
    40584058        if ( 'attachment' != $post->post_type ) 
     
    40914091 */ 
    40924092function wp_get_attachment_thumb_file( $post_id = 0 ) { 
    40934093        $post_id = (int) $post_id; 
    4094         if ( !$post =& get_post( $post_id ) ) 
     4094        if ( !$post = get_post( $post_id ) ) 
    40954095                return false; 
    40964096        if ( !is_array( $imagedata = wp_get_attachment_metadata( $post->ID ) ) ) 
    40974097                return false; 
     
    41134113 */ 
    41144114function wp_get_attachment_thumb_url( $post_id = 0 ) { 
    41154115        $post_id = (int) $post_id; 
    4116         if ( !$post =& get_post( $post_id ) ) 
     4116        if ( !$post = get_post( $post_id ) ) 
    41174117                return false; 
    41184118        if ( !$url = wp_get_attachment_url( $post->ID ) ) 
    41194119                return false; 
     
    41404140 */ 
    41414141function wp_attachment_is_image( $post_id = 0 ) { 
    41424142        $post_id = (int) $post_id; 
    4143         if ( !$post =& get_post( $post_id ) ) 
     4143        if ( !$post = get_post( $post_id ) ) 
    41444144                return false; 
    41454145 
    41464146        if ( !$file = get_attached_file( $post->ID ) ) 
     
    41714171                $post_mimes = array(); 
    41724172                if ( is_numeric($mime) ) { 
    41734173                        $mime = (int) $mime; 
    4174                         if ( $post =& get_post( $mime ) ) { 
     4174                        if ( $post = get_post( $mime ) ) { 
    41754175                                $post_id = (int) $post->ID; 
    41764176                                $ext = preg_replace('/^.+?\.([^.]+)$/', '$1', $post->guid); 
    41774177                                if ( !empty($ext) ) { 
  • wp-includes/comment.php

     
    13711371                if ( '0' == $commentdata['comment_approved'] ) 
    13721372                        wp_notify_moderator($comment_ID); 
    13731373 
    1374                 $post = &get_post($commentdata['comment_post_ID']); // Don't notify if it's your own comment 
     1374                $post = get_post($commentdata['comment_post_ID']); // Don't notify if it's your own comment 
    13751375 
    13761376                if ( get_option('comments_notify') && $commentdata['comment_approved'] && ( ! isset( $commentdata['user_id'] ) || $post->post_author != $commentdata['user_id'] ) ) 
    13771377                        wp_notify_postauthor($comment_ID, isset( $commentdata['comment_type'] ) ? $commentdata['comment_type'] : '' ); 
  • wp-includes/media.php

     
    655655                $hwstring = image_hwstring($width, $height); 
    656656                if ( is_array($size) ) 
    657657                        $size = join('x', $size); 
    658                 $attachment =& get_post($attachment_id); 
     658                $attachment = get_post($attachment_id); 
    659659                $default_attr = array( 
    660660                        'src'   => $src, 
    661661                        'class' => "attachment-$size", 
  • wp-includes/link-template.php

     
    9696                $post = $id; 
    9797                $sample = true; 
    9898        } else { 
    99                 $post = &get_post($id); 
     99                $post = get_post($id); 
    100100                $sample = false; 
    101101        } 
    102102 
     
    178178function get_post_permalink( $id = 0, $leavename = false, $sample = false ) { 
    179179        global $wp_rewrite; 
    180180 
    181         $post = &get_post($id); 
     181        $post = get_post($id); 
    182182 
    183183        if ( is_wp_error( $post ) ) 
    184184                return $post; 
     
    271271        if ( !$id ) 
    272272                $id = (int) $post->ID; 
    273273        else 
    274                 $post = &get_post($id); 
     274                $post = get_post($id); 
    275275 
    276276        $draft_or_pending = in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft' ) ); 
    277277 
     
    898898 * @return string 
    899899 */ 
    900900function get_edit_post_link( $id = 0, $context = 'display' ) { 
    901         if ( !$post = &get_post( $id ) ) 
     901        if ( !$post = get_post( $id ) ) 
    902902                return; 
    903903 
    904904        if ( 'display' == $context ) 
     
    927927 * @param int $id Optional. Post ID. 
    928928 */ 
    929929function edit_post_link( $link = null, $before = '', $after = '', $id = 0 ) { 
    930         if ( !$post = &get_post( $id ) ) 
     930        if ( !$post = get_post( $id ) ) 
    931931                return; 
    932932 
    933933        if ( !$url = get_edit_post_link( $post->ID ) ) 
     
    957957        if ( ! empty( $deprecated ) ) 
    958958                _deprecated_argument( __FUNCTION__, '3.0' ); 
    959959 
    960         if ( !$post = &get_post( $id ) ) 
     960        if ( !$post = get_post( $id ) ) 
    961961                return; 
    962962 
    963963        $post_type_object = get_post_type_object( $post->post_type ); 
     
    12041204 */ 
    12051205function get_adjacent_post_rel_link($title = '%title', $in_same_cat = false, $excluded_categories = '', $previous = true) { 
    12061206        if ( $previous && is_attachment() && is_object( $GLOBALS['post'] ) ) 
    1207                 $post = & get_post($GLOBALS['post']->post_parent); 
     1207                $post = get_post($GLOBALS['post']->post_parent); 
    12081208        else 
    12091209                $post = get_adjacent_post($in_same_cat,$excluded_categories,$previous); 
    12101210 
     
    13691369 */ 
    13701370function adjacent_post_link($format, $link, $in_same_cat = false, $excluded_categories = '', $previous = true) { 
    13711371        if ( $previous && is_attachment() ) 
    1372                 $post = & get_post($GLOBALS['post']->post_parent); 
     1372                $post = get_post($GLOBALS['post']->post_parent); 
    13731373        else 
    13741374                $post = get_adjacent_post($in_same_cat, $excluded_categories, $previous); 
    13751375 
  • wp-includes/general-template.php

     
    16271627 
    16281628        if ( is_single() || is_page() ) { 
    16291629                $id = 0; 
    1630                 $post = &get_post( $id ); 
     1630                $post = get_post( $id ); 
    16311631 
    16321632                if ( comments_open() || pings_open() || $post->comment_count > 0 ) { 
    16331633                        $title = sprintf( $args['singletitle'], get_bloginfo('name'), $args['separator'], esc_html( get_the_title() ) ); 
  • wp-includes/deprecated.php

     
    2626function get_postdata($postid) { 
    2727        _deprecated_function( __FUNCTION__, '1.5.1', 'get_post()' ); 
    2828 
    29         $post = &get_post($postid); 
     29        $post = get_post($postid); 
    3030 
    3131        $postdata = array ( 
    3232                'ID' => $post->ID, 
     
    18921892function get_the_attachment_link($id = 0, $fullsize = false, $max_dims = false, $permalink = false) { 
    18931893        _deprecated_function( __FUNCTION__, '2.5', 'wp_get_attachment_link()' ); 
    18941894        $id = (int) $id; 
    1895         $_post = & get_post($id); 
     1895        $_post = get_post($id); 
    18961896 
    18971897        if ( ('attachment' != $_post->post_type) || !$url = wp_get_attachment_url($_post->ID) ) 
    18981898                return __('Missing Attachment'); 
     
    19211921function get_attachment_icon_src( $id = 0, $fullsize = false ) { 
    19221922        _deprecated_function( __FUNCTION__, '2.5', 'wp_get_attachment_image_src()' ); 
    19231923        $id = (int) $id; 
    1924         if ( !$post = & get_post($id) ) 
     1924        if ( !$post = get_post($id) ) 
    19251925                return false; 
    19261926 
    19271927        $file = get_attached_file( $post->ID ); 
     
    19661966function get_attachment_icon( $id = 0, $fullsize = false, $max_dims = false ) { 
    19671967        _deprecated_function( __FUNCTION__, '2.5', 'wp_get_attachment_image()' ); 
    19681968        $id = (int) $id; 
    1969         if ( !$post = & get_post($id) ) 
     1969        if ( !$post = get_post($id) ) 
    19701970                return false; 
    19711971 
    19721972        if ( !$src = get_attachment_icon_src( $post->ID, $fullsize ) ) 
     
    20232023function get_attachment_innerHTML($id = 0, $fullsize = false, $max_dims = false) { 
    20242024        _deprecated_function( __FUNCTION__, '2.5', 'wp_get_attachment_image()' ); 
    20252025        $id = (int) $id; 
    2026         if ( !$post = & get_post($id) ) 
     2026        if ( !$post = get_post($id) ) 
    20272027                return false; 
    20282028 
    20292029        if ( $innerHTML = get_attachment_icon($post->ID, $fullsize, $max_dims)) 
     
    28012801        _deprecated_function( __FUNCTION__, '3.3' ); 
    28022802 
    28032803        if ( ! empty( $GLOBALS['post'] ) && ! empty( $GLOBALS['post']->post_parent ) ) 
    2804                 $post = & get_post($GLOBALS['post']->post_parent); 
     2804                $post = get_post($GLOBALS['post']->post_parent); 
    28052805 
    28062806        if ( empty($post) ) 
    28072807                return; 
  • wp-admin/includes/post.php

     
    160160 
    161161        // Autosave shouldn't save too soon after a real save 
    162162        if ( 'autosave' == $post_data['action'] ) { 
    163                 $post =& get_post( $post_ID ); 
     163                $post = get_post( $post_ID ); 
    164164                $now = time(); 
    165165                $then = strtotime($post->post_date_gmt . ' +0000'); 
    166166                $delta = AUTOSAVE_INTERVAL / 2; 
     
    439439                $post->page_template = 'default'; 
    440440                $post->post_parent = 0; 
    441441                $post->menu_order = 0; 
     442                $post = new WP_Post( $post ); 
    442443        } 
    443444 
    444445        $post->post_content = apply_filters( 'default_content', $post_content, $post ); 
     
    745746 * @return unknown 
    746747 */ 
    747748function _fix_attachment_links( $post_ID ) { 
    748         $post = & get_post( $post_ID, ARRAY_A ); 
     749        $post = get_post( $post_ID, ARRAY_A ); 
    749750        $content = $post['post_content']; 
    750751 
    751752        // quick sanity check, don't run if no pretty permalinks or post is not published 
     
    10121013 * @return array With two entries of type string 
    10131014 */ 
    10141015function get_sample_permalink($id, $title = null, $name = null) { 
    1015         $post = &get_post($id); 
     1016        $post = get_post($id); 
    10161017        if ( !$post->ID ) 
    10171018                return array('', ''); 
    10181019 
     
    10781079 */ 
    10791080function get_sample_permalink_html( $id, $new_title = null, $new_slug = null ) { 
    10801081        global $wpdb; 
    1081         $post = &get_post($id); 
     1082        $post = get_post($id); 
    10821083 
    10831084        list($permalink, $post_name) = get_sample_permalink($post->ID, $new_title, $new_slug); 
    10841085 
  • wp-admin/includes/template.php

     
    705705 */ 
    706706function the_attachment_links( $id = false ) { 
    707707        $id = (int) $id; 
    708         $post = & get_post( $id ); 
     708        $post = get_post( $id ); 
    709709 
    710710        if ( $post->post_type != 'attachment' ) 
    711711                return false; 
  • wp-admin/includes/media.php

     
    893893 * @return unknown 
    894894 */ 
    895895function image_media_send_to_editor($html, $attachment_id, $attachment) { 
    896         $post =& get_post($attachment_id); 
     896        $post = get_post($attachment_id); 
    897897        if ( substr($post->post_mime_type, 0, 5) == 'image' ) { 
    898898                $url = $attachment['url']; 
    899899                $align = !empty($attachment['align']) ? $attachment['align'] : 'none'; 
     
    920920 */ 
    921921function get_attachment_fields_to_edit($post, $errors = null) { 
    922922        if ( is_int($post) ) 
    923                 $post =& get_post($post); 
     923                $post = get_post($post); 
    924924        if ( is_array($post) ) 
    925                 $post = (object) $post; 
     925                $post = new WP_Post( (object) $post ); 
    926926 
    927927        $image_url = wp_get_attachment_url($post->ID); 
    928928 
  • wp-admin/post.php

     
    202202case 'trash': 
    203203        check_admin_referer('trash-post_' . $post_id); 
    204204 
    205         $post = & get_post($post_id); 
     205        $post = get_post($post_id); 
    206206 
    207207        if ( !current_user_can($post_type_object->cap->delete_post, $post_id) ) 
    208208                wp_die( __('You are not allowed to move this item to the Trash.') ); 
  • wp-admin/upload.php

     
    5757                        if ( !$parent_id ) 
    5858                                return; 
    5959 
    60                         $parent = &get_post( $parent_id ); 
     60                        $parent = get_post( $parent_id ); 
    6161                        if ( !current_user_can( 'edit_post', $parent_id ) ) 
    6262                                wp_die( __( 'You are not allowed to edit this post.' ) ); 
    6363 
  • wp-admin/edit.php

     
    103103                case 'delete': 
    104104                        $deleted = 0; 
    105105                        foreach( (array) $post_ids as $post_id ) { 
    106                                 $post_del = & get_post($post_id); 
     106                                $post_del = get_post($post_id); 
    107107 
    108108                                if ( !current_user_can($post_type_object->cap->delete_post, $post_id) ) 
    109109                                        wp_die( __('You are not allowed to delete this item.') );