Ticket #4239: no_pref.diff

File no_pref.diff, 1.7 KB (added by ryan, 5 years ago)
  • wp-admin/import/wordpress.php

     
    8484 
    8585        function get_entries() { 
    8686                set_magic_quotes_runtime(0); 
    87                 $importdata = file($this->file); // Read the file into an array 
    88                 $importdata = implode('', $importdata); // squish it 
    89                 $importdata = preg_replace("/(\r\n|\n|\r)/", "\n", $importdata); 
    90                 preg_match_all('|<item>(.*?)</item>|is', $importdata, $this->posts); 
    91                 $this->posts = $this->posts[1]; 
     87                $importdata = array_map('rtrim', file($this->file)); // Read the file into an array 
     88 
     89                $this->posts = array(); 
     90                $this->categories = array(); 
     91                $num = 0; 
     92                $doing_entry = false; 
     93                foreach ($importdata as $importline) { 
     94                        if ( false !== strpos($importline, '<wp:category>') ) { 
     95                                preg_match('|<wp:category>(.*?)</wp:category>|is', $importline, $category); 
     96                                $this->categories[] = $category[1]; 
     97                                continue; 
     98                        } 
     99                        if ( false !== strpos($importline, '<item>') ) { 
     100                                $this->posts[$num] = ''; 
     101                                $doing_entry = true; 
     102                                continue;        
     103                        } 
     104                        if ( false !== strpos($importline, '</item>') ) { 
     105                                $num++; 
     106                                $doing_entry = false; 
     107                                continue;        
     108                        } 
     109                        if ( $doing_entry ) { 
     110                                $this->posts[$num] .= $importline . "\n"; 
     111                        } 
     112                } 
     113 
    92114                foreach ($this->posts as $post) { 
    93115                        $post_ID = (int) $this->get_tag( $post, 'wp:post_id' ); 
    94                         if ($post_ID) 
     116                        if ($post_ID) { 
    95117                                $this->posts_processed[$post_ID][0] = &$post; 
    96118                                $this->posts_processed[$post_ID][1] = 0; 
     119                        } 
    97120                } 
    98                 preg_match_all('|<wp:category>(.*?)</wp:category>|is', $importdata, $this->categories); 
    99                 $this->categories = $this->categories[1]; 
    100121        } 
    101122 
    102123        function get_wp_authors() {