Make WordPress Core

Ticket #13458: 13458_2.diff

File 13458_2.diff, 6.8 KB (added by ampt, 16 years ago)

Additional undefined index fixes, change filename to match ticket

  • wp-admin/import/blogger.php

     
    162162                                        if ( $tag['tag'] == 'TITLE' ) {
    163163                                                $blog['title'] = $tag['value'];
    164164                                        } elseif ( $tag['tag'] == 'SUMMARY' ) {
    165                                                 $blog['summary'] = $tag['value'];
     165                                                $blog['summary'] = ( isset( $tag['value'] ) ) ? $tag['value'] : '';
    166166                                        } elseif ( $tag['tag'] == 'LINK' ) {
    167167                                                if ( $tag['attributes']['REL'] == 'alternate' && $tag['attributes']['TYPE'] == 'text/html' ) {
    168168                                                        $parts = parse_url( $tag['attributes']['HREF'] );
     
    205205                $posts    = __('Posts');
    206206                $comments = __('Comments');
    207207                $noscript = __('This feature requires Javascript but it seems to be disabled. Please enable Javascript and then reload this page. Don’t worry, you can turn it back off when you’re done.');
     208                $init     = '';
     209                $rows     = '';
    208210
    209211                $interval = STATUS_INTERVAL * 1000;
    210212
     
    499501                                                if ( preg_match('/rel=.previous./', $match) )
    500502                                                        $query = @html_entity_decode( preg_replace('/^.*href=[\'"].*\?(.+)[\'"].*$/', '$1', $match), ENT_COMPAT, get_option('blog_charset') );
    501503
    502                                 parse_str($query, $q);
    503 
    504                                 $this->blogs[$importing_blog]['comments_start_index'] = (int) $q['start-index'];
     504                                if ( $query ) {
     505                                        parse_str($query, $q);
     506                                        $this->blogs[$importing_blog]['comments_start_index'] = (int) $q['start-index'];
     507                                } else
     508                                        $this->blogs[$importing_blog]['comments_start_index'] = 0;
    505509                                $this->save_vars();
    506510                        } while ( !empty( $query ) && $this->have_time() );
    507511                }
     
    560564                $post_content = str_replace('<br>', '<br />', $post_content);
    561565                $post_content = str_replace('<hr>', '<hr />', $post_content);
    562566
     567                if( !isset( $this->blogs[$importing_blog]['posts_skipped'] ) ) {
     568                        $this->blogs[$importing_blog]['posts_skipped'] = 0;
     569                }
     570
    563571                // Checks for duplicates
    564572                if ( isset( $this->blogs[$importing_blog]['posts'][$entry->old_permalink] ) ) {
    565573                        ++$this->blogs[$importing_blog]['posts_skipped'];
     
    582590                        add_post_meta( $post_id, 'blogger_permalink', $entry->old_permalink, true );
    583591
    584592                        $this->blogs[$importing_blog]['posts'][$entry->old_permalink] = $post_id;
     593                        if( !isset( $this->blogs[$importing_blog]['posts_done'] ) ) {
     594                                $this->blogs[$importing_blog]['posts_done'] = 0;
     595                        }
    585596                        ++$this->blogs[$importing_blog]['posts_done'];
    586597                }
    587598                $this->save_vars();
     
    602613                }
    603614
    604615                $comment_post_ID = (int) $this->blogs[$importing_blog]['posts'][$entry->old_post_permalink];
    605                 preg_match('#<name>(.+?)</name>.*(?:\<uri>(.+?)</uri>)?#', $entry->author, $matches);
     616                preg_match('#<name>(.+?)</name>.*?(?:\<uri>(.+?)</uri>)?#', $entry->author, $matches);
     617
     618                // Not all comments have an author url
     619                $comment_author_url = isset( $matches[2] ) ? $matches[2] : '';
     620
    606621                $comment_author  = addslashes( $this->no_apos( strip_tags( (string) $matches[1] ) ) );
    607                 $comment_author_url = addslashes( $this->no_apos( strip_tags( (string) $matches[2] ) ) );
     622                $comment_author_url = addslashes( $this->no_apos( strip_tags( (string) $comment_author_url ) ) );
    608623                $comment_date    = $this->convert_date( $entry->updated );
    609624                $comment_content = addslashes( $this->no_apos( @html_entity_decode( $entry->content, ENT_COMPAT, get_option('blog_charset') ) ) );
    610625
     
    618633                        isset( $this->blogs[$importing_blog]['comments'][$entry->old_permalink] ) ||
    619634                        comment_exists( $comment_author, $comment_date )
    620635                ) {
     636                        if( !isset( $this->blogs[$importing_blog]['comments_skipped'] ) ) {
     637                                $this->blogs[$importing_blog]['comments_skipped'] = 0;
     638                        }
    621639                        ++$this->blogs[$importing_blog]['comments_skipped'];
    622640                } else {
    623641                        $comment = compact('comment_post_ID', 'comment_author', 'comment_author_url', 'comment_date', 'comment_content');
     
    627645
    628646                        $this->blogs[$importing_blog]['comments'][$entry->old_permalink] = $comment_id;
    629647
     648                        if( !isset( $this->blogs[$importing_blog]['comments_done'] ) ) {
     649                                $this->blogs[$importing_blog]['comments_done'] = 0;
     650                        }
     651
    630652                        ++$this->blogs[$importing_blog]['comments_done'];
    631653                }
    632654                $this->save_vars();
     
    665687                $mapthis = __('Blogger username');
    666688                $tothis = __('WordPress login');
    667689                $submit = esc_js( __('Save Changes') );
     690                $rows = '';
    668691
    669692                foreach ( $blog['authors'] as $i => $author )
    670693                        $rows .= "<tr><td><label for='authors[$i]'>{$author[0]}</label></td><td><select name='authors[$i]' id='authors[$i]'>" . $this->get_user_options($author[1]) . "</select></td></tr>";
     
    674697
    675698        function get_user_options($current) {
    676699                global $importer_users;
     700                $options = '';
    677701                if ( ! isset( $importer_users ) )
    678702                        $importer_users = (array) get_users_of_blog();
    679703
     
    743767        }
    744768
    745769        function _txrx( $sock, $request ) {
     770                $response = '';
    746771                fwrite( $sock, $request );
    747772                while ( ! feof( $sock ) )
    748773                        $response .= @ fread ( $sock, 8192 );
     
    787812                $response_header_array = array();
    788813                foreach($response_header_lines as $header_line) {
    789814                        list($header,$value) = explode(': ', $header_line, 2);
    790                         $response_header_array[$header] .= $value."\n";
     815                        $response_header_array[$header] = $value."\n";
    791816                }
    792817
    793818                $cookie_array = array();
    794                 $cookies = explode("\n", $response_header_array["Set-Cookie"]);
     819                $cookies = array();
     820                if( isset($response_header_array["Set-Cookie"]) ) {
     821                        $cookies = explode("\n", $response_header_array["Set-Cookie"]);
     822                }
    795823                foreach($cookies as $this_cookie) { array_push($cookie_array, "Cookie: ".$this_cookie); }
    796824
    797825                return array("code" => $response_code, "header" => $response_header_array, "cookies" => $cookie_array, "body" => $response_body);
     
    9831011                        array_push($this->in_content, "<". $this->ns_to_prefix($name) ."{$xmlns_str}{$attrs_str}");
    9841012                } else if (in_array($tag, $this->ATOM_CONTENT_ELEMENTS) || in_array($tag, $this->ATOM_SIMPLE_ELEMENTS)) {
    9851013                        $this->in_content = array();
    986                         $this->is_xhtml = $attrs['type'] == 'xhtml';
     1014                       
     1015                        if( isset( $attrs['type'] ) ) {
     1016                                $this->is_xhtml = $attrs['type'] == 'xhtml';
     1017                        } else {
     1018                                $this->is_xhtml = false;
     1019                        }
     1020
    9871021                        array_push($this->in_content, array($tag,$this->depth));
    9881022                } else if ($tag == 'link') {
    9891023                        array_push($this->entry->links, $attrs);
     
    10361070        function cdata($parser, $data) {
    10371071                #print str_repeat(" ", $this->depth * $this->indent) . "data: #" . $data . "#\n";
    10381072                if (!empty($this->in_content)) {
     1073                        $in_content = $this->in_content[count($this->in_content)-1];
     1074                        if( is_array( $in_content ) ) {
     1075                                $in_content = $in_content[0];
     1076                        }
     1077
    10391078                        // handle self-closing tags (case: text node found, need to close element started)
    1040                         if (strpos($this->in_content[count($this->in_content)-1], '<') !== false) {
     1079                        if (strpos($in_content, '<') !== false) {
    10411080                                array_push($this->in_content, ">");
    10421081                        }
    10431082                        array_push($this->in_content, $this->xml_escape($data));