From 3ea5315ea94d245b2aa83df678c606d9e4c04614 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Sun, 15 Jul 2007 17:55:12 +0000 Subject: [PATCH] Don't slurp in entire file. Props tellyworth. see #4421 git-svn-id: https://develop.svn.wordpress.org/trunk@5802 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/import/wordpress.php | 59 ++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 26 deletions(-) diff --git a/wp-admin/import/wordpress.php b/wp-admin/import/wordpress.php index 746a8627e8..5ec0d04ce4 100644 --- a/wp-admin/import/wordpress.php +++ b/wp-admin/import/wordpress.php @@ -85,39 +85,46 @@ class WP_Import { function get_entries() { set_magic_quotes_runtime(0); - $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) { - $this->posts_processed[$post_ID][0] = &$post; - $this->posts_processed[$post_ID][1] = 0; + $fp = fopen($this->file, 'r'); + if ($fp) { + while ( !feof($fp) ) { + $importline = rtrim(fgets($fp)); + + 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) { + $this->posts_processed[$post_ID][0] = &$post; + $this->posts_processed[$post_ID][1] = 0; + } + } + + fclose($fp); } }