Ticket #4421: import-memory-reduction-r6606.patch
| File import-memory-reduction-r6606.patch, 2.1 kB (added by tellyworth, 1 year ago) |
|---|
-
wp-admin/import/wordpress.php
old new 69 69 70 70 function get_entries() { 71 71 set_magic_quotes_runtime(0); 72 $importdata = array_map('rtrim', file($this->file)); // Read the file into an array73 72 74 73 $this->posts = array(); 75 74 $this->categories = array(); 76 75 $num = 0; 77 76 $doing_entry = false; 78 foreach ($importdata as $importline) { 79 if ( false !== strpos($importline, '<wp:category>') ) { 80 preg_match('|<wp:category>(.*?)</wp:category>|is', $importline, $category); 81 $this->categories[] = $category[1]; 82 continue; 77 78 $fp = fopen($this->file, 'r'); 79 if ($fp) { 80 while ( !feof($fp) ) { 81 $importline = rtrim(fgets($fp)); 82 83 if ( false !== strpos($importline, '<wp:category>') ) { 84 preg_match('|<wp:category>(.*?)</wp:category>|is', $importline, $category); 85 $this->categories[] = $category[1]; 86 continue; 87 } 88 if ( false !== strpos($importline, '<item>') ) { 89 $this->posts[$num] = ''; 90 $doing_entry = true; 91 continue; 92 } 93 if ( false !== strpos($importline, '</item>') ) { 94 $num++; 95 $doing_entry = false; 96 continue; 97 } 98 if ( $doing_entry ) { 99 $this->posts[$num] .= $importline . "\n"; 100 } 83 101 } 84 if ( false !== strpos($importline, '<item>') ) { 85 $this->posts[$num] = ''; 86 $doing_entry = true; 87 continue; 102 103 foreach ($this->posts as $post) { 104 $post_ID = (int) $this->get_tag( $post, 'wp:post_id' ); 105 if ($post_ID) { 106 $this->posts_processed[$post_ID][0] = &$post; 107 $this->posts_processed[$post_ID][1] = 0; 108 } 88 109 } 89 if ( false !== strpos($importline, '</item>') ) {90 $num++;91 $doing_entry = false;92 continue;93 }94 if ( $doing_entry ) {95 $this->posts[$num] .= $importline . "\n";96 }97 }98 110 99 foreach ($this->posts as $post) { 100 $post_ID = (int) $this->get_tag( $post, 'wp:post_id' ); 101 if ($post_ID) { 102 $this->posts_processed[$post_ID][0] = &$post; 103 $this->posts_processed[$post_ID][1] = 0; 104 } 111 fclose($fp); 105 112 } 106 113 } 107 114
