From 17be568a6d7395f229286d70e4c933259e9151c6 Mon Sep 17 00:00:00 2001 From: ryan Date: Thu, 10 May 2007 00:05:21 +0000 Subject: [PATCH] Don't preg_match_all when processing items. fixes #4239 for 2.3 git-svn-id: http://svn.automattic.com/wordpress/trunk@5423 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/import/wordpress.php | 37 +++++++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/wp-admin/import/wordpress.php b/wp-admin/import/wordpress.php index 3cb6eedbd5..deff943d77 100644 --- a/wp-admin/import/wordpress.php +++ b/wp-admin/import/wordpress.php @@ -84,19 +84,40 @@ class WP_Import { function get_entries() { set_magic_quotes_runtime(0); - $importdata = file($this->file); // Read the file into an array - $importdata = implode('', $importdata); // squish it - $importdata = preg_replace("/(\r\n|\n|\r)/", "\n", $importdata); - preg_match_all('|(.*?)|is', $importdata, $this->posts); - $this->posts = $this->posts[1]; + $importdata = array_map('rtrim', file($this->file)); // Read the file into an array + + $this->posts = array(); + $this->categories = array(); + $num = 0; + $doing_entry = false; + foreach ($importdata as $importline) { + if ( false !== strpos($importline, '') ) { + preg_match('|(.*?)|is', $importline, $category); + $this->categories[] = $category[1]; + continue; + } + if ( false !== strpos($importline, '') ) { + $this->posts[$num] = ''; + $doing_entry = true; + continue; + } + if ( false !== strpos($importline, '') ) { + $num++; + $doing_entry = false; + continue; + } + if ( $doing_entry ) { + $this->posts[$num] .= $importline . "\n"; + } + } + foreach ($this->posts as $post) { $post_ID = (int) $this->get_tag( $post, 'wp:post_id' ); - if ($post_ID) + if ($post_ID) { $this->posts_processed[$post_ID][0] = &$post; $this->posts_processed[$post_ID][1] = 0; + } } - preg_match_all('|(.*?)|is', $importdata, $this->categories); - $this->categories = $this->categories[1]; } function get_wp_authors() {