commit:     a3f92de33bff286d20fde5c575e407fcb3d58c2b
Author:     Anthony G. Basile <blueness <AT> gentoo <DOT> org>
AuthorDate: Sun Mar 11 00:20:38 2018 +0000
Commit:     Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Sun Mar 11 00:20:38 2018 +0000
URL:        https://gitweb.gentoo.org/proj/blogs-gentoo.git/commit/?id=a3f92de3

Update wordpress-importer 0.6.4

Signed-off-by: Anthony G. Basile <blueness <AT> gentoo.org>

 .../languages/wordpress-importer.pot               | 239 ---------------------
 plugins/wordpress-importer/parsers.php             |  61 +++---
 plugins/wordpress-importer/readme.txt              |  23 +-
 plugins/wordpress-importer/wordpress-importer.php  |  30 ++-
 4 files changed, 69 insertions(+), 284 deletions(-)

diff --git a/plugins/wordpress-importer/languages/wordpress-importer.pot 
b/plugins/wordpress-importer/languages/wordpress-importer.pot
deleted file mode 100644
index 97f2d76..0000000
--- a/plugins/wordpress-importer/languages/wordpress-importer.pot
+++ /dev/null
@@ -1,239 +0,0 @@
-# Copyright (C) 2016 WordPress Importer
-# This file is distributed under the same license as the WordPress Importer 
package.
-msgid ""
-msgstr ""
-"Project-Id-Version: WordPress Importer 0.6.3\n"
-"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/wordpress-";
-"importer\n"
-"POT-Creation-Date: 2016-08-19 13:28:24+00:00\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=UTF-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-"PO-Revision-Date: 2016-MO-DA HO:MI+ZONE\n"
-"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
-"Language-Team: LANGUAGE <[email protected]>\n"
-
-#: parsers.php:42 parsers.php:72 parsers.php:80
-msgid "There was an error when reading this WXR file"
-msgstr ""
-
-#: parsers.php:43
-msgid ""
-"Details are shown above. The importer will now try again with a different "
-"parser..."
-msgstr ""
-
-#: parsers.php:84 parsers.php:89 parsers.php:306 parsers.php:495
-msgid ""
-"This does not appear to be a WXR file, missing/invalid WXR version number"
-msgstr ""
-
-#: wordpress-importer.php:132 wordpress-importer.php:141
-#: wordpress-importer.php:192 wordpress-importer.php:196
-#: wordpress-importer.php:205
-msgid "Sorry, there has been an error."
-msgstr ""
-
-#: wordpress-importer.php:133
-msgid "The file does not exist, please try again."
-msgstr ""
-
-#: wordpress-importer.php:176
-msgid "All done."
-msgstr ""
-
-#: wordpress-importer.php:176
-msgid "Have fun!"
-msgstr ""
-
-#: wordpress-importer.php:177
-msgid "Remember to update the passwords and roles of imported users."
-msgstr ""
-
-#: wordpress-importer.php:197
-msgid ""
-"The export file could not be found at <code>%s</code>. It is likely that "
-"this was caused by a permissions problem."
-msgstr ""
-
-#: wordpress-importer.php:213
-msgid ""
-"This WXR file (version %s) may not be supported by this version of the "
-"importer. Please consider updating."
-msgstr ""
-
-#: wordpress-importer.php:238
-msgid ""
-"Failed to import author %s. Their posts will be attributed to the current "
-"user."
-msgstr ""
-
-#: wordpress-importer.php:264
-msgid "Assign Authors"
-msgstr ""
-
-#: wordpress-importer.php:265
-msgid ""
-"To make it easier for you to edit and save the imported content, you may "
-"want to reassign the author of the imported item to an existing user of this "
-"site. For example, you may want to import all the entries as <code>admin</"
-"code>s entries."
-msgstr ""
-
-#: wordpress-importer.php:267
-msgid ""
-"If a new user is created by WordPress, a new password will be randomly "
-"generated and the new user&#8217;s role will be set as %s. Manually changing "
-"the new user&#8217;s details will be necessary."
-msgstr ""
-
-#: wordpress-importer.php:277
-msgid "Import Attachments"
-msgstr ""
-
-#: wordpress-importer.php:280
-msgid "Download and import file attachments"
-msgstr ""
-
-#: wordpress-importer.php:284
-msgid "Submit"
-msgstr ""
-
-#: wordpress-importer.php:297
-msgid "Import author:"
-msgstr ""
-
-#: wordpress-importer.php:308
-msgid "or create new user with login name:"
-msgstr ""
-
-#: wordpress-importer.php:311
-msgid "as a new user:"
-msgstr ""
-
-#: wordpress-importer.php:319
-msgid "assign posts to an existing user:"
-msgstr ""
-
-#: wordpress-importer.php:321
-msgid "or assign posts to an existing user:"
-msgstr ""
-
-#: wordpress-importer.php:322
-msgid "- Select -"
-msgstr ""
-
-#: wordpress-importer.php:372
-msgid ""
-"Failed to create new user for %s. Their posts will be attributed to the "
-"current user."
-msgstr ""
-
-#: wordpress-importer.php:424
-msgid "Failed to import category %s"
-msgstr ""
-
-#: wordpress-importer.php:467
-msgid "Failed to import post tag %s"
-msgstr ""
-
-#: wordpress-importer.php:516 wordpress-importer.php:738
-msgid "Failed to import %s %s"
-msgstr ""
-
-#: wordpress-importer.php:605
-msgid "Failed to import &#8220;%s&#8221;: Invalid post type %s"
-msgstr ""
-
-#: wordpress-importer.php:642
-msgid "%s &#8220;%s&#8221; already exists."
-msgstr ""
-
-#: wordpress-importer.php:704
-msgid "Failed to import %s &#8220;%s&#8221;"
-msgstr ""
-
-#: wordpress-importer.php:869
-msgid "Menu item skipped due to missing menu slug"
-msgstr ""
-
-#: wordpress-importer.php:876
-msgid "Menu item skipped due to invalid menu slug: %s"
-msgstr ""
-
-#: wordpress-importer.php:939
-msgid "Fetching attachments is not enabled"
-msgstr ""
-
-#: wordpress-importer.php:952
-msgid "Invalid file type"
-msgstr ""
-
-#: wordpress-importer.php:996
-msgid "Remote server did not respond"
-msgstr ""
-
-#: wordpress-importer.php:1002
-msgid "Remote server returned error response %1$d %2$s"
-msgstr ""
-
-#: wordpress-importer.php:1009
-msgid "Remote file is incorrect size"
-msgstr ""
-
-#: wordpress-importer.php:1014
-msgid "Zero size file downloaded"
-msgstr ""
-
-#: wordpress-importer.php:1020
-msgid "Remote file is too large, limit is %s"
-msgstr ""
-
-#: wordpress-importer.php:1119
-msgid "Import WordPress"
-msgstr ""
-
-#: wordpress-importer.php:1126
-msgid ""
-"A new version of this importer is available. Please update to version %s to "
-"ensure compatibility with newer export files."
-msgstr ""
-
-#: wordpress-importer.php:1141
-msgid ""
-"Howdy! Upload your WordPress eXtended RSS (WXR) file and we&#8217;ll import "
-"the posts, pages, comments, custom fields, categories, and tags into this "
-"site."
-msgstr ""
-
-#: wordpress-importer.php:1142
-msgid "Choose a WXR (.xml) file to upload, then click Upload file and import."
-msgstr ""
-
-#: wordpress-importer.php:1216
-msgid ""
-"Import <strong>posts, pages, comments, custom fields, categories, and tags</"
-"strong> from a WordPress export file."
-msgstr ""
-
-#. Plugin Name of the plugin/theme
-msgid "WordPress Importer"
-msgstr ""
-
-#. Plugin URI of the plugin/theme
-msgid "http://wordpress.org/extend/plugins/wordpress-importer/";
-msgstr ""
-
-#. Description of the plugin/theme
-msgid ""
-"Import posts, pages, comments, custom fields, categories, tags and more from "
-"a WordPress export file."
-msgstr ""
-
-#. Author of the plugin/theme
-msgid "wordpressdotorg"
-msgstr ""
-
-#. Author URI of the plugin/theme
-msgid "http://wordpress.org/";
-msgstr ""

diff --git a/plugins/wordpress-importer/parsers.php 
b/plugins/wordpress-importer/parsers.php
index fab101e..b9d0e7a 100644
--- a/plugins/wordpress-importer/parsers.php
+++ b/plugins/wordpress-importer/parsers.php
@@ -437,7 +437,16 @@ class WXR_Parser_Regex {
        }
 
        function parse( $file ) {
-               $wxr_version = $in_post = false;
+               $wxr_version = $in_multiline = false;
+
+               $multiline_content = '';
+
+               $multiline_tags = array(
+                       'item'        => array( 'posts', array( $this, 
'process_post' ) ),
+                       'wp:category' => array( 'categories', array( $this, 
'process_category' ) ),
+                       'wp:tag'      => array( 'tags', array( $this, 
'process_tag' ) ),
+                       'wp:term'     => array( 'terms', array( $this, 
'process_term' ) ),
+               );
 
                $fp = $this->fopen( $file, 'r' );
                if ( $fp ) {
@@ -452,39 +461,37 @@ class WXR_Parser_Regex {
                                        $this->base_url = $url[1];
                                        continue;
                                }
-                               if ( false !== strpos( $importline, 
'<wp:category>' ) ) {
-                                       preg_match( 
'|<wp:category>(.*?)</wp:category>|is', $importline, $category );
-                                       $this->categories[] = 
$this->process_category( $category[1] );
-                                       continue;
-                               }
-                               if ( false !== strpos( $importline, '<wp:tag>' 
) ) {
-                                       preg_match( 
'|<wp:tag>(.*?)</wp:tag>|is', $importline, $tag );
-                                       $this->tags[] = $this->process_tag( 
$tag[1] );
-                                       continue;
-                               }
-                               if ( false !== strpos( $importline, '<wp:term>' 
) ) {
-                                       preg_match( 
'|<wp:term>(.*?)</wp:term>|is', $importline, $term );
-                                       $this->terms[] = $this->process_term( 
$term[1] );
-                                       continue;
-                               }
+
                                if ( false !== strpos( $importline, 
'<wp:author>' ) ) {
                                        preg_match( 
'|<wp:author>(.*?)</wp:author>|is', $importline, $author );
                                        $a = $this->process_author( $author[1] 
);
                                        $this->authors[$a['author_login']] = $a;
                                        continue;
                                }
-                               if ( false !== strpos( $importline, '<item>' ) 
) {
-                                       $post = '';
-                                       $in_post = true;
-                                       continue;
-                               }
-                               if ( false !== strpos( $importline, '</item>' ) 
) {
-                                       $in_post = false;
-                                       $this->posts[] = $this->process_post( 
$post );
-                                       continue;
+
+                               foreach ( $multiline_tags as $tag => $handler ) 
{
+                                       // Handle multi-line tags on a singular 
line
+                                       if ( preg_match( '|<' . $tag . 
'>(.*?)</' . $tag . '>|is', $importline, $matches ) ) {
+                                               $this->{$handler[0]}[] = 
call_user_func( $handler[1], $matches[1] );
+
+                                       } elseif ( false !== ( $pos = strpos( 
$importline, "<$tag>" ) ) ) {
+                                               // Take note of any content 
after the opening tag
+                                               $multiline_content = trim( 
substr( $importline, $pos + strlen( $tag ) + 2 ) );
+
+                                               // We don't want to have this 
line added to `$is_multiline` below.
+                                               $importline        = '';
+                                               $in_multiline      = $tag;
+
+                                       } elseif ( false !== ( $pos = strpos( 
$importline, "</$tag>" ) ) ) {
+                                               $in_multiline          = false;
+                                               $multiline_content    .= trim( 
substr( $importline, 0, $pos ) );
+
+                                               $this->{$handler[0]}[] = 
call_user_func( $handler[1], $multiline_content );
+                                       }
                                }
-                               if ( $in_post ) {
-                                       $post .= $importline . "\n";
+
+                               if ( $in_multiline && $importline ) {
+                                       $multiline_content .= $importline . 
"\n";
                                }
                        }
 

diff --git a/plugins/wordpress-importer/readme.txt 
b/plugins/wordpress-importer/readme.txt
index 3ad9c75..68ea7f3 100644
--- a/plugins/wordpress-importer/readme.txt
+++ b/plugins/wordpress-importer/readme.txt
@@ -1,11 +1,12 @@
 === WordPress Importer ===
 Contributors: wordpressdotorg
+Donate link: https://wordpressfoundation.org/donate/
 Tags: importer, wordpress
-Requires at least: 3.0
-Tested up to: 4.6
-Stable tag: 0.6.3
+Requires at least: 3.6
+Tested up to: 4.9
+Stable tag: 0.6.4
 License: GPLv2 or later
-License URI: http://www.gnu.org/licenses/gpl-2.0.html
+License URI: https://www.gnu.org/licenses/gpl-2.0.html
 
 Import posts, pages, comments, custom fields, categories, tags and more from a 
WordPress export file.
 
@@ -19,7 +20,7 @@ The WordPress Importer will import the following content from 
a WordPress export
 * Categories, tags and terms from custom taxonomies
 * Authors
 
-For further information and instructions please see the [Codex page on 
Importing Content](http://codex.wordpress.org/Importing_Content#WordPress)
+For further information and instructions please see the [Codex page on 
Importing Content](https://codex.wordpress.org/Importing_Content#WordPress)
 
 == Installation ==
 
@@ -38,6 +39,12 @@ If you would prefer to do things manually then follow these 
instructions:
 
 == Changelog ==
 
+= 0.6.4 =
+* Improve PHP7 compatibility.
+* Fix bug that caused slashes to be stripped from imported comments.
+* Fix for various deprecation notices including `wp_get_http()` and 
`screen_icon()`.
+* Fix for importing export files with multiline term meta data.
+
 = 0.6.3 =
 * Add support for import term metadata.
 * Fix bug that caused slashes to be stripped from imported content.
@@ -45,7 +52,7 @@ If you would prefer to do things manually then follow these 
instructions:
 * Fix PHP notices.
 
 = 0.6.2 =
-* Add wp_import_existing_post filter. See: 
https://core.trac.wordpress.org/ticket/33721
+* Add `wp_import_existing_post` filter, see [Trac ticket 
#33721](https://core.trac.wordpress.org/ticket/33721).
 
 = 0.6 =
 * Support for WXR 1.2 and multiple CDATA sections
@@ -68,7 +75,7 @@ an export file is uploaded to a server with bad permissions 
and WordPress 3.3 or
 = 0.3 =
 * Use an XML Parser if possible
 * Proper import support for nav menus
-* ... and much more, see [Trac ticket 
#15197](http://core.trac.wordpress.org/ticket/15197)
+* ... and much more, see [Trac ticket 
#15197](https://core.trac.wordpress.org/ticket/15197)
 
 = 0.1 =
 * Initial release
@@ -99,7 +106,7 @@ A message like "Fatal error: Allowed memory size of 8388608 
bytes exhausted" ind
 
 For those with shared hosting, the best alternative may be to consult hosting 
support to determine the safest approach for running the import. A host may be 
willing to temporarily lift the memory limit and/or run the process directly 
from their end.
 
--- [WordPress Codex: Importing 
Content](http://codex.wordpress.org/Importing_Content#Before_Importing)
+-- [WordPress Codex: Importing 
Content](https://codex.wordpress.org/Importing_Content#Before_Importing)
 
 == Filters ==
 

diff --git a/plugins/wordpress-importer/wordpress-importer.php 
b/plugins/wordpress-importer/wordpress-importer.php
index 31b91b6..97376f0 100644
--- a/plugins/wordpress-importer/wordpress-importer.php
+++ b/plugins/wordpress-importer/wordpress-importer.php
@@ -1,11 +1,11 @@
 <?php
 /*
 Plugin Name: WordPress Importer
-Plugin URI: http://wordpress.org/extend/plugins/wordpress-importer/
+Plugin URI: https://wordpress.org/plugins/wordpress-importer/
 Description: Import posts, pages, comments, custom fields, categories, tags 
and more from a WordPress export file.
 Author: wordpressdotorg
-Author URI: http://wordpress.org/
-Version: 0.6.3
+Author URI: https://wordpress.org/
+Version: 0.6.4
 Text Domain: wordpress-importer
 License: GPL version 2 or later - 
http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 */
@@ -786,6 +786,7 @@ class WP_Import extends WP_Importer {
                                        if ( ! $post_exists || ! 
comment_exists( $comment['comment_author'], $comment['comment_date'] ) ) {
                                                if ( isset( 
$inserted_comments[$comment['comment_parent']] ) )
                                                        
$comment['comment_parent'] = $inserted_comments[$comment['comment_parent']];
+                                               $comment = wp_slash( $comment );
                                                $comment = wp_filter_comment( 
$comment );
                                                $inserted_comments[$key] = 
wp_insert_comment( $comment );
                                                do_action( 
'wp_import_insert_comment', $inserted_comments[$key], $comment, 
$comment_post_ID, $post );
@@ -881,7 +882,7 @@ class WP_Import extends WP_Importer {
                }
 
                foreach ( $item['postmeta'] as $meta )
-                       $$meta['key'] = $meta['value'];
+                       ${$meta['key']} = $meta['value'];
 
                if ( 'taxonomy' == $_menu_item_type && isset( 
$this->processed_terms[intval($_menu_item_object_id)] ) ) {
                        $_menu_item_object_id = 
$this->processed_terms[intval($_menu_item_object_id)];
@@ -988,7 +989,13 @@ class WP_Import extends WP_Importer {
                        return new WP_Error( 'upload_dir_error', 
$upload['error'] );
 
                // fetch the remote url and write it to the placeholder file
-               $headers = wp_get_http( $url, $upload['file'] );
+               $remote_response = wp_safe_remote_get( $url, array(
+                       'timeout' => 300,
+                       'stream' => true,
+                       'filename' => $upload['file'],
+               ) );
+
+               $headers = wp_remote_retrieve_headers( $remote_response );
 
                // request failed
                if ( ! $headers ) {
@@ -996,10 +1003,12 @@ class WP_Import extends WP_Importer {
                        return new WP_Error( 'import_file_error', __('Remote 
server did not respond', 'wordpress-importer') );
                }
 
+               $remote_response_code = wp_remote_retrieve_response_code( 
$remote_response );
+
                // make sure the fetch was successful
-               if ( $headers['response'] != '200' ) {
+               if ( $remote_response_code != '200' ) {
                        @unlink( $upload['file'] );
-                       return new WP_Error( 'import_file_error', sprintf( 
__('Remote server returned error response %1$d %2$s', 'wordpress-importer'), 
esc_html($headers['response']), get_status_header_desc($headers['response']) ) 
);
+                       return new WP_Error( 'import_file_error', sprintf( 
__('Remote server returned error response %1$d %2$s', 'wordpress-importer'), 
esc_html($remote_response_code), get_status_header_desc($remote_response_code) 
) );
                }
 
                $filesize = filesize( $upload['file'] );
@@ -1048,8 +1057,10 @@ class WP_Import extends WP_Importer {
                        if ( isset( $this->processed_posts[$parent_id] ) )
                                $local_parent_id = 
$this->processed_posts[$parent_id];
 
-                       if ( $local_child_id && $local_parent_id )
+                       if ( $local_child_id && $local_parent_id ) {
                                $wpdb->update( $wpdb->posts, array( 
'post_parent' => $local_parent_id ), array( 'ID' => $local_child_id ), '%d', 
'%d' );
+                               clean_post_cache( $local_child_id );
+                       }
                }
 
                // all other posts/terms are imported, retry menu items with 
missing associated object
@@ -1115,7 +1126,6 @@ class WP_Import extends WP_Importer {
        // Display import page title
        function header() {
                echo '<div class="wrap">';
-               screen_icon();
                echo '<h2>' . __( 'Import WordPress', 'wordpress-importer' ) . 
'</h2>';
 
                $updates = get_plugin_updates();
@@ -1206,7 +1216,7 @@ class WP_Import extends WP_Importer {
 } // class_exists( 'WP_Importer' )
 
 function wordpress_importer_init() {
-       load_plugin_textdomain( 'wordpress-importer', false, dirname( 
plugin_basename( __FILE__ ) ) . '/languages' );
+       load_plugin_textdomain( 'wordpress-importer' );
 
        /**
         * WordPress Importer object for registering the import callback

Reply via email to