<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[2175] 2013/frederickding/importer/trunk: General cleanup of inline documentation and whitespace; see #327, #331.</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://gsoc.trac.wordpress.org/changeset/2175">2175</a></dd>
<dt>Author</dt> <dd>frederick.ding</dd>
<dt>Date</dt> <dd>2013-07-29 19:29:18 +0000 (Mon, 29 Jul 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>General cleanup of inline documentation and whitespace; see <a href="http://gsoc.trac.wordpress.org/ticket/327">#327</a>, <a href="http://gsoc.trac.wordpress.org/ticket/331">#331</a>.

- Also fixed `process_attachment()` to use true `base_url` param and to check
  `is_allowed_attachment_fetch()`.
- Exposed `fetch_remote_file()` to public visibility.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#2013frederickdingimportertrunkclasswordpressimporterphp">2013/frederickding/importer/trunk/class-wordpress-importer.php</a></li>
<li><a href="#2013frederickdingimportertrunkclasswpimportercronphp">2013/frederickding/importer/trunk/class-wp-importer-cron.php</a></li>
<li><a href="#2013frederickdingimportertrunkteststestclasswordpressimporterphp">2013/frederickding/importer/trunk/tests/test-class-wordpress-importer.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="2013frederickdingimportertrunkclasswordpressimporterphp"></a>
<div class="modfile"><h4>Modified: 2013/frederickding/importer/trunk/class-wordpress-importer.php (2174 => 2175)</h4>
<pre class="diff"><span>
<span class="info">--- 2013/frederickding/importer/trunk/class-wordpress-importer.php   2013-07-29 18:37:33 UTC (rev 2174)
+++ 2013/frederickding/importer/trunk/class-wordpress-importer.php      2013-07-29 19:29:18 UTC (rev 2175)
</span><span class="lines">@@ -4,57 +4,60 @@
</span><span class="cx">  *
</span><span class="cx">  * Cron-based importer specifically for WordPress-generated WXR imports.
</span><span class="cx">  *
</span><del>- * Based on the WordPress Importer 
</del><ins>+ * Based on the WordPress Importer
</ins><span class="cx">  * (http://wordpress.org/extend/plugins/wordpress-importer/).
</span><span class="cx">  *
</span><span class="cx">  * @package WordPress
</span><span class="cx">  * @subpackage Importer
</span><span class="cx">  */
</span><del>-require_once 'class-wxr-parser.php';
-
</del><span class="cx"> class WordPress_Importer extends WP_Importer_Cron {
</span><span class="cx"> 
</span><span class="cx">  /**
</span><span class="cx">   * Highest supported WXR version.
</span><del>-        * 
</del><ins>+         *
</ins><span class="cx">    * @var float
</span><span class="cx">   */
</span><span class="cx">  const MAX_WXR_VERSION = 1.2;
</span><span class="cx"> 
</span><span class="cx">  /**
</span><span class="cx">   * Attachment ID of the WXR file.
</span><del>-        * 
</del><ins>+         *
</ins><span class="cx">    * @var int
</span><span class="cx">   */
</span><span class="cx">  protected $id;
</span><span class="cx"> 
</span><span class="cx">  /**
</span><span class="cx">   * WXR version of the file to be imported.
</span><del>-        * 
</del><ins>+         *
</ins><span class="cx">    * @var float
</span><span class="cx">   */
</span><span class="cx">  protected $version;
</span><span class="cx"> 
</span><span class="cx">  /**
</span><span class="cx">   * A single error object representing the fatal problem that halted things.
</span><del>-        * 
</del><ins>+         *
</ins><span class="cx">    * @var WP_Error
</span><span class="cx">   */
</span><span class="cx">  protected $error = null;
</span><del>-       
</del><ins>+
</ins><span class="cx">   /**
</span><del>-        * An array of objects representing non-fatal problems that occurred 
</del><ins>+         * An array of objects representing non-fatal problems that occurred
</ins><span class="cx">    * during import.
</span><del>-        * 
</del><ins>+         *
</ins><span class="cx">    * @var WP_Error[]
</span><span class="cx">   */
</span><span class="cx">  protected $warnings = array();
</span><span class="cx"> 
</span><ins>+       /**
+        * Tracks the stage of import.
+        *
+        * @var array
+        */
</ins><span class="cx">   protected $progress = array();
</span><span class="cx"> 
</span><span class="cx">  /**
</span><span class="cx">   * The name of the WXR file being processed by this instance of the importer.
</span><del>-        * 
</del><ins>+         *
</ins><span class="cx">    * @var string
</span><span class="cx">   */
</span><span class="cx">  protected $wxr_file;
</span><span class="lines">@@ -65,133 +68,138 @@
</span><span class="cx">   * @var array
</span><span class="cx">   */
</span><span class="cx">  protected $_wxr_data = array();
</span><del>-       
</del><ins>+
</ins><span class="cx">   /*
</span><span class="cx">   * SECTION: parsed data from import file
</span><span class="cx">   */
</span><del>-       
</del><ins>+
</ins><span class="cx">   /**
</span><del>-        * 
</del><ins>+         * Array of user information, including (optionally) names and emails.
+        *
</ins><span class="cx">    * @see process_authors()
</span><span class="cx">   * @var array
</span><span class="cx">   */
</span><span class="cx">  protected $authors = array();
</span><del>-       
</del><ins>+
</ins><span class="cx">   /**
</span><ins>+        * Categories to import.
</ins><span class="cx">    *
</span><span class="cx">   * @see process_categories()
</span><span class="cx">   * @var array
</span><span class="cx">   */
</span><span class="cx">  protected $categories = array();
</span><del>-       
</del><ins>+
</ins><span class="cx">   /**
</span><del>-        * 
</del><ins>+         * Tags to import.
+        *
</ins><span class="cx">    * @see process_tags()
</span><span class="cx">   * @var array
</span><span class="cx">   */
</span><span class="cx">  protected $tags = array();
</span><del>-       
</del><ins>+
</ins><span class="cx">   /**
</span><del>-        * 
</del><ins>+         * Other terms (including those of custom taxonomies) to import.
+        *
</ins><span class="cx">    * @see process_terms()
</span><span class="cx">   * @var array
</span><span class="cx">   */
</span><span class="cx">  protected $terms = array();
</span><del>-       
</del><ins>+
</ins><span class="cx">   /**
</span><ins>+        * Posts, attachments, menu items, and custom post type objects to import.
</ins><span class="cx">    *
</span><span class="cx">   * @see process_posts()
</span><span class="cx">   * @var array
</span><span class="cx">   */
</span><span class="cx">  protected $posts = array();
</span><del>-       
</del><ins>+
</ins><span class="cx">   /*
</span><span class="cx">   * SECTION: mappings from old information to new
</span><span class="cx">   */
</span><del>-       
</del><ins>+
</ins><span class="cx">   /**
</span><del>-        * 
</del><ins>+         *
</ins><span class="cx">    * @see process_author_mappings()
</span><span class="cx">   * @var array
</span><span class="cx">   */
</span><span class="cx">  protected $processed_authors = array();
</span><del>-       
</del><ins>+
</ins><span class="cx">   /**
</span><span class="cx">   *
</span><span class="cx">   * @see process_author_mappings()
</span><span class="cx">   * @var array
</span><span class="cx">   */
</span><span class="cx">  protected $processed_author_mappings = array();
</span><del>-       
</del><ins>+
</ins><span class="cx">   /**
</span><del>-        * 
</del><ins>+         *
</ins><span class="cx">    * @var array
</span><span class="cx">   */
</span><span class="cx">  protected $processed_terms = array();
</span><del>-       
</del><ins>+
</ins><span class="cx">   /**
</span><span class="cx">   *
</span><span class="cx">   * @var array
</span><span class="cx">   */
</span><span class="cx">  protected $processed_posts = array();
</span><del>-       
</del><ins>+
</ins><span class="cx">   /**
</span><span class="cx">   *
</span><span class="cx">   * @see process_posts()
</span><span class="cx">   * @var array
</span><span class="cx">   */
</span><span class="cx">  protected $processed_post_orphans = array();
</span><del>-       
</del><ins>+
</ins><span class="cx">   /**
</span><span class="cx">   *
</span><span class="cx">   * @see process_posts()
</span><span class="cx">   * @var array
</span><span class="cx">   */
</span><span class="cx">  protected $processed_featured_images = array();
</span><del>-       
</del><ins>+
</ins><span class="cx">   /**
</span><span class="cx">   *
</span><span class="cx">   * @see process_menu_item()
</span><span class="cx">   * @var array
</span><span class="cx">   */
</span><span class="cx">  protected $processed_menu_items = array();
</span><del>-       
</del><ins>+
</ins><span class="cx">   /**
</span><span class="cx">   *
</span><span class="cx">   * @see process_menu_item()
</span><span class="cx">   * @var array
</span><span class="cx">   */
</span><span class="cx">  protected $processed_menu_missing_items = array();
</span><del>-       
</del><ins>+
</ins><span class="cx">   /**
</span><span class="cx">   *
</span><span class="cx">   * @see process_parents()
</span><span class="cx">   * @var array
</span><span class="cx">   */
</span><span class="cx">  protected $processed_menu_orphan_items = array();
</span><del>-       
</del><ins>+
</ins><span class="cx">   /**
</span><span class="cx">   *
</span><span class="cx">   * @see fetch_remote_file()
</span><span class="cx">   * @var array
</span><span class="cx">   */
</span><span class="cx">  protected $processed_url_remap = array();
</span><del>-       
</del><ins>+
</ins><span class="cx">   /**
</span><span class="cx">   * Stores user-submitted choices on how to proceed with the process.
</span><del>-        * 
-        * The first dimension of this array is 
-        * 
</del><ins>+         *
+        * The first dimension of this array is
+        *
</ins><span class="cx">    * @var array
</span><span class="cx">   */
</span><span class="cx">  protected $params = array();
</span><span class="cx"> 
</span><span class="cx">  /**
</span><span class="cx">   * Parses the WXR file and prepares us to process parsed data.
</span><del>-        * 
</del><ins>+         *
</ins><span class="cx">    * This method is synchronous and is NOT for use in a cron-scheduled job; it
</span><span class="cx">   * should be invoked by a controller UI before do_import() is scheduled.
</span><del>-        * 
</del><ins>+         *
</ins><span class="cx">    * @param string $file
</span><span class="cx">   *              Path to the WXR file for parsing
</span><span class="cx">   * @return array WP_Error data if successful, or an instance of WP_Error if
</span><span class="lines">@@ -199,39 +207,41 @@
</span><span class="cx">   */
</span><span class="cx">  public function do_parse( $file ) {
</span><span class="cx">          if ( ! is_file( $file ) ) {
</span><del>-                       return new WP_Error( 'import_wxr_error', 
-                                       __( 'The file does not exist, please try again.', 
</del><ins>+                        return new WP_Error( 'import_wxr_error',
+                                       __( 'The file does not exist, please try again.',
</ins><span class="cx">                                                   'wordpress-importer' ), $file );
</span><span class="cx">          }
</span><del>-               
</del><ins>+
</ins><span class="cx">           $parser = new WXR_Parser();
</span><del>-               
</del><ins>+
</ins><span class="cx">           $data = $parser->parse( $file );
</span><del>-               
</del><ins>+
</ins><span class="cx">           // pass through errors
</span><span class="cx">          if ( is_wp_error( $data ) )
</span><span class="cx">                  return $data;
</span><del>-                       
</del><ins>+
</ins><span class="cx">                   // check for acceptable version
</span><span class="cx">          $version = floatval( $data['version'] );
</span><span class="cx">          if ( $version > self::MAX_WXR_VERSION ) {
</span><del>-                       return new WP_Error( 'import_wxr_error', 
-                                       __( 'WXR version newer than importer', 
</del><ins>+                        return new WP_Error( 'import_wxr_error',
+                                       __( 'WXR version newer than importer',
</ins><span class="cx">                                                   'wordpress-importer' ), $version );
</span><span class="cx">          }
</span><del>-               
</del><ins>+
</ins><span class="cx">           $this->version = $version;
</span><span class="cx">          $this->wxr_file = $file;
</span><span class="cx">          $this->categories = $data['categories'];
</span><span class="cx">          $this->tags = $data['tags'];
</span><span class="cx">          $this->terms = $data['terms'];
</span><span class="cx">          $this->posts = $data['posts'];
</span><del>-               
</del><ins>+
+               $this->set_param('base_url', esc_url( $data['base_url'] ));
+
</ins><span class="cx">           $this->_wxr_data = $data;
</span><span class="cx">          if ( $user = get_current_user_id() > 0 ) {
</span><span class="cx">                  $this->set_param( 'admin_user_id', $user );
</span><span class="cx">          }
</span><del>-               
</del><ins>+
</ins><span class="cx">           /**
</span><span class="cx">           *
</span><span class="cx">           * @todo persistent storage without taking up too much space, or more
</span><span class="lines">@@ -243,7 +253,7 @@
</span><span class="cx">  /**
</span><span class="cx">   * The main controller for the actual import stage. Modelled on
</span><span class="cx">   * Tumblr_Import::do_blog_import().
</span><del>-        * 
</del><ins>+         *
</ins><span class="cx">    * @param string $file
</span><span class="cx">   *              Path to the WXR file for importing
</span><span class="cx">   * @return boolean Whether the import process is complete
</span><span class="lines">@@ -252,17 +262,17 @@
</span><span class="cx">          // defaults to being done
</span><span class="cx">          $done = true;
</span><span class="cx">          $this->error = null;
</span><del>-               
</del><ins>+
</ins><span class="cx">           if ( empty( $file ) )
</span><span class="cx">                  $file = $this->wxr_file;
</span><del>-               
</del><ins>+
</ins><span class="cx">           if ( ! empty( $this->progress[$file] ) ) {
</span><span class="cx">                  $done = false;
</span><del>-                       
</del><ins>+
</ins><span class="cx">                   do {
</span><del>-                               // we could probably be doing call_user_func() or using some 
-                               // Reflection, but this makes more sense for readability and 
-                               // process-specific modifications 
</del><ins>+                                // we could probably be doing call_user_func() or using some
+                               // Reflection, but this makes more sense for readability and
+                               // process-specific modifications
</ins><span class="cx">                           switch ( $this->progress[$file] ) {
</span><span class="cx">                                  case 'start':
</span><span class="cx">                                  case 'authors':
</span><span class="lines">@@ -283,10 +293,10 @@
</span><span class="cx">                                  case 'posts':
</span><span class="cx">                                          $this->process_posts();
</span><span class="cx">                                          break;
</span><del>-                                       case 'backfill_parents':
</del><ins>+                                        case 'parents':
</ins><span class="cx">                                           $this->process_parents();
</span><span class="cx">                                          break;
</span><del>-                                       case 'backfill_urls':
</del><ins>+                                        case 'urls':
</ins><span class="cx">                                           $this->process_urls();
</span><span class="cx">                                          break;
</span><span class="cx">                                  case 'finish':
</span><span class="lines">@@ -300,40 +310,48 @@
</span><span class="cx">  }
</span><span class="cx"> 
</span><span class="cx">  /**
</span><del>-        * Performs post-import cleanup of files and the cache
</del><ins>+         * Performs post-import cleanup of files and the cache.
+        *
+        * Must be called to reenable the cache and remove extraneous options.
+        *
+        * If the IMPORT_DEBUG constant is defined and true, the option in the
+        * database will be retained so that the internal data from this class can
+        * be debugged.
</ins><span class="cx">    */
</span><span class="cx">  public function do_cleanup() {
</span><span class="cx">          /*
</span><del>-                * @todo remove this, which has to do with attachments and UI rather 
</del><ins>+                 * @todo remove this, which has to do with attachments and UI rather
</ins><span class="cx">            *       than actual importer logic
</span><span class="cx">           */
</span><span class="cx">          wp_import_cleanup( $this->id );
</span><del>-               
</del><ins>+
</ins><span class="cx">           wp_cache_flush();
</span><span class="cx">          foreach ( get_taxonomies() as $tax ) {
</span><span class="cx">                  delete_option( "{$tax}_children" );
</span><span class="cx">                  _get_term_hierarchy( $tax );
</span><span class="cx">          }
</span><del>-               
</del><ins>+
</ins><span class="cx">           wp_defer_term_counting( false );
</span><span class="cx">          wp_defer_comment_counting( false );
</span><del>-               
</del><ins>+
</ins><span class="cx">           // un-suspend cache
</span><span class="cx">          wp_suspend_cache_invalidation( false );
</span><span class="cx">          wp_suspend_cache_addition( false );
</span><del>-               
</del><ins>+
+               if ( ! IMPORT_DEBUG )
+                       delete_option( get_class( $this ) );
</ins><span class="cx">           // do_action('import_end') omitted because that action seems to be
</span><span class="cx">          // designed for callbacks that could sent output
</span><span class="cx">  }
</span><span class="cx"> 
</span><span class="cx">  /**
</span><span class="cx">   * Advances the progress state to the specified state.
</span><del>-        * 
-        * @param string $step          
</del><ins>+         *
+        * @param string $step
</ins><span class="cx">    * @return boolean|WP_Error
</span><span class="cx">   */
</span><span class="cx">  public function advance( $step = '' ) {
</span><del>-               $steps = array( 
</del><ins>+                $steps = array(
</ins><span class="cx">                           'start',
</span><span class="cx">                          'authors',
</span><span class="cx">                          'author_mappings',
</span><span class="lines">@@ -341,11 +359,11 @@
</span><span class="cx">                          'tags',
</span><span class="cx">                          'terms',
</span><span class="cx">                          'posts',
</span><del>-                               'backfill_parents',
-                               'backfill_urls',
-                               'finish' 
</del><ins>+                                'parents',
+                               'urls',
+                               'finish'
</ins><span class="cx">           );
</span><del>-                               
</del><ins>+
</ins><span class="cx">           // if no step provided, advance to the next step
</span><span class="cx">          if ( empty( $step ) && ! empty( $this->wxr_file ) ) {
</span><span class="cx">                  if ( empty( $this->progress[$this->wxr_file] ) ) {
</span><span class="lines">@@ -353,7 +371,7 @@
</span><span class="cx">                          $step = $steps[0];
</span><span class="cx">                  } else {
</span><span class="cx">                          $step_index = array_search( $this->progress[$this->wxr_file], $steps );
</span><del>-                               
</del><ins>+
</ins><span class="cx">                           // if currently on start step, fast forward 2 steps in total
</span><span class="cx">                          if ( $step_index === 0 ) {
</span><span class="cx">                                  $step_index ++;
</span><span class="lines">@@ -364,31 +382,33 @@
</span><span class="cx">                  }
</span><span class="cx">          }
</span><span class="cx">          if ( ! in_array( $step, $steps ) ) {
</span><del>-                       return new WP_Error( 'import_cron_step_error', 
</del><ins>+                        return new WP_Error( 'import_cron_step_error',
</ins><span class="cx">                                   __( 'Invalid step', 'wordpress-importer' ) );
</span><span class="cx">          }
</span><span class="cx">          $this->progress[$this->wxr_file] = $step;
</span><del>-               
</del><ins>+
</ins><span class="cx">           return $step;
</span><span class="cx">  }
</span><span class="cx"> 
</span><span class="cx">  /**
</span><ins>+        * Copies authors data from the WXR parsed data.
+        *
</ins><span class="cx">    * do_parse() must first be called successfully before this can be used.
</span><del>-        * 
-        * Like all process_* methods, this will return true when its step has 
</del><ins>+         *
+        * Like all process_* methods, this will return true when its step has
</ins><span class="cx">    * completed.
</span><del>-        * 
</del><ins>+         *
</ins><span class="cx">    * @return boolean True upon completion, false otherwise, if an error has occurred
</span><span class="cx">   */
</span><span class="cx">  protected function process_authors() {
</span><span class="cx">          // check for availability of data
</span><span class="cx">          if ( empty( $this->wxr_file ) || empty( $this->_wxr_data ) ) {
</span><del>-                       $this->error = new WP_Error( 'import_process_wxr_error', 
-                                       __( 'No parsed data available for processing', 
</del><ins>+                        $this->error = new WP_Error( 'import_process_wxr_error',
+                                       __( 'No parsed data available for processing',
</ins><span class="cx">                                                   'wordpress-importer' ) );
</span><span class="cx">                  return false;
</span><span class="cx">          }
</span><del>-               
</del><ins>+
</ins><span class="cx">           if ( ! empty( $this->_wxr_data['authors'] ) ) {
</span><span class="cx">                  $this->authors = $this->_wxr_data['authors'];
</span><span class="cx">          } else {
</span><span class="lines">@@ -396,24 +416,24 @@
</span><span class="cx">                  foreach ( $this->_['posts'] as $post ) {
</span><span class="cx">                          $login = sanitize_user( $post['post_author'], true );
</span><span class="cx">                          if ( empty( $login ) ) {
</span><del>-                                       $this->warnings[] = new WP_Error( 
-                                                       'import_process_authors_warning', 
-                                                       sprintf( 
-                                                                       __( 
-                                                                                       'Failed to import author %s. Their posts will be attributed to the current user.', 
-                                                                                       'wordpress-importer' ), 
</del><ins>+                                        $this->warnings[] = new WP_Error(
+                                                       'import_process_authors_warning',
+                                                       sprintf(
+                                                                       __(
+                                                                                       'Failed to import author %s. Their posts will be attributed to the current user.',
+                                                                                       'wordpress-importer' ),
</ins><span class="cx">                                                                   esc_html( $post['post_author'] ) ) );
</span><span class="cx">                                  continue;
</span><span class="cx">                          }
</span><del>-                               
</del><ins>+
</ins><span class="cx">                           if ( ! isset( $this->authors[$login] ) )
</span><del>-                                       $this->authors[$login] = array( 
</del><ins>+                                        $this->authors[$login] = array(
</ins><span class="cx">                                                   'author_login' => $login,
</span><del>-                                                       'author_display_name' => $post['post_author'] 
</del><ins>+                                                        'author_display_name' => $post['post_author']
</ins><span class="cx">                                   );
</span><span class="cx">                  }
</span><span class="cx">          }
</span><del>-               
</del><ins>+
</ins><span class="cx">           // done without fatal errors, so we'll advance step
</span><span class="cx">          $this->advance();
</span><span class="cx">          return true;
</span><span class="lines">@@ -427,29 +447,29 @@
</span><span class="cx">   */
</span><span class="cx">  protected function process_author_mappings () {
</span><span class="cx">          $create_users = $this->is_allowed_user_creation();
</span><del>-               
</del><ins>+
</ins><span class="cx">           // adapted from WP_Import; however, we don't have the luxury of
</span><span class="cx">          // directly accessing $_POST, so we rely instead on DB-stored params
</span><span class="cx">          $imported_authors = $this->get_param( 'imported_authors', array() );
</span><del>-               
</del><ins>+
</ins><span class="cx">           if ( is_wp_error( $imported_authors ) ) {
</span><span class="cx">                  $this->error = $imported_authors;
</span><span class="cx">                  return false;
</span><span class="cx">          }
</span><del>-               
</del><ins>+
</ins><span class="cx">           foreach ( (array) $imported_authors as $i => $old_login ) {
</span><span class="cx">                  // Multisite adds strtolower to sanitize_user. Need to sanitize here
</span><span class="cx">                  // to stop breakage in process_posts.
</span><span class="cx">                  $sanitized_old_login = sanitize_user( $old_login, true );
</span><del>-                       
</del><ins>+
</ins><span class="cx">                   /*
</span><span class="cx">                   * $this->authors should have already been set by process_authors(),
</span><span class="cx">                   * although author_id will be missing if author information was
</span><span class="cx">                   * pulled out of post meta
</span><span class="cx">                   */
</span><del>-                       $old_id = isset( $this->authors[$old_login]['author_id'] ) ? intval( 
</del><ins>+                        $old_id = isset( $this->authors[$old_login]['author_id'] ) ? intval(
</ins><span class="cx">                                   $this->authors[$old_login]['author_id'] ) : false;
</span><del>-                       
</del><ins>+
</ins><span class="cx">                   $user_map = $this->get_param( 'user_map', array() );
</span><span class="cx">                  if ( ! empty( $user_map[$i] ) ) {
</span><span class="cx">                          // the mapping old->new was defined from the form
</span><span class="lines">@@ -463,23 +483,23 @@
</span><span class="cx">                          // make a user for an unmapped author only if allowed
</span><span class="cx">                          $user_new = $this->get_param( 'user_new', array() );
</span><span class="cx">                          if ( ! empty( $user_new[$i] ) ) {
</span><del>-                                       $user_id = wp_create_user( $user_new[$i], 
</del><ins>+                                        $user_id = wp_create_user( $user_new[$i],
</ins><span class="cx">                                                   wp_generate_password() );
</span><span class="cx">                          } elseif ( $this->version != '1.0' ) {
</span><span class="cx">                                  $user_data = array(
</span><span class="cx">                                                  'user_login' => $old_login,
</span><span class="cx">                                                  'user_pass' => wp_generate_password(),
</span><del>-                                                       'user_email' => isset( 
</del><ins>+                                                        'user_email' => isset(
</ins><span class="cx">                                                                   $this->authors[$old_login]['author_email'] ) ? $this->authors[$old_login]['author_email'] : '',
</span><span class="cx">                                                  'display_name' => $this->authors[$old_login]['author_display_name'],
</span><del>-                                                       'first_name' => isset( 
</del><ins>+                                                        'first_name' => isset(
</ins><span class="cx">                                                                   $this->authors[$old_login]['author_first_name'] ) ? $this->authors[$old_login]['author_first_name'] : '',
</span><del>-                                                       'last_name' => isset( 
</del><ins>+                                                        'last_name' => isset(
</ins><span class="cx">                                                                   $this->authors[$old_login]['author_last_name'] ) ? $this->authors[$old_login]['author_last_name'] : ''
</span><span class="cx">                                  );
</span><span class="cx">                                  $user_id = wp_insert_user( $user_data );
</span><span class="cx">                          }
</span><del>-                               
</del><ins>+
</ins><span class="cx">                           if ( ! is_wp_error( $user_id ) ) {
</span><span class="cx">                                  // successful user creation; add to mappings
</span><span class="cx">                                  if ( $old_id )
</span><span class="lines">@@ -488,23 +508,23 @@
</span><span class="cx">                          } else {
</span><span class="cx">                                          // set a warning in the importer class, and include the
</span><span class="cx">                                          // WP_Error object emitted by wp_insert_user() as data.
</span><del>-                                       $this->warnings[] = new WP_Error( 
-                                                       'import_process_author_mappings_warning', 
-                                                       sprintf( 
-                                                                       __( 
-                                                                                       'Failed to create new user for %s. Their posts will be attributed to the current user.', 
-                                                                                       'wordpress-importer' ), 
-                                                                       esc_html( 
-                                                                                       $this->authors[$old_login]['author_display_name'] ) ), 
</del><ins>+                                        $this->warnings[] = new WP_Error(
+                                                       'import_process_author_mappings_warning',
+                                                       sprintf(
+                                                                       __(
+                                                                                       'Failed to create new user for %s. Their posts will be attributed to the current user.',
+                                                                                       'wordpress-importer' ),
+                                                                       esc_html(
+                                                                                       $this->authors[$old_login]['author_display_name'] ) ),
</ins><span class="cx">                                                   $user_id );
</span><del>-                                       // really wish WP_Error were like an exception and that we 
</del><ins>+                                        // really wish WP_Error were like an exception and that we
</ins><span class="cx">                                   // could use try...catch...finally.
</span><span class="cx">                          }
</span><span class="cx">                  }
</span><del>-                               
</del><ins>+
</ins><span class="cx">                   /*
</span><span class="cx">                   * Failsafe: if the user_id was invalid, default to the current user.
</span><del>-                        * 
</del><ins>+                         *
</ins><span class="cx">                    * Cron note: can't use logged in user; instead default to the user
</span><span class="cx">                   * ID stored in params, which should be the admin user who triggered
</span><span class="cx">                   * the import. It is possible to override this from an external
</span><span class="lines">@@ -513,45 +533,45 @@
</span><span class="cx">                   */
</span><span class="cx">                  if ( ! isset( $this->processed_author_mappings[$sanitized_old_login] ) ) {
</span><span class="cx">                          if ( $old_id )
</span><del>-                                       $this->processed_authors[$old_id] = (int) $this->get_param( 
</del><ins>+                                        $this->processed_authors[$old_id] = (int) $this->get_param(
</ins><span class="cx">                                                   'admin_user_id', 0 );
</span><del>-                               $this->processed_author_mappings[$sanitized_old_login] = (int) $this->get_param( 
</del><ins>+                                $this->processed_author_mappings[$sanitized_old_login] = (int) $this->get_param(
</ins><span class="cx">                                           'admin_user_id', 0 );
</span><span class="cx">                  }
</span><span class="cx">          }
</span><del>-                       
</del><ins>+
</ins><span class="cx">           /*
</span><del>-                * At this point, theoretically all authors should be mapped. However, 
-                * emit a warning if the number of mapped authors is fewer than the 
</del><ins>+                 * At this point, theoretically all authors should be mapped. However,
+                * emit a warning if the number of mapped authors is fewer than the
</ins><span class="cx">            * number of authors identified from the import data.
</span><span class="cx">           */
</span><span class="cx">          if ( count( $this->processed_author_mappings ) < count( $this->authors ) ) {
</span><del>-                       $this->warnings[] = new WP_Error( 
-                                       'import_process_author_mappings_warning', 
-                                       __( 
-                                                       'Some authors may not have been attributed correctly.', 
</del><ins>+                        $this->warnings[] = new WP_Error(
+                                       'import_process_author_mappings_warning',
+                                       __(
+                                                       'Some authors may not have been attributed correctly.',
</ins><span class="cx">                                                   'wordpress-importer' ) );
</span><span class="cx">          }
</span><del>-               
</del><ins>+
</ins><span class="cx">           $this->advance();
</span><span class="cx">          return true;
</span><span class="cx">  }
</span><span class="cx"> 
</span><span class="cx">  /**
</span><span class="cx">   * Creates new categories based on those used in the import data.
</span><del>-        * 
</del><ins>+         *
</ins><span class="cx">    * Depends on do_parse(), which sets $this->categories.
</span><span class="cx">   */
</span><span class="cx">  protected function process_categories() {
</span><span class="cx">          // allow some categories to be filtered out from import
</span><del>-               $this->categories = apply_filters( 'wp_import_categories', 
</del><ins>+                $this->categories = apply_filters( 'wp_import_categories',
</ins><span class="cx">                           $this->categories );
</span><del>-               
</del><ins>+
</ins><span class="cx">           if ( empty( $this->categories ) ) {
</span><span class="cx">                  $this->advance();
</span><span class="cx">                  return true;
</span><span class="cx">          }
</span><del>-               
</del><ins>+
</ins><span class="cx">           foreach ( $this->categories as $cat ) {
</span><span class="cx">                  // if the category already exists leave it alone
</span><span class="cx">                  $term_id = term_exists( $cat['category_nicename'], 'category' );
</span><span class="lines">@@ -562,8 +582,8 @@
</span><span class="cx">                                  $this->processed_terms[intval( $cat['term_id'] )] = (int) $term_id;
</span><span class="cx">                          continue;
</span><span class="cx">                  }
</span><del>-                       
-                       $category_parent = empty( $cat['category_parent'] ) ? 0 : category_exists( 
</del><ins>+
+                       $category_parent = empty( $cat['category_parent'] ) ? 0 : category_exists(
</ins><span class="cx">                                   $cat['category_parent'] );
</span><span class="cx">                  $category_description = isset( $cat['category_description'] ) ? $cat['category_description'] : '';
</span><span class="cx">                  $catarr = array(
</span><span class="lines">@@ -572,7 +592,7 @@
</span><span class="cx">                                  'cat_name' => $cat['cat_name'],
</span><span class="cx">                                  'category_description' => $category_description
</span><span class="cx">                  );
</span><del>-                       
</del><ins>+
</ins><span class="cx">                   $id = wp_insert_category( $catarr );
</span><span class="cx">                  if ( ! is_wp_error( $id ) ) {
</span><span class="cx">                          if ( isset( $cat['term_id'] ) )
</span><span class="lines">@@ -580,37 +600,37 @@
</span><span class="cx">                  } else {
</span><span class="cx">                                  // set a warning in the importer class, and include the
</span><span class="cx">                                  // WP_Error object emitted by wp_insert_category() as data.
</span><del>-                               $this->warnings[] = new WP_Error( 
-                                               'import_process_categories_warning', 
-                                               sprintf( 
-                                                               __( 'Failed to import category %s', 
-                                                                               'wordpress-importer' ), 
</del><ins>+                                $this->warnings[] = new WP_Error(
+                                               'import_process_categories_warning',
+                                               sprintf(
+                                                               __( 'Failed to import category %s',
+                                                                               'wordpress-importer' ),
</ins><span class="cx">                                                           esc_html( $cat['category_nicename'] ) ), $id );
</span><span class="cx">                          continue;
</span><span class="cx">                  }
</span><span class="cx">          }
</span><del>-               
</del><ins>+
</ins><span class="cx">           // saves us some memory
</span><span class="cx">          unset( $this->categories );
</span><del>-               
</del><ins>+
</ins><span class="cx">           $this->advance();
</span><span class="cx">          return true;
</span><span class="cx">  }
</span><span class="cx"> 
</span><span class="cx">  /**
</span><span class="cx">   * Creates new tags based on those used in the import data.
</span><del>-        * 
-        * Depends on do_parse(), which sets $this->tags. Very similar in structure 
</del><ins>+         *
+        * Depends on do_parse(), which sets $this->tags. Very similar in structure
</ins><span class="cx">    * and function to process_categories().
</span><span class="cx">   */
</span><span class="cx">  protected function process_tags() {
</span><span class="cx">          $this->tags = apply_filters( 'wp_import_tags', $this->tags );
</span><del>-               
</del><ins>+
</ins><span class="cx">           if ( empty( $this->tags ) ) {
</span><span class="cx">                  $this->advance();
</span><span class="cx">                  return true;
</span><span class="cx">          }
</span><del>-               
</del><ins>+
</ins><span class="cx">           foreach ( $this->tags as $tag ) {
</span><span class="cx">                  // if the tag already exists leave it alone
</span><span class="cx">                  $term_id = term_exists( $tag['tag_slug'], 'post_tag' );
</span><span class="lines">@@ -621,13 +641,13 @@
</span><span class="cx">                                  $this->processed_terms[intval( $tag['term_id'] )] = (int) $term_id;
</span><span class="cx">                          continue;
</span><span class="cx">                  }
</span><del>-                       
</del><ins>+
</ins><span class="cx">                   $tag_desc = isset( $tag['tag_description'] ) ? $tag['tag_description'] : '';
</span><span class="cx">                  $tagarr = array(
</span><span class="cx">                                  'slug' => $tag['tag_slug'],
</span><span class="cx">                                  'description' => $tag_desc
</span><span class="cx">                  );
</span><del>-                       
</del><ins>+
</ins><span class="cx">                   $id = wp_insert_term( $tag['tag_name'], 'post_tag', $tagarr );
</span><span class="cx">                  if ( ! is_wp_error( $id ) ) {
</span><span class="cx">                          if ( isset( $tag['term_id'] ) )
</span><span class="lines">@@ -635,36 +655,36 @@
</span><span class="cx">                  } else {
</span><span class="cx">                                  // set a warning in the importer class, and include the
</span><span class="cx">                                  // WP_Error object emitted by wp_insert_category() as data.
</span><del>-                               $this->warnings[] = new WP_Error( 
-                                               'import_process_tags_warning', 
-                                               sprintf( 
-                                                               __( 'Failed to import post tag %s', 
-                                                                               'wordpress-importer' ), 
</del><ins>+                                $this->warnings[] = new WP_Error(
+                                               'import_process_tags_warning',
+                                               sprintf(
+                                                               __( 'Failed to import post tag %s',
+                                                                               'wordpress-importer' ),
</ins><span class="cx">                                                           esc_html( $tag['tag_name'] ) ), $id );
</span><span class="cx">                          continue;
</span><span class="cx">                  }
</span><span class="cx">          }
</span><del>-               
</del><ins>+
</ins><span class="cx">           unset( $this->tags );
</span><del>-               
</del><ins>+
</ins><span class="cx">           $this->advance();
</span><span class="cx">          return true;
</span><span class="cx">  }
</span><span class="cx"> 
</span><span class="cx">  /**
</span><span class="cx">   * Creates new terms based on those used in the import data.
</span><del>-        * 
-        * Depends on do_parse(), which sets $this->terms. Very similar in structure 
</del><ins>+         *
+        * Depends on do_parse(), which sets $this->terms. Very similar in structure
</ins><span class="cx">    * and function to process_categories() and process_tags().
</span><span class="cx">   */
</span><span class="cx">  protected function process_terms() {
</span><span class="cx">          $this->terms = apply_filters( 'wp_import_terms', $this->terms );
</span><del>-               
</del><ins>+
</ins><span class="cx">           if ( empty( $this->terms ) ) {
</span><span class="cx">                  $this->advance();
</span><span class="cx">                  return true;
</span><span class="cx">          }
</span><del>-               
</del><ins>+
</ins><span class="cx">           foreach ( $this->terms as $term ) {
</span><span class="cx">                  // if the term already exists in the correct taxonomy leave it alone
</span><span class="cx">                  $term_id = term_exists( $term['slug'], $term['term_taxonomy'] );
</span><span class="lines">@@ -675,11 +695,11 @@
</span><span class="cx">                                  $this->processed_terms[intval( $term['term_id'] )] = (int) $term_id;
</span><span class="cx">                          continue;
</span><span class="cx">                  }
</span><del>-                       
</del><ins>+
</ins><span class="cx">                   if ( empty( $term['term_parent'] ) ) {
</span><span class="cx">                          $parent = 0;
</span><span class="cx">                  } else {
</span><del>-                               $parent = term_exists( $term['term_parent'], 
</del><ins>+                                $parent = term_exists( $term['term_parent'],
</ins><span class="cx">                                           $term['term_taxonomy'] );
</span><span class="cx">                          if ( is_array( $parent ) )
</span><span class="cx">                                  $parent = $parent['term_id'];
</span><span class="lines">@@ -690,8 +710,8 @@
</span><span class="cx">                                  'description' => $description,
</span><span class="cx">                                  'parent' => intval( $parent )
</span><span class="cx">                  );
</span><del>-                       
-                       $id = wp_insert_term( $term['term_name'], $term['term_taxonomy'], 
</del><ins>+
+                       $id = wp_insert_term( $term['term_name'], $term['term_taxonomy'],
</ins><span class="cx">                                   $termarr );
</span><span class="cx">                  if ( ! is_wp_error( $id ) ) {
</span><span class="cx">                          if ( isset( $term['term_id'] ) )
</span><span class="lines">@@ -699,71 +719,75 @@
</span><span class="cx">                  } else {
</span><span class="cx">                          // set a warning in the importer class, and include the
</span><span class="cx">                          // WP_Error object emitted by wp_insert_term() as data.
</span><del>-                               $this->warnings[] = new WP_Error( 
-                                               'import_process_term_warning', 
-                                               sprintf( 
-                                                               __( 'Failed to import %s %s', 
-                                                                               'wordpress-importer' ), 
-                                                               esc_html( $term['term_taxonomy'] ), 
</del><ins>+                                $this->warnings[] = new WP_Error(
+                                               'import_process_term_warning',
+                                               sprintf(
+                                                               __( 'Failed to import %s %s',
+                                                                               'wordpress-importer' ),
+                                                               esc_html( $term['term_taxonomy'] ),
</ins><span class="cx">                                                           esc_html( $term['term_name'] ) ), $id );
</span><span class="cx">                          continue;
</span><span class="cx">                  }
</span><span class="cx">          } // foreach
</span><del>-               
</del><ins>+
</ins><span class="cx">           unset( $this->terms );
</span><span class="cx">          $this->advance();
</span><span class="cx">          return true;
</span><span class="cx">  }
</span><del>-       
</del><ins>+
</ins><span class="cx">   /**
</span><ins>+        * Fetches attachments if permitted and inserts them with metadata.
</ins><span class="cx">    *
</span><del>-        * @todo
</del><ins>+         * @param array $post
+        * @param string $url
+        * @return int|WP_Error
</ins><span class="cx">    */
</span><span class="cx">  protected function process_attachment( $post, $url ) {
</span><del>-               if ( ! $this->fetch_attachments )
</del><ins>+                if ( ! $this->is_allowed_attachment_fetch() )
</ins><span class="cx">               return new WP_Error( 'attachment_processing_error',
</span><span class="cx">                  __( 'Fetching attachments is not enabled', 'wordpress-importer' ) );
</span><del>-               
</del><ins>+
</ins><span class="cx">           // if the URL is absolute, but does not contain address, then upload it assuming base_site_url
</span><span class="cx">          if ( preg_match( '|^/[\w\W]+$|', $url ) )
</span><del>-                   $url = rtrim( $this->base_url, '/' ) . $url;
-               
</del><ins>+                        $url = rtrim( $this->get_param( 'base_url', '' ), '/' ) . $url;
+
</ins><span class="cx">           $upload = $this->fetch_remote_file( $url, $post );
</span><span class="cx">          if ( is_wp_error( $upload ) )
</span><span class="cx">              return $upload;
</span><del>-               
</del><ins>+
</ins><span class="cx">           if ( $info = wp_check_filetype( $upload['file'] ) )
</span><span class="cx">              $post['post_mime_type'] = $info['type'];
</span><span class="cx">          else
</span><span class="cx">              return new WP_Error( 'attachment_processing_error', __('Invalid file type', 'wordpress-importer') );
</span><del>-               
</del><ins>+
</ins><span class="cx">           $post['guid'] = $upload['url'];
</span><del>-               
</del><ins>+
</ins><span class="cx">           // as per wp-admin/includes/upload.php
</span><span class="cx">          $post_id = wp_insert_attachment( $post, $upload['file'] );
</span><span class="cx">          wp_update_attachment_metadata( $post_id, wp_generate_attachment_metadata( $post_id, $upload['file'] ) );
</span><del>-               
</del><ins>+
</ins><span class="cx">           // remap resized image URLs, works by stripping the extension and remapping the URL stub.
</span><span class="cx">          if ( preg_match( '!^image/!', $info['type'] ) ) {
</span><span class="cx">              $parts = pathinfo( $url );
</span><span class="cx">              $name = basename( $parts['basename'], ".{$parts['extension']}" ); // PATHINFO_FILENAME in PHP 5.2
</span><del>-               
</del><ins>+
</ins><span class="cx">               $parts_new = pathinfo( $upload['url'] );
</span><span class="cx">              $name_new = basename( $parts_new['basename'], ".{$parts_new['extension']}" );
</span><del>-               
</del><ins>+
</ins><span class="cx">               $this->processed_url_remap[$parts['dirname'] . '/' . $name] = $parts_new['dirname'] . '/' . $name_new;
</span><span class="cx">          }
</span><del>-               
</del><ins>+
</ins><span class="cx">           return $post_id;
</span><span class="cx">  }
</span><del>-       
</del><ins>+
</ins><span class="cx">   /**
</span><del>-        * Attempt to create a new menu item from import data
</del><ins>+         * Attempts to create a new menu item from import data.
</ins><span class="cx">    *
</span><del>-        * Fails for draft, orphaned menu items and those without an associated nav_menu
-        * or an invalid nav_menu term. If the post type or term object which the menu item
-        * represents doesn't exist then the menu item will not be imported (waits until the
-        * end of the import to retry again before discarding).
</del><ins>+         * Fails for draft, orphaned menu items and those without an associated
+        * nav_menu or an invalid nav_menu term. If the post type or term object
+        * which the menu item represents doesn't exist, the menu item will not be
+        * imported (waits until the end of the import to retry again before
+        * discarding).
</ins><span class="cx">    *
</span><span class="cx">   * @param array $item Menu item details from WXR file
</span><span class="cx">   * @return int|WP_Error
</span><span class="lines">@@ -786,21 +810,21 @@
</span><span class="cx"> 
</span><span class="cx">          // no nav_menu term associated with this menu item
</span><span class="cx">          if ( ! $menu_slug ) {
</span><del>-                       $this->warnings[] = new WP_Error( 
-                                       'import_process_menu_item_slug_warning', 
-                                       __( 'Menu item skipped due to missing menu slug', 
</del><ins>+                        $this->warnings[] = new WP_Error(
+                                       'import_process_menu_item_slug_warning',
+                                       __( 'Menu item skipped due to missing menu slug',
</ins><span class="cx">                                                   'wordpress-importer' ) );
</span><span class="cx">                  return 0;
</span><span class="cx">          }
</span><span class="cx"> 
</span><span class="cx">          $menu_id = term_exists( $menu_slug, 'nav_menu' );
</span><span class="cx">          if ( ! $menu_id ) {
</span><del>-                       $this->warnings[] = new WP_Error( 
-                                       'import_process_menu_item_slug_warning', 
-                                       sprintf( 
-                                                       __( 
-                                                                       'Menu item skipped due to invalid menu slug: %s', 
-                                                                       'wordpress-importer' ), 
</del><ins>+                        $this->warnings[] = new WP_Error(
+                                       'import_process_menu_item_slug_warning',
+                                       sprintf(
+                                                       __(
+                                                                       'Menu item skipped due to invalid menu slug: %s',
+                                                                       'wordpress-importer' ),
</ins><span class="cx">                                                   esc_html( $menu_slug ) ) );
</span><span class="cx">                  return 0;
</span><span class="cx">          } else {
</span><span class="lines">@@ -851,7 +875,7 @@
</span><span class="cx">          $id = wp_update_nav_menu_item( $menu_id, 0, $args );
</span><span class="cx">          if ( $id && ! is_wp_error( $id ) )
</span><span class="cx">                  $this->processed_menu_items[intval($item['post_id'])] = (int) $id;
</span><del>-               
</del><ins>+
</ins><span class="cx">           return $id;
</span><span class="cx">  }
</span><span class="cx"> 
</span><span class="lines">@@ -859,9 +883,9 @@
</span><span class="cx">   * Creates new posts based on import data.
</span><span class="cx">   *
</span><span class="cx">   * Posts marked as having a parent which doesn't exist will become top level
</span><del>-        * items. Doesn't create a new post if: the post type doesn't exist, the 
-        * given post ID is already noted as imported or a post with the same title 
-        * and date already exists. Note that new/updated terms, comments and meta 
</del><ins>+         * items. Doesn't create a new post if: the post type doesn't exist, the
+        * given post ID is already noted as imported or a post with the same title
+        * and date already exists. Note that new/updated terms, comments and meta
</ins><span class="cx">    * are imported for the last of the above.
</span><span class="cx">   */
</span><span class="cx">  protected function process_posts() {
</span><span class="lines">@@ -870,12 +894,12 @@
</span><span class="cx">                  $this->posts = apply_filters( 'wp_import_posts', $this->posts );
</span><span class="cx">                  $this->set_param('filtered_wp_import_posts', true);
</span><span class="cx">          }
</span><del>-               
</del><ins>+
</ins><span class="cx">           // use an iterator object with which we can track state
</span><del>-               if ( ! ($iterator = $this->get_param( 'process_posts_iterator', null ) 
</del><ins>+                if ( ! ($iterator = $this->get_param( 'process_posts_iterator', null )
</ins><span class="cx">                           instanceof ArrayIterator) )
</span><span class="cx">                  $iterator = new ArrayIterator( $this->posts );
</span><del>-               
</del><ins>+
</ins><span class="cx">           foreach ( $iterator as $post ) {
</span><span class="cx">                  $post = apply_filters( 'wp_import_post_data_raw', $post );
</span><span class="cx">                  if ( ! post_type_exists( $post['post_type'] ) ) {
</span><span class="lines">@@ -883,43 +907,43 @@
</span><span class="cx">                                          'title' => esc_html( $post['post_title'] ),
</span><span class="cx">                                          'post_type' => esc_html( $post['post_type'] )
</span><span class="cx">                          );
</span><del>-                               $this->warnings[] = new WP_Error( 
-                                               'import_process_posts_post_type_warning', 
-                                               sprintf( 
-                                                               __( 
-                                                                               'Failed to import &#8220;%s&#8221;: Invalid post type %s', 
-                                                                               'wordpress-importer' ), 
</del><ins>+                                $this->warnings[] = new WP_Error(
+                                               'import_process_posts_post_type_warning',
+                                               sprintf(
+                                                               __(
+                                                                               'Failed to import &#8220;%s&#8221;: Invalid post type %s',
+                                                                               'wordpress-importer' ),
</ins><span class="cx">                                                           $error_data['title'], $error_data['post_type'] ),
</span><span class="cx">                                          $error_data );
</span><span class="cx">                          do_action( 'wp_import_post_exists', $post );
</span><span class="cx">                          continue;
</span><span class="cx">                  }
</span><del>-                       
</del><ins>+
</ins><span class="cx">                   if ( isset( $this->processed_posts[$post['post_id']] ) &&
</span><span class="cx">                                   ! empty( $post['post_id'] ) )
</span><span class="cx">                          continue;
</span><del>-                       
</del><ins>+
</ins><span class="cx">                   if ( $post['status'] == 'auto-draft' )
</span><span class="cx">                          continue;
</span><del>-                       
</del><ins>+
</ins><span class="cx">                   if ( 'nav_menu_item' == $post['post_type'] ) {
</span><span class="cx">                          $this->process_menu_item( $post );
</span><span class="cx">                          continue;
</span><span class="cx">                  }
</span><del>-                       
</del><ins>+
</ins><span class="cx">                   $post_type_object = get_post_type_object( $post['post_type'] );
</span><del>-                       
-                       $post_exists = post_exists( $post['post_title'], '', 
</del><ins>+
+                       $post_exists = post_exists( $post['post_title'], '',
</ins><span class="cx">                                   $post['post_date'] );
</span><span class="cx">                  if ( $post_exists &&
</span><span class="cx">                                   get_post_type( $post_exists ) == $post['post_type'] ) {
</span><del>-                               $this->warnings[] = new WP_Error( 
-                                               'import_process_posts_post_exists_warning', 
-                                               sprintf( 
-                                                               __( '%s &#8220;%s&#8221; already exists.', 
-                                                                               'wordpress-importer' ), 
-                                                               $post_type_object->labels->singular_name, 
-                                                               esc_html( $post['post_title'] ) ), 
</del><ins>+                                $this->warnings[] = new WP_Error(
+                                               'import_process_posts_post_exists_warning',
+                                               sprintf(
+                                                               __( '%s &#8220;%s&#8221; already exists.',
+                                                                               'wordpress-importer' ),
+                                                               $post_type_object->labels->singular_name,
+                                                               esc_html( $post['post_title'] ) ),
</ins><span class="cx">                                           array(
</span><span class="cx">                                                          'post_type' => $post_type_object->labels->singular_name,
</span><span class="cx">                                                          'title' => esc_html( $post['post_title'] )
</span><span class="lines">@@ -933,19 +957,19 @@
</span><span class="cx">                                          $post_parent = $this->processed_posts[$post_parent];
</span><span class="cx">                                          // otherwise record the parent for later
</span><span class="cx">                                  } else {
</span><del>-                                               $this->processed_post_orphans[intval( 
</del><ins>+                                                $this->processed_post_orphans[intval(
</ins><span class="cx">                                                           $post['post_id'] )] = $post_parent;
</span><span class="cx">                                          $post_parent = 0;
</span><span class="cx">                                  }
</span><span class="cx">                          }
</span><del>-                               
</del><ins>+
</ins><span class="cx">                           // map the post author
</span><span class="cx">                          $author = sanitize_user( $post['post_author'], true );
</span><span class="cx">                          if ( isset( $this->processed_author_mappings[$author] ) )
</span><span class="cx">                                  $author = $this->processed_author_mappings[$author];
</span><span class="cx">                          else
</span><span class="cx">                                  $author = (int) $this->get_param( 'admin_user_id', 0 );
</span><del>-                               
</del><ins>+
</ins><span class="cx">                           $postdata = array(
</span><span class="cx">                                          'import_id' => $post['post_id'],
</span><span class="cx">                                          'post_author' => $author,
</span><span class="lines">@@ -964,17 +988,17 @@
</span><span class="cx">                                          'post_type' => $post['post_type'],
</span><span class="cx">                                          'post_password' => $post['post_password']
</span><span class="cx">                          );
</span><del>-                               
</del><ins>+
</ins><span class="cx">                           $original_post_ID = $post['post_id'];
</span><del>-                               $postdata = apply_filters( 'wp_import_post_data_processed', 
</del><ins>+                                $postdata = apply_filters( 'wp_import_post_data_processed',
</ins><span class="cx">                                           $postdata, $post );
</span><del>-                               
</del><ins>+
</ins><span class="cx">                           /*
</span><span class="cx">                           * @todo decouple attachment processing from post processing
</span><span class="cx">                           */
</span><span class="cx">                          if ( 'attachment' == $postdata['post_type'] ) {
</span><span class="cx">                                  $remote_url = ! empty( $post['attachment_url'] ) ? $post['attachment_url'] : $post['guid'];
</span><del>-                                       
</del><ins>+
</ins><span class="cx">                                   // try to use _wp_attached file for upload folder placement
</span><span class="cx">                                  // to ensure the same location as the export site
</span><span class="cx">                                  // e.g. location is 2003/05/image.jpg but the attachment
</span><span class="lines">@@ -983,48 +1007,48 @@
</span><span class="cx">                                  if ( isset( $post['postmeta'] ) ) {
</span><span class="cx">                                          foreach ( $post['postmeta'] as $meta ) {
</span><span class="cx">                                                  if ( $meta['key'] == '_wp_attached_file' ) {
</span><del>-                                                               if ( preg_match( '%^[0-9]{4}/[0-9]{2}%', 
</del><ins>+                                                                if ( preg_match( '%^[0-9]{4}/[0-9]{2}%',
</ins><span class="cx">                                                                           $meta['value'], $matches ) )
</span><span class="cx">                                                                  $postdata['upload_date'] = $matches[0];
</span><span class="cx">                                                          break;
</span><span class="cx">                                                  }
</span><span class="cx">                                          }
</span><span class="cx">                                  }
</span><del>-                                       
-                                       $comment_post_ID = $post_id = $this->process_attachment( 
</del><ins>+
+                                       $comment_post_ID = $post_id = $this->process_attachment(
</ins><span class="cx">                                                   $postdata, $remote_url );
</span><span class="cx">                          } else {
</span><del>-                                       $comment_post_ID = $post_id = wp_insert_post( $postdata, 
</del><ins>+                                        $comment_post_ID = $post_id = wp_insert_post( $postdata,
</ins><span class="cx">                                                   true );
</span><del>-                                       do_action( 'wp_import_insert_post', $post_id, 
</del><ins>+                                        do_action( 'wp_import_insert_post', $post_id,
</ins><span class="cx">                                                   $original_post_ID, $postdata, $post );
</span><span class="cx">                          }
</span><del>-                               
</del><ins>+
</ins><span class="cx">                           if ( is_wp_error( $post_id ) ) {
</span><del>-                                       $this->warnings[] = new WP_Error( 
-                                                       'import_process_posts_failure_warning', 
-                                                       sprintf( 
-                                                                       __( 
-                                                                                       'Failed to import %s &#8220;%s&#8221;', 
-                                                                                       'wordpress-importer' ), 
-                                                                       $post_type_object->labels->singular_name, 
</del><ins>+                                        $this->warnings[] = new WP_Error(
+                                                       'import_process_posts_failure_warning',
+                                                       sprintf(
+                                                                       __(
+                                                                                       'Failed to import %s &#8220;%s&#8221;',
+                                                                                       'wordpress-importer' ),
+                                                                       $post_type_object->labels->singular_name,
</ins><span class="cx">                                                                   esc_html( $post['post_title'] ) ), $post_id );
</span><span class="cx">                                  continue;
</span><span class="cx">                          }
</span><del>-                               
</del><ins>+
</ins><span class="cx">                           if ( $post['is_sticky'] == 1 )
</span><span class="cx">                                  stick_post( $post_id );
</span><span class="cx">                  }
</span><del>-                       
</del><ins>+
</ins><span class="cx">                   // map pre-import ID to local ID
</span><span class="cx">                  $this->processed_posts[intval( $post['post_id'] )] = (int) $post_id;
</span><del>-                       
</del><ins>+
</ins><span class="cx">                   if ( ! isset( $post['terms'] ) )
</span><span class="cx">                          $post['terms'] = array();
</span><del>-                       
-                       $post['terms'] = apply_filters( 'wp_import_post_terms', 
</del><ins>+
+                       $post['terms'] = apply_filters( 'wp_import_post_terms',
</ins><span class="cx">                                   $post['terms'], $post_id, $post );
</span><del>-                       
</del><ins>+
</ins><span class="cx">                   // add categories, tags and other terms
</span><span class="cx">                  if ( ! empty( $post['terms'] ) ) {
</span><span class="cx">                          $terms_to_set = array();
</span><span class="lines">@@ -1034,44 +1058,44 @@
</span><span class="cx">                                  $term_exists = term_exists( $term['slug'], $taxonomy );
</span><span class="cx">                                  $term_id = is_array( $term_exists ) ? $term_exists['term_id'] : $term_exists;
</span><span class="cx">                                  if ( ! $term_id ) {
</span><del>-                                               $t = wp_insert_term( $term['name'], $taxonomy, 
</del><ins>+                                                $t = wp_insert_term( $term['name'], $taxonomy,
</ins><span class="cx">                                                           array(
</span><span class="cx">                                                                          'slug' => $term['slug']
</span><span class="cx">                                                          ) );
</span><span class="cx">                                          if ( ! is_wp_error( $t ) ) {
</span><span class="cx">                                                  $term_id = $t['term_id'];
</span><del>-                                                       do_action( 'wp_import_insert_term', $t, $term, 
</del><ins>+                                                        do_action( 'wp_import_insert_term', $t, $term,
</ins><span class="cx">                                                                   $post_id, $post );
</span><span class="cx">                                          } else {
</span><del>-                                                       $this->warnings[] = new WP_Error( 
-                                                                       'import_process_term_warning', 
-                                                                       sprintf( 
-                                                                                       __( 'Failed to import %s %s', 
-                                                                                                       'wordpress-importer' ), 
-                                                                                       esc_html( $taxonomy ), 
</del><ins>+                                                        $this->warnings[] = new WP_Error(
+                                                                       'import_process_term_warning',
+                                                                       sprintf(
+                                                                                       __( 'Failed to import %s %s',
+                                                                                                       'wordpress-importer' ),
+                                                                                       esc_html( $taxonomy ),
</ins><span class="cx">                                                                                   esc_html( $term['name'] ) ), $t );
</span><del>-                                                       do_action( 'wp_import_insert_term_failed', $t, 
</del><ins>+                                                        do_action( 'wp_import_insert_term_failed', $t,
</ins><span class="cx">                                                                   $term, $post_id, $post );
</span><span class="cx">                                                  continue;
</span><span class="cx">                                          }
</span><span class="cx">                                  }
</span><span class="cx">                                  $terms_to_set[$taxonomy][] = intval( $term_id );
</span><span class="cx">                          }
</span><del>-                               
</del><ins>+
</ins><span class="cx">                           foreach ( $terms_to_set as $tax => $ids ) {
</span><span class="cx">                                  $tt_ids = wp_set_post_terms( $post_id, $ids, $tax );
</span><del>-                                       do_action( 'wp_import_set_post_terms', $tt_ids, $ids, 
</del><ins>+                                        do_action( 'wp_import_set_post_terms', $tt_ids, $ids,
</ins><span class="cx">                                                   $tax, $post_id, $post );
</span><span class="cx">                          }
</span><span class="cx">                          unset( $post['terms'], $terms_to_set );
</span><span class="cx">                  }
</span><del>-                       
</del><ins>+
</ins><span class="cx">                   if ( ! isset( $post['comments'] ) )
</span><span class="cx">                          $post['comments'] = array();
</span><del>-                       
-                       $post['comments'] = apply_filters( 'wp_import_post_comments', 
</del><ins>+
+                       $post['comments'] = apply_filters( 'wp_import_post_comments',
</ins><span class="cx">                                   $post['comments'], $post_id, $post );
</span><del>-                       
</del><ins>+
</ins><span class="cx">                   // add/update comments
</span><span class="cx">                  if ( ! empty( $post['comments'] ) ) {
</span><span class="cx">                          $num_comments = 0;
</span><span class="lines">@@ -1089,75 +1113,75 @@
</span><span class="cx">                                  $newcomments[$comment_id]['comment_approved'] = $comment['comment_approved'];
</span><span class="cx">                                  $newcomments[$comment_id]['comment_type'] = $comment['comment_type'];
</span><span class="cx">                                  $newcomments[$comment_id]['comment_parent'] = $comment['comment_parent'];
</span><del>-                                       $newcomments[$comment_id]['commentmeta'] = isset( 
</del><ins>+                                        $newcomments[$comment_id]['commentmeta'] = isset(
</ins><span class="cx">                                                   $comment['commentmeta'] ) ? $comment['commentmeta'] : array();
</span><del>-                                       if ( isset( 
</del><ins>+                                        if ( isset(
</ins><span class="cx">                                                   $this->processed_authors[$comment['comment_user_id']] ) )
</span><span class="cx">                                          $newcomments[$comment_id]['user_id'] = $this->processed_authors[$comment['comment_user_id']];
</span><span class="cx">                          }
</span><span class="cx">                          ksort( $newcomments );
</span><del>-                               
</del><ins>+
</ins><span class="cx">                           foreach ( $newcomments as $key => $comment ) {
</span><span class="cx">                                  // if this is a new post we can skip the comment_exists()
</span><span class="cx">                                  // check
</span><del>-                                       if ( ! $post_exists || ! comment_exists( 
-                                                       $comment['comment_author'], 
</del><ins>+                                        if ( ! $post_exists || ! comment_exists(
+                                                       $comment['comment_author'],
</ins><span class="cx">                                                   $comment['comment_date'] ) ) {
</span><del>-                                               if ( isset( 
</del><ins>+                                                if ( isset(
</ins><span class="cx">                                                           $inserted_comments[$comment['comment_parent']] ) )
</span><span class="cx">                                                  $comment['comment_parent'] = $inserted_comments[$comment['comment_parent']];
</span><span class="cx">                                          $comment = wp_filter_comment( $comment );
</span><del>-                                               $inserted_comments[$key] = wp_insert_comment( 
</del><ins>+                                                $inserted_comments[$key] = wp_insert_comment(
</ins><span class="cx">                                                           $comment );
</span><del>-                                               do_action( 'wp_import_insert_comment', 
-                                                               $inserted_comments[$key], $comment, 
</del><ins>+                                                do_action( 'wp_import_insert_comment',
+                                                               $inserted_comments[$key], $comment,
</ins><span class="cx">                                                           $comment_post_ID, $post );
</span><del>-                                               
</del><ins>+
</ins><span class="cx">                                           foreach ( $comment['commentmeta'] as $meta ) {
</span><span class="cx">                                                  $value = maybe_unserialize( $meta['value'] );
</span><del>-                                                       add_comment_meta( $inserted_comments[$key], 
</del><ins>+                                                        add_comment_meta( $inserted_comments[$key],
</ins><span class="cx">                                                                   $meta['key'], $value );
</span><span class="cx">                                          }
</span><del>-                                               
</del><ins>+
</ins><span class="cx">                                           $num_comments ++;
</span><span class="cx">                                  }
</span><span class="cx">                          }
</span><span class="cx">                          unset( $newcomments, $inserted_comments, $post['comments'] );
</span><span class="cx">                  }
</span><del>-                       
</del><ins>+
</ins><span class="cx">                   if ( ! isset( $post['postmeta'] ) )
</span><span class="cx">                          $post['postmeta'] = array();
</span><del>-                       
-                       $post['postmeta'] = apply_filters( 'wp_import_post_meta', 
</del><ins>+
+                       $post['postmeta'] = apply_filters( 'wp_import_post_meta',
</ins><span class="cx">                                   $post['postmeta'], $post_id, $post );
</span><del>-                       
</del><ins>+
</ins><span class="cx">                   // add/update post meta
</span><span class="cx">                  if ( ! empty( $post['postmeta'] ) ) {
</span><span class="cx">                          foreach ( $post['postmeta'] as $meta ) {
</span><del>-                                       $key = apply_filters( 'import_post_meta_key', 
</del><ins>+                                        $key = apply_filters( 'import_post_meta_key',
</ins><span class="cx">                                                   $meta['key'], $post_id, $post );
</span><span class="cx">                                  $value = false;
</span><del>-                                       
</del><ins>+
</ins><span class="cx">                                   if ( '_edit_last' == $key ) {
</span><del>-                                               if ( isset( 
-                                                               $this->processed_authors[intval( 
</del><ins>+                                                if ( isset(
+                                                               $this->processed_authors[intval(
</ins><span class="cx">                                                                           $meta['value'] )] ) )
</span><del>-                                                       $value = $this->processed_authors[intval( 
</del><ins>+                                                        $value = $this->processed_authors[intval(
</ins><span class="cx">                                                                   $meta['value'] )];
</span><span class="cx">                                          else
</span><span class="cx">                                                  $key = false;
</span><span class="cx">                                  }
</span><del>-                                       
</del><ins>+
</ins><span class="cx">                                   if ( $key ) {
</span><span class="cx">                                          // export gets meta straight from the DB so could have a
</span><span class="cx">                                          // serialized string
</span><span class="cx">                                          if ( ! $value )
</span><span class="cx">                                                  $value = maybe_unserialize( $meta['value'] );
</span><del>-                                               
</del><ins>+
</ins><span class="cx">                                           add_post_meta( $post_id, $key, $value );
</span><del>-                                               do_action( 'import_post_meta', $post_id, $key, 
</del><ins>+                                                do_action( 'import_post_meta', $post_id, $key,
</ins><span class="cx">                                                           $value );
</span><del>-                                               
</del><ins>+
</ins><span class="cx">                                           // if the post has a featured image, take note of this
</span><span class="cx">                                          // in case of remap
</span><span class="cx">                                          if ( '_thumbnail_id' == $key )
</span><span class="lines">@@ -1165,13 +1189,13 @@
</span><span class="cx">                                  }
</span><span class="cx">                          }
</span><span class="cx">                  }
</span><del>-                               
</del><ins>+
</ins><span class="cx">                   // stop execution if we've reached the end of this cron run's
</span><span class="cx">                  // limit
</span><span class="cx">                  if ( ! $this->have_time() )
</span><span class="cx">                          break;
</span><span class="cx">          } // foreach
</span><del>-               
</del><ins>+
</ins><span class="cx">           // only unset after all posts have gone through the foreach
</span><span class="cx">          if(! $iterator->valid()) {
</span><span class="cx">                  // done
</span><span class="lines">@@ -1180,7 +1204,7 @@
</span><span class="cx">                  $this->advance();
</span><span class="cx">                  return true;
</span><span class="cx">          }
</span><del>-                               
</del><ins>+
</ins><span class="cx">           // save the state of our iterator
</span><span class="cx">          $this->set_param('process_posts_iterator', $iterator);
</span><span class="cx">          return false;
</span><span class="lines">@@ -1204,27 +1228,27 @@
</span><span class="cx">                  if ( $local_child_id && $local_parent_id ) {
</span><span class="cx">                          // this used to use $wpdb->update(), but this would be
</span><span class="cx">                          // preferable for a self-contained importer
</span><del>-                               $update = wp_update_post( 
</del><ins>+                                $update = wp_update_post(
</ins><span class="cx">                                           array(
</span><span class="cx">                                                          'ID' => (int) $local_child_id,
</span><span class="cx">                                                          'post_parent' => (int) $local_parent_id
</span><span class="cx">                                          ), true );
</span><span class="cx">                          if ( is_wp_error( $update ) )
</span><del>-                                       $this->warnings[] = new WP_Error( 
-                                                       'import_process_parents_post_warning', 
-                                                       sprintf( 
-                                                                       __( 
-                                                                                       'Failed to update parent on post orphan with ID %d', 
-                                                                                       'wordpress-importer' ), 
</del><ins>+                                        $this->warnings[] = new WP_Error(
+                                                       'import_process_parents_post_warning',
+                                                       sprintf(
+                                                                       __(
+                                                                                       'Failed to update parent on post orphan with ID %d',
+                                                                                       'wordpress-importer' ),
</ins><span class="cx">                                                                   $local_child_id ), $update );
</span><span class="cx">                  }
</span><span class="cx">          }
</span><del>-               
</del><ins>+
</ins><span class="cx">           // all other posts/terms are imported, retry menu items with missing
</span><span class="cx">          // associated object
</span><span class="cx">          foreach ( $this->processed_menu_missing_items as $item )
</span><span class="cx">                  $this->process_menu_item( $item );
</span><del>-                       
</del><ins>+
</ins><span class="cx">           // find parents for menu item orphans
</span><span class="cx">          foreach ( $this->processed_menu_orphan_items as $child_id => $parent_id ) {
</span><span class="cx">                  $local_child_id = $local_parent_id = 0;
</span><span class="lines">@@ -1232,12 +1256,12 @@
</span><span class="cx">                          $local_child_id = $this->processed_menu_items[$child_id];
</span><span class="cx">                  if ( isset( $this->processed_menu_items[$parent_id] ) )
</span><span class="cx">                          $local_parent_id = $this->processed_menu_items[$parent_id];
</span><del>-                       
</del><ins>+
</ins><span class="cx">                   if ( $local_child_id && $local_parent_id )
</span><del>-                               update_post_meta( $local_child_id, 
</del><ins>+                                update_post_meta( $local_child_id,
</ins><span class="cx">                                           '_menu_item_menu_item_parent', (int) $local_parent_id );
</span><span class="cx">          }
</span><del>-               
</del><ins>+
</ins><span class="cx">           $this->advance();
</span><span class="cx">          return true;
</span><span class="cx">  }
</span><span class="lines">@@ -1261,82 +1285,82 @@
</span><span class="cx">   * @return array WP_Error file location details on success, WP_Error
</span><span class="cx">   *         otherwise
</span><span class="cx">   */
</span><del>-       protected function fetch_remote_file( $url, $post ) {
</del><ins>+        public function fetch_remote_file( $url, $post ) {
</ins><span class="cx">           // extract the file name and extension from the url
</span><span class="cx">          $file_name = basename( $url );
</span><del>-               
</del><ins>+
</ins><span class="cx">           // get placeholder file in the upload dir with a unique, sanitized
</span><span class="cx">          // filename
</span><span class="cx">          $upload = wp_upload_bits( $file_name, 0, '', $post['upload_date'] );
</span><span class="cx">          if ( $upload['error'] )
</span><span class="cx">                  return new WP_Error( 'upload_dir_error', $upload['error'] );
</span><del>-                       
</del><ins>+
</ins><span class="cx">                   // fetch the remote url and write it to the placeholder file
</span><span class="cx">          $headers = wp_get_http( $url, $upload['file'] );
</span><del>-               
</del><ins>+
</ins><span class="cx">           // request failed
</span><span class="cx">          if ( ! $headers ) {
</span><span class="cx">                  @unlink( $upload['file'] );
</span><del>-                       return new WP_Error( 'import_file_error', 
-                                       __( 'Remote server did not respond', 
</del><ins>+                        return new WP_Error( 'import_file_error',
+                                       __( 'Remote server did not respond',
</ins><span class="cx">                                                   'wordpress-importer' ) );
</span><span class="cx">          }
</span><del>-               
</del><ins>+
</ins><span class="cx">           // make sure the fetch was successful
</span><span class="cx">          if ( $headers['response'] != '200' ) {
</span><span class="cx">                  @unlink( $upload['file'] );
</span><del>-                       return new WP_Error( 'import_file_error', 
-                                       sprintf( 
-                                                       __( 
-                                                                       'Remote server returned error response %1$d %2$s', 
-                                                                       'wordpress-importer' ), 
-                                                       esc_html( $headers['response'] ), 
</del><ins>+                        return new WP_Error( 'import_file_error',
+                                       sprintf(
+                                                       __(
+                                                                       'Remote server returned error response %1$d %2$s',
+                                                                       'wordpress-importer' ),
+                                                       esc_html( $headers['response'] ),
</ins><span class="cx">                                                   get_status_header_desc( $headers['response'] ) ) );
</span><span class="cx">          }
</span><del>-               
</del><ins>+
</ins><span class="cx">           $filesize = filesize( $upload['file'] );
</span><del>-               
</del><ins>+
</ins><span class="cx">           if ( isset( $headers['content-length'] ) &&
</span><span class="cx">                           $filesize != $headers['content-length'] ) {
</span><span class="cx">                  @unlink( $upload['file'] );
</span><del>-                       return new WP_Error( 'import_file_error', 
-                                       __( 'Remote file is incorrect size', 
</del><ins>+                        return new WP_Error( 'import_file_error',
+                                       __( 'Remote file is incorrect size',
</ins><span class="cx">                                                   'wordpress-importer' ) );
</span><span class="cx">          }
</span><del>-               
</del><ins>+
</ins><span class="cx">           if ( 0 == $filesize ) {
</span><span class="cx">                  @unlink( $upload['file'] );
</span><del>-                       return new WP_Error( 'import_file_error', 
</del><ins>+                        return new WP_Error( 'import_file_error',
</ins><span class="cx">                                   __( 'Zero size file downloaded', 'wordpress-importer' ) );
</span><span class="cx">          }
</span><del>-               
</del><ins>+
</ins><span class="cx">           $max_size = (int) $this->max_attachment_size();
</span><span class="cx">          if ( ! empty( $max_size ) && $filesize > $max_size ) {
</span><span class="cx">                  @unlink( $upload['file'] );
</span><del>-                       return new WP_Error( 'import_file_error', 
-                                       sprintf( 
-                                                       __( 'Remote file is too large, limit is %s', 
-                                                                       'wordpress-importer' ), 
</del><ins>+                        return new WP_Error( 'import_file_error',
+                                       sprintf(
+                                                       __( 'Remote file is too large, limit is %s',
+                                                                       'wordpress-importer' ),
</ins><span class="cx">                                                   size_format( $max_size ) ) );
</span><span class="cx">          }
</span><del>-               
</del><ins>+
</ins><span class="cx">           // keep track of the old and new urls so we can substitute them later
</span><span class="cx">          $this->processed_url_remap[$url] = $upload['url'];
</span><span class="cx">          $this->processed_url_remap[$post['guid']] = $upload['url'];
</span><span class="cx">          // r13735, really needed?
</span><span class="cx">          // ^ keep track of the destination if the remote url is redirected
</span><span class="cx">          // somewhere else
</span><del>-               
</del><ins>+
</ins><span class="cx">           if ( isset( $headers['x-final-location'] ) &&
</span><span class="cx">                           $headers['x-final-location'] != $url )
</span><span class="cx">                  $this->processed_url_remap[$headers['x-final-location']] = $upload['url'];
</span><del>-               
</del><ins>+
</ins><span class="cx">           return $upload;
</span><span class="cx">  }
</span><span class="cx"> 
</span><span class="cx">  /**
</span><span class="cx">   * Decide if the given meta key maps to information we will want to import
</span><del>-        * 
</del><ins>+         *
</ins><span class="cx">    * @param string $key
</span><span class="cx">   *              The meta key to check
</span><span class="cx">   * @return string|bool key if we do want to import, false if not
</span><span class="lines">@@ -1344,11 +1368,11 @@
</span><span class="cx">  public function is_valid_meta_key( $key ) {
</span><span class="cx">          // skip attachment metadata since we'll regenerate it from scratch
</span><span class="cx">          // skip _edit_lock as not relevant for import
</span><del>-               if ( in_array( $key, 
-                               array( 
</del><ins>+                if ( in_array( $key,
+                               array(
</ins><span class="cx">                                           '_wp_attached_file',
</span><span class="cx">                                          '_wp_attachment_metadata',
</span><del>-                                               '_edit_lock' 
</del><ins>+                                                '_edit_lock'
</ins><span class="cx">                           ) ) )
</span><span class="cx">                  return false;
</span><span class="cx">          return $key;
</span><span class="lines">@@ -1357,7 +1381,7 @@
</span><span class="cx">  /**
</span><span class="cx">   * Decide whether or not the importer is allowed to create users. Default is
</span><span class="cx">   * true, can be filtered via import_allow_create_users
</span><del>-        * 
</del><ins>+         *
</ins><span class="cx">    * @return bool True if creating users is allowed
</span><span class="cx">   */
</span><span class="cx">  public function is_allowed_user_creation() {
</span><span class="lines">@@ -1367,11 +1391,11 @@
</span><span class="cx">  /**
</span><span class="cx">   * Retrieves whether the importer should attempt to download attachment
</span><span class="cx">   * files.
</span><del>-        * 
</del><ins>+         *
</ins><span class="cx">    * Default is true, can be filtered via
</span><span class="cx">   * import_allow_fetch_attachments. The choice made at the import options
</span><span class="cx">   * screen must also be true; false here hides that checkbox.
</span><del>-        * 
</del><ins>+         *
</ins><span class="cx">    * @return bool True if downloading attachments is allowed
</span><span class="cx">   */
</span><span class="cx">  public function is_allowed_attachment_fetch() {
</span><span class="lines">@@ -1380,37 +1404,37 @@
</span><span class="cx"> 
</span><span class="cx">  /**
</span><span class="cx">   * Retrieves the maximum file size for downloaded attachments.
</span><del>-        * 
-        * Default is 0 (unlimited), can be filtered via 
</del><ins>+         *
+        * Default is 0 (unlimited), can be filtered via
</ins><span class="cx">    * import_attachment_size_limit.
</span><del>-        * 
</del><ins>+         *
</ins><span class="cx">    * @return int Maximum attachment file size to import
</span><span class="cx">   */
</span><span class="cx">  public function get_max_attachment_size() {
</span><span class="cx">          return apply_filters( 'import_attachment_size_limit', 0 );
</span><span class="cx">  }
</span><del>-       
</del><ins>+
</ins><span class="cx">   /**
</span><span class="cx">   * Retrieves the fatal error.
</span><del>-        * 
</del><ins>+         *
</ins><span class="cx">    * @return WP_Error|null
</span><span class="cx">   */
</span><span class="cx">  public function get_error() {
</span><span class="cx">          return $this->error;
</span><span class="cx">  }
</span><del>-       
</del><ins>+
</ins><span class="cx">   /**
</span><span class="cx">   * Retrieves all non-fatal warnings.
</span><del>-        * 
</del><ins>+         *
</ins><span class="cx">    * @return WP_Error[]
</span><span class="cx">   */
</span><span class="cx">  public function get_warnings() {
</span><span class="cx">          return $this->warnings;
</span><span class="cx">  }
</span><del>-       
</del><ins>+
</ins><span class="cx">   /**
</span><span class="cx">   * Retrieves the current step.
</span><del>-        * 
</del><ins>+         *
</ins><span class="cx">    * @return string|WP_Error
</span><span class="cx">   */
</span><span class="cx">  public function get_step() {
</span><span class="lines">@@ -1429,27 +1453,27 @@
</span><span class="cx">   * Previously, some of these params would have been directly accessed with
</span><span class="cx">   * $_POST; now they are stored.
</span><span class="cx">   *
</span><del>-        * @param string $name          
-        * @param mixed $value          
</del><ins>+         * @param string $name
+        * @param mixed $value
</ins><span class="cx">    * @return boolean|WP_Error if unsuccessful, an error object
</span><span class="cx">   */
</span><span class="cx">  public function set_param ( $name, $value ) {
</span><span class="cx">          if ( ! isset( $this->wxr_file ) ) {
</span><span class="cx">                  // cannot set user options before WXR data is parsed
</span><del>-                       return new WP_Error( 'import_param_set_error', 
-                                       __( 'Cannot set param without parsed data', 
</del><ins>+                        return new WP_Error( 'import_param_set_error',
+                                       __( 'Cannot set param without parsed data',
</ins><span class="cx">                                                   'wordpress-importer' ) );
</span><span class="cx">          }
</span><span class="cx">          if ( ! is_array( $this->params[$this->wxr_file] ) )
</span><span class="cx">                  $this->params[$this->wxr_file] = array();
</span><span class="cx">          $this->params[$this->wxr_file][$name] = $value;
</span><del>-               
</del><ins>+
</ins><span class="cx">           return true;
</span><span class="cx">  }
</span><del>-       
</del><ins>+
</ins><span class="cx">   /**
</span><span class="cx">   * Unsets a parameter.
</span><del>-        * 
</del><ins>+         *
</ins><span class="cx">    * @param string $name
</span><span class="cx">   * @return boolean|WP_Error
</span><span class="cx">   */
</span><span class="lines">@@ -1464,38 +1488,38 @@
</span><span class="cx">              $this->params[$this->wxr_file] = array();
</span><span class="cx">          elseif(key_exists($name, $this->params[$this->wxr_file]))
</span><span class="cx">                  unset($this->params[$this->wxr_file][$name]);
</span><del>-               
</del><ins>+
</ins><span class="cx">           return true;
</span><span class="cx">  }
</span><span class="cx"> 
</span><span class="cx">  /**
</span><span class="cx">   * Retrieves parameters typically used for user input.
</span><span class="cx">   *
</span><del>-        * @param string $name          
-        * @param mixed $default                
</del><ins>+         * @param string $name
+        * @param mixed $default
</ins><span class="cx">    * @return mixed WP_Error requested parameter, or if unsuccessful, an error
</span><span class="cx">   *         object
</span><span class="cx">   */
</span><span class="cx">  public function get_param ( $name, $default = null ) {
</span><span class="cx">          if ( ! isset( $this->wxr_file ) ) {
</span><span class="cx">                  // cannot get user options before WXR data is parsed
</span><del>-                       return new WP_Error( 'import_param_get_error', 
-                                       __( 'Cannot get param without parsed data', 
</del><ins>+                        return new WP_Error( 'import_param_get_error',
+                                       __( 'Cannot get param without parsed data',
</ins><span class="cx">                                                   'wordpress-importer' ) );
</span><span class="cx">          }
</span><span class="cx">          if ( isset( $this->params[$this->wxr_file] ) &&
</span><span class="cx">                           isset( $this->params[$this->wxr_file][$name] ) )
</span><span class="cx">                  return $this->params[$this->wxr_file][$name];
</span><del>-               
</del><ins>+
</ins><span class="cx">           return $default;
</span><span class="cx">  }
</span><del>-       
</del><ins>+
</ins><span class="cx">   /**
</span><span class="cx">   * Returns all params.
</span><del>-        * 
-        * The first dimension of this array is the WXR filename (for example, 
</del><ins>+         *
+        * The first dimension of this array is the WXR filename (for example,
</ins><span class="cx">    * <code>$params['/path/to/wxr.xml']</code>).
</span><del>-        * 
</del><ins>+         *
</ins><span class="cx">    * @return array
</span><span class="cx">   */
</span><span class="cx">  public function get_all_params () {
</span></span></pre></div>
<a id="2013frederickdingimportertrunkclasswpimportercronphp"></a>
<div class="modfile"><h4>Modified: 2013/frederickding/importer/trunk/class-wp-importer-cron.php (2174 => 2175)</h4>
<pre class="diff"><span>
<span class="info">--- 2013/frederickding/importer/trunk/class-wp-importer-cron.php     2013-07-29 18:37:33 UTC (rev 2174)
+++ 2013/frederickding/importer/trunk/class-wp-importer-cron.php        2013-07-29 19:29:18 UTC (rev 2175)
</span><span class="lines">@@ -1,12 +1,10 @@
</span><span class="cx"> <?php
</span><span class="cx"> /**
</span><del>- * WP_Importer_Cron base class
</del><ins>+ * WP_Importer_Cron base
</ins><span class="cx">  *
</span><del>- * Adds cron based importing functionality to WP_Importer
- *
</del><span class="cx">  * Forked from the Tumblr Importer (http://wordpress.org/plugins/tumblr-importer/)
</span><span class="cx">  * at revision 477917; original work by Otto42 and westi.
</span><del>- * 
</del><ins>+ *
</ins><span class="cx">  * @package WordPress
</span><span class="cx">  * @subpackage Importer
</span><span class="cx">  */
</span><span class="lines">@@ -25,11 +23,22 @@
</span><span class="cx">  }
</span><span class="cx"> 
</span><span class="cx">  /**
</span><del>-        * 
</del><ins>+         * WP_Importer_Cron base class
+        *
+        * Adds cron based functionality to WP_Importer, allowing for step-wise
+        * import processes that occur separate from a page view.
+        *
</ins><span class="cx">    * @since 0.7.0
</span><span class="cx">   */
</span><span class="cx">  class WP_Importer_Cron extends WP_Importer {
</span><span class="cx"> 
</span><ins>+               /**
+                * Instantiates a new cron-based importer object.
+                *
+                * If this method is overrided by a child class, it is crucial that the
+                * same initialization steps as below are done, such as by way of
+                * <code>parent::__construct();</code>
+                */
</ins><span class="cx">           function __construct() {
</span><span class="cx">                  // start the clock
</span><span class="cx">                  $this->_importer_started = time();
</span><span class="lines">@@ -41,7 +50,7 @@
</span><span class="cx"> 
</span><span class="cx">                  // add the importer hook
</span><span class="cx">                  add_action( 'wp_cron_importer_hook', array( $this, 'importer_callback' ) );
</span><del>-                       
</del><ins>+
</ins><span class="cx">                   // crucial! for preventing cache breaking
</span><span class="cx">                  wp_suspend_cache_invalidation( true );
</span><span class="cx">                  wp_suspend_cache_addition( true );
</span><span class="lines">@@ -71,13 +80,13 @@
</span><span class="cx">           * This is a filter for cron_schedules.
</span><span class="cx">           *
</span><span class="cx">           * @see wp_get_schedules()
</span><del>-                * @param array $schedules              
</del><ins>+                 * @param array $schedules
</ins><span class="cx">            * @return array filtered schedules
</span><span class="cx">           */
</span><span class="cx">          function importer_schedule( $schedules ) {
</span><del>-                       $schedules['everyminute'] = array( 
</del><ins>+                        $schedules['everyminute'] = array(
</ins><span class="cx">                                   'interval' => 60,
</span><del>-                                       'display' => __( 'Once Per Minute' ) 
</del><ins>+                                        'display' => __( 'Once Per Minute' )
</ins><span class="cx">                   );
</span><span class="cx">                  return $schedules;
</span><span class="cx">          }
</span><span class="lines">@@ -85,35 +94,35 @@
</span><span class="cx">          /**
</span><span class="cx">           * Schedules an importer job on the per-minute cron schedule.
</span><span class="cx">           *
</span><del>-                * @param callback $function_name               
</del><ins>+                 * @param callback $function_name
</ins><span class="cx">            * @param array $args optional
</span><span class="cx">           */
</span><span class="cx">          function schedule_import_job( $function_name, $args = array() ) {
</span><span class="cx">                  $this->callback = $function_name;
</span><del>-                       wp_schedule_event( time(), 'everyminute', 'wp_cron_importer_hook', 
</del><ins>+                        wp_schedule_event( time(), 'everyminute', 'wp_cron_importer_hook',
</ins><span class="cx">                                   $args );
</span><span class="cx">          }
</span><span class="cx"> 
</span><span class="cx">          /**
</span><span class="cx">           * Dispatches a cron event to an importer job or cleans up.
</span><del>-                * 
</del><ins>+                 *
</ins><span class="cx">            * @param array $args
</span><span class="cx">           *              optional
</span><span class="cx">           */
</span><span class="cx">          function importer_callback( $args = array() ) {
</span><span class="cx">                  $args = (array) $args;
</span><del>-                       
</del><ins>+
</ins><span class="cx">                   if ( isset( $this->callback ) ) {
</span><del>-                               $complete = call_user_func_array( 
-                                               array( 
</del><ins>+                                $complete = call_user_func_array(
+                                               array(
</ins><span class="cx">                                                           $this,
</span><del>-                                                               $this->callback 
</del><ins>+                                                                $this->callback
</ins><span class="cx">                                           ), $args );
</span><span class="cx">                  } else {
</span><span class="cx">                          // no callback, force the cron job to end
</span><span class="cx">                          $complete = true;
</span><span class="cx">                  }
</span><del>-                       
</del><ins>+
</ins><span class="cx">                   if ( $complete ) {
</span><span class="cx">                          // importer is finished, stop the scheduler
</span><span class="cx">                          wp_clear_scheduled_hook( 'wp_cron_importer_hook', $args );
</span><span class="lines">@@ -125,7 +134,7 @@
</span><span class="cx">           *
</span><span class="cx">           * On later runs, these variables are loaded from the option during
</span><span class="cx">           * instantiation.
</span><del>-                * 
</del><ins>+                 *
</ins><span class="cx">            * @return boolean
</span><span class="cx">           */
</span><span class="cx">          function save_vars() {
</span><span class="lines">@@ -135,7 +144,7 @@
</span><span class="cx">                                  unset( $vars[$var] );
</span><span class="cx">                  }
</span><span class="cx">                  update_option( get_class( $this ), $vars );
</span><del>-                       
</del><ins>+
</ins><span class="cx">                   return ! empty( $vars );
</span><span class="cx">          }
</span><span class="cx">  }
</span></span></pre></div>
<a id="2013frederickdingimportertrunkteststestclasswordpressimporterphp"></a>
<div class="modfile"><h4>Modified: 2013/frederickding/importer/trunk/tests/test-class-wordpress-importer.php (2174 => 2175)</h4>
<pre class="diff"><span>
<span class="info">--- 2013/frederickding/importer/trunk/tests/test-class-wordpress-importer.php        2013-07-29 18:37:33 UTC (rev 2174)
+++ 2013/frederickding/importer/trunk/tests/test-class-wordpress-importer.php   2013-07-29 19:29:18 UTC (rev 2175)
</span><span class="lines">@@ -13,22 +13,22 @@
</span><span class="cx">   */
</span><span class="cx">  function setUp() {
</span><span class="cx">          parent::setUp();
</span><del>-               
</del><ins>+
</ins><span class="cx">           if ( ! defined( 'WP_IMPORTING' ) )
</span><span class="cx">                  define( 'WP_IMPORTING', true );
</span><del>-               
</del><ins>+
</ins><span class="cx">           if ( ! defined( 'WP_LOAD_IMPORTERS' ) )
</span><span class="cx">                  define( 'WP_LOAD_IMPORTERS', true );
</span><del>-               
</del><ins>+
</ins><span class="cx">           add_filter( 'import_allow_create_users', '__return_true' );
</span><del>-               
</del><ins>+
</ins><span class="cx">           require_once dirname( dirname( __FILE__ ) ) .
</span><span class="cx">                           '/class-wp-importer-cron.php';
</span><span class="cx">          require_once dirname( dirname( __FILE__ ) ) .
</span><span class="cx">                           '/class-wordpress-importer.php';
</span><span class="cx">          require_once dirname( dirname( __FILE__ ) ) .
</span><span class="cx">                           '/class-wxr-parser.php';
</span><del>-               
</del><ins>+
</ins><span class="cx">           global $wpdb;
</span><span class="cx">          // crude but effective: make sure there's no residual data in the main
</span><span class="cx">          // tables
</span><span class="lines">@@ -47,7 +47,7 @@
</span><span class="cx"> 
</span><span class="cx">  function tearDown() {
</span><span class="cx">          remove_filter( 'import_allow_create_users', '__return_true' );
</span><del>-               
</del><ins>+
</ins><span class="cx">           parent::tearDown();
</span><span class="cx">  }
</span><span class="cx"> 
</span><span class="lines">@@ -56,17 +56,17 @@
</span><span class="cx">   */
</span><span class="cx">  public function test___construct() {
</span><span class="cx">          $instance = new WordPress_Importer();
</span><del>-                       
</del><ins>+
</ins><span class="cx">           // check for hooks
</span><del>-               $this->assertNotEquals( false, 
-                               has_filter( 'cron_schedules', 
</del><ins>+                $this->assertNotEquals( false,
+                               has_filter( 'cron_schedules',
</ins><span class="cx">                                           array(
</span><span class="cx">                                                          $instance,
</span><span class="cx">                                                          'importer_schedule'
</span><span class="cx">                                          ) ) );
</span><del>-               
-               $this->assertNotEquals( false, 
-                               has_action( 'wp_cron_importer_hook', 
</del><ins>+
+               $this->assertNotEquals( false,
+                               has_action( 'wp_cron_importer_hook',
</ins><span class="cx">                                           array(
</span><span class="cx">                                                          $instance,
</span><span class="cx">                                                          'importer_callback'
</span><span class="lines">@@ -76,30 +76,30 @@
</span><span class="cx">  public function test_save_vars() {
</span><span class="cx">          $instance = new WordPress_Importer();
</span><span class="cx">          $vars = $instance->save_vars();
</span><del>-               
</del><ins>+
</ins><span class="cx">           $this->assertTrue( $vars );
</span><del>-               $this->assertNotEmpty( 
</del><ins>+                $this->assertNotEmpty(
</ins><span class="cx">                           $options = get_option( get_class( $instance ) ) );
</span><span class="cx">  }
</span><span class="cx"> 
</span><span class="cx">  public function test_advance() {
</span><span class="cx">          $instance = new WordPress_Importer();
</span><del>-               
</del><ins>+
</ins><span class="cx">           // hack it into submission; nothing else will function without a
</span><span class="cx">          // properly defined wxr_file
</span><span class="cx">          self::set( $instance, 'wxr_file', 'test-nonexistent.xml' );
</span><del>-               
</del><ins>+
</ins><span class="cx">           // with no step defined
</span><span class="cx">          $this->assertEquals( 'start', $instance->advance() );
</span><del>-               
</del><ins>+
</ins><span class="cx">           // non-existent step
</span><span class="cx">          $this->assertWPError( $instance->advance( rand_str( 10 ) ) );
</span><del>-                       
</del><ins>+
</ins><span class="cx">           // if on a terms step, the next step is posts
</span><span class="cx">          $this->assertEquals( 'terms', $instance->advance( 'terms' ) );
</span><span class="cx">          $this->assertEquals( 'terms', $instance->get_step() );
</span><span class="cx">          $this->assertEquals( 'posts', $instance->advance() );
</span><del>-               
</del><ins>+
</ins><span class="cx">           // valid step
</span><span class="cx">          $this->assertEquals( 'finish', $instance->advance( 'finish' ) );
</span><span class="cx">  }
</span><span class="lines">@@ -107,14 +107,14 @@
</span><span class="cx">  public function test_get_error() {
</span><span class="cx">          // clean instance, no errors
</span><span class="cx">          $instance = new WordPress_Importer();
</span><del>-               
</del><ins>+
</ins><span class="cx">           $this->assertNull( $instance->get_error() );
</span><span class="cx">  }
</span><span class="cx"> 
</span><span class="cx">  public function test_get_warnings() {
</span><span class="cx">          // clean instance, no warnings
</span><span class="cx">          $instance = new WordPress_Importer();
</span><del>-               
</del><ins>+
</ins><span class="cx">           $this->assertInternalType( 'array', $instance->get_warnings() );
</span><span class="cx">          $this->assertEmpty( $instance->get_warnings() );
</span><span class="cx">  }
</span><span class="lines">@@ -123,17 +123,17 @@
</span><span class="cx">          // clean instance, no warnings
</span><span class="cx">          $instance = new WordPress_Importer();
</span><span class="cx">          $wxr_file = 'test-nonexistent.xml';
</span><del>-               
</del><ins>+
</ins><span class="cx">           // can't set without a WXR file defined
</span><span class="cx">          $this->assertWPError( $instance->set_param( 'name', 'value' ) );
</span><del>-               
</del><ins>+
</ins><span class="cx">           // hack it into submission; nothing else will function without a
</span><span class="cx">          // properly defined wxr_file
</span><span class="cx">          self::set( $instance, 'wxr_file', $wxr_file );
</span><del>-               
</del><ins>+
</ins><span class="cx">           $this->assertTrue( $instance->set_param( 'name', 'value' ) );
</span><span class="cx">          $this->assertEquals( 'value', $instance->get_param( 'name' ) );
</span><del>-               
</del><ins>+
</ins><span class="cx">           $this->assertCount( 1, $instance->get_all_params() );
</span><span class="cx">          $this->assertArrayHasKey( $wxr_file, $instance->get_all_params() );
</span><span class="cx">  }
</span><span class="lines">@@ -143,10 +143,10 @@
</span><span class="cx">   */
</span><span class="cx">  public function test_process_authors_standalone() {
</span><span class="cx">          $instance = new WordPress_Importer();
</span><del>-               
</del><ins>+
</ins><span class="cx">           $this->assertFalse( self::call( $instance, 'process_authors' ) );
</span><span class="cx">          $this->assertWPError( $instance->get_error() );
</span><del>-               
</del><ins>+
</ins><span class="cx">           return $instance;
</span><span class="cx">  }
</span><span class="cx"> 
</span><span class="lines">@@ -157,8 +157,8 @@
</span><span class="cx">   */
</span><span class="cx">  public function test_process_author_mappings_standalone() {
</span><span class="cx">          $instance = new WordPress_Importer();
</span><del>-               
-               $this->assertFalse( 
</del><ins>+
+               $this->assertFalse(
</ins><span class="cx">                           self::call( $instance, 'process_author_mappings' ) );
</span><span class="cx">          $this->assertWPError( $instance->get_error() );
</span><span class="cx"> 
</span><span class="lines">@@ -180,49 +180,49 @@
</span><span class="cx">                          $mapping[$_i] = $_map;
</span><span class="cx">                  elseif ( is_string( $_map ) )
</span><span class="cx">                          $new[$_i] = $_map;
</span><del>-                       
</del><ins>+
</ins><span class="cx">                   $_i ++;
</span><span class="cx">          }
</span><span class="cx">          unset( $_i );
</span><del>-               
</del><ins>+
</ins><span class="cx">           $instance = new WordPress_Importer();
</span><span class="cx">          // hack it into submission; nothing else will function without a
</span><span class="cx">          // properly defined wxr_file
</span><span class="cx">          self::set( $instance, 'wxr_file', 'test-nonexistent.xml' );
</span><del>-               $this->assertTrue( 
</del><ins>+                $this->assertTrue(
</ins><span class="cx">                           $instance->set_param( 'admin_user_id', $admin_user ) );
</span><span class="cx">          $this->assertTrue( $instance->is_allowed_user_creation() );
</span><del>-               
</del><ins>+
</ins><span class="cx">           // set the parameters necessary for the process to run
</span><del>-               $this->assertTrue( 
</del><ins>+                $this->assertTrue(
</ins><span class="cx">                           $instance->set_param( 'imported_authors', $authors ) );
</span><span class="cx">          $this->assertTrue( $instance->set_param( 'user_map', $mapping ) );
</span><span class="cx">          $this->assertTrue( $instance->set_param( 'user_new', $new ) );
</span><del>-               
</del><ins>+
</ins><span class="cx">           // running the mapping process should be successful, no error/warnings
</span><del>-               $this->assertTrue( 
</del><ins>+                $this->assertTrue(
</ins><span class="cx">                           self::call( $instance, 'process_author_mappings' ) );
</span><span class="cx">          $this->assertNull( $instance->get_error() );
</span><span class="cx">          $this->assertCount( 0, $instance->get_warnings() );
</span><del>-               
</del><ins>+
</ins><span class="cx">           // since this test case is run by itself without the benefit of
</span><span class="cx">          // a predecessor process_authors(), no author IDs will be "processed"
</span><span class="cx">          $this->assertCount( 0, self::get( $instance, 'processed_authors' ) );
</span><del>-               
</del><ins>+
</ins><span class="cx">           // however, mappings will exist for all provided users
</span><del>-               $this->assertCount( count( $users ), 
-                               $author_mappings = self::get( $instance, 
</del><ins>+                $this->assertCount( count( $users ),
+                               $author_mappings = self::get( $instance,
</ins><span class="cx">                                           'processed_author_mappings' ) );
</span><del>-               $this->assertEquals( array_keys( $users ), 
</del><ins>+                $this->assertEquals( array_keys( $users ),
</ins><span class="cx">                           array_keys( $author_mappings ) );
</span><span class="cx">          foreach ( $author_mappings as $username => $map ) {
</span><span class="cx">                  $_user = get_user_by( 'id', $map );
</span><span class="cx">                  $this->assertInstanceOf( 'WP_User', $_user );
</span><span class="cx">          }
</span><del>-               
</del><ins>+
</ins><span class="cx">           // ... and, if a mapping was set by user decision, it should match
</span><span class="cx">          $this->assertEquals( current( $mapping ), $author_mappings['alice'] );
</span><del>-               $this->assertEquals( get_user_by( 'login', $users['bob'] )->ID, 
</del><ins>+                $this->assertEquals( get_user_by( 'login', $users['bob'] )->ID,
</ins><span class="cx">                           $author_mappings['bob'] );
</span><span class="cx">  }
</span><span class="cx"> 
</span><span class="lines">@@ -237,29 +237,29 @@
</span><span class="cx">           * An empty posts array causes the process to advance
</span><span class="cx">           */
</span><span class="cx">          $instance = new WordPress_Importer();
</span><del>-               
</del><ins>+
</ins><span class="cx">           // hack it into submission; nothing else will function without a
</span><span class="cx">          // properly defined wxr_file
</span><span class="cx">          self::set( $instance, 'wxr_file', 'test-nonexistent.xml' );
</span><del>-               
</del><ins>+
</ins><span class="cx">           self::set( $instance, 'posts', array() );
</span><span class="cx">          $this->assertEquals( 'posts', $instance->advance( 'posts' ) );
</span><span class="cx">          $this->assertTrue( self::call( $instance, 'process_posts' ) );
</span><span class="cx">          $this->assertEmpty( $instance->get_error() );
</span><span class="cx">          $this->assertEmpty( $instance->get_warnings() );
</span><del>-               $this->assertEquals( 'backfill_parents', 
</del><ins>+                $this->assertEquals( 'parents',
</ins><span class="cx">                           current( self::get( $instance, 'progress' ) ) );
</span><del>-               
</del><ins>+
</ins><span class="cx">           /*
</span><span class="cx">           * START OVER to test a post with non-existent post type
</span><span class="cx">           */
</span><span class="cx">          $instance2 = new WordPress_Importer();
</span><del>-               
</del><ins>+
</ins><span class="cx">           // hack it into submission; nothing else will function without a
</span><span class="cx">          // properly defined wxr_file
</span><span class="cx">          self::set( $instance2, 'wxr_file', 'test-nonexistent.xml' );
</span><del>-               
-               self::set( $instance2, 'posts', 
</del><ins>+
+               self::set( $instance2, 'posts',
</ins><span class="cx">                           array(
</span><span class="cx">                                          array(
</span><span class="cx">                                                          'post_type' => rand_str( 12 )
</span><span class="lines">@@ -270,7 +270,7 @@
</span><span class="cx">          $this->assertEmpty( $instance2->get_error() );
</span><span class="cx">          $this->assertNotEmpty( $instance2->get_warnings() );
</span><span class="cx">          $this->assertWPError(current($instance2->get_warnings()));
</span><del>-               $this->assertEquals('import_process_posts_post_type_warning', 
</del><ins>+                $this->assertEquals('import_process_posts_post_type_warning',
</ins><span class="cx">                   current($instance2->get_warnings())->get_error_code());
</span><span class="cx"> 
</span><span class="cx">  }
</span><span class="lines">@@ -286,35 +286,35 @@
</span><span class="cx">   */
</span><span class="cx">  public function test_wxr_smallest() {
</span><span class="cx">          $instance = new WordPress_Importer();
</span><del>-               
-               // use the WordPress core test case
</del><ins>+
+               // use the WordPress core test case in valid-wxr-1.1.xml
</ins><span class="cx">           $authors = array(
</span><span class="cx">                          'john',
</span><span class="cx">          );
</span><span class="cx">          $wxr_file = DIR_TESTDATA . '/export/valid-wxr-1.1.xml';
</span><del>-               $this->assertNotInstanceOf( 'WP_Error', 
</del><ins>+                $this->assertNotInstanceOf( 'WP_Error',
</ins><span class="cx">                           $parse = $instance->do_parse( $wxr_file ) );
</span><del>-               
</del><ins>+
</ins><span class="cx">           // set the parameters necessary for the process to run
</span><span class="cx">          $this->assertTrue( $instance->set_param( 'imported_authors', $authors ) );
</span><span class="cx">          $this->assertTrue( $instance->set_param( 'user_new', $authors ) );
</span><span class="cx">          $this->assertEquals( 'start', $instance->advance( 'start' ) );
</span><span class="cx">          $this->assertTrue( $instance->is_allowed_user_creation() );
</span><del>-               
</del><ins>+
</ins><span class="cx">           // this import file has a custom taxonomy
</span><span class="cx">          register_taxonomy('post_tax', 'post');
</span><span class="cx">          $this->assertTrue(taxonomy_exists('post_tax'));
</span><del>-               
</del><ins>+
</ins><span class="cx">           // should be done in one cron run
</span><span class="cx">          $this->assertTrue( $instance->do_import() );
</span><span class="cx">          $this->assertNull( $instance->get_error() );
</span><del>-               
</del><ins>+
</ins><span class="cx">           $instance->do_cleanup();
</span><del>-               
</del><ins>+
</ins><span class="cx">           // check author was imported correctly
</span><span class="cx">          $user_count = count_users();
</span><span class="cx">          $this->assertEquals( 1, $user_count['total_users'] );
</span><del>-                       
</del><ins>+
</ins><span class="cx">           // check that terms were imported correctly
</span><span class="cx">          $this->assertEquals( 1, wp_count_terms( 'category' ) );
</span><span class="cx">          $this->assertEquals( 1, wp_count_terms( 'post_tag' ) );
</span><span class="lines">@@ -325,9 +325,9 @@
</span><span class="cx">          $this->assertEquals( 0, $clippable->parent );
</span><span class="cx">          $bieup = get_term_by( 'slug', 'bieup', 'post_tax' );
</span><span class="cx">          $this->assertEquals( 0, $bieup->parent );
</span><del>-               
</del><ins>+
</ins><span class="cx">           // check posts
</span><del>-               $posts = get_posts( 
</del><ins>+                $posts = get_posts(
</ins><span class="cx">                           array(
</span><span class="cx">                                          'numberposts' => 10,
</span><span class="cx">                                          'post_type' => 'any',
</span><span class="lines">@@ -335,9 +335,9 @@
</span><span class="cx">                                          'orderby' => 'ID'
</span><span class="cx">                          ) );
</span><span class="cx">          $this->assertCount( 2, $posts );
</span><del>-               
</del><ins>+
</ins><span class="cx">           $author = get_user_by( 'login', 'john' );
</span><del>-                       
</del><ins>+
</ins><span class="cx">           // check posts and pages
</span><span class="cx">          $post = $posts[0];
</span><span class="cx">          $this->assertEquals( 'About', $post->post_title );
</span><span class="lines">@@ -346,9 +346,9 @@
</span><span class="cx">          $this->assertEquals( 'page', $post->post_type );
</span><span class="cx">          $this->assertEquals( 'publish', $post->post_status );
</span><span class="cx">          $this->assertEquals( 0, $post->post_parent );
</span><del>-               $this->assertEquals( 'default', 
</del><ins>+                $this->assertEquals( 'default',
</ins><span class="cx">                           get_post_meta( $post->ID, '_wp_page_template', true ) );
</span><del>-               
</del><ins>+
</ins><span class="cx">           $post = $posts[1];
</span><span class="cx">          $this->assertEquals( 'Hello world!', $post->post_title );
</span><span class="cx">          $this->assertEquals( 'hello-world', $post->post_name );
</span><span class="lines">@@ -363,7 +363,7 @@
</span><span class="cx">          $this->assertEquals( 1, count($tags) );
</span><span class="cx">          $this->assertEquals( 'clippable', $tags[0]->slug );
</span><span class="cx">  }
</span><del>-       
</del><ins>+
</ins><span class="cx">   /**
</span><span class="cx">   * Standard test case of a WXR file, not utilizing cron scheduler.
</span><span class="cx">   *
</span><span class="lines">@@ -375,7 +375,7 @@
</span><span class="cx">   */
</span><span class="cx">  public function test_wxr_standard() {
</span><span class="cx">      $instance = new WordPress_Importer();
</span><del>-                       
</del><ins>+
</ins><span class="cx">                   // use the WordPress core test case
</span><span class="cx">          $authors = array(
</span><span class="cx">                          'admin',
</span><span class="lines">@@ -383,21 +383,21 @@
</span><span class="cx">                          'author'
</span><span class="cx">          );
</span><span class="cx">          $wxr_file = DIR_TESTDATA . '/export/small-export.xml';
</span><del>-               $this->assertNotInstanceOf( 'WP_Error', 
</del><ins>+                $this->assertNotInstanceOf( 'WP_Error',
</ins><span class="cx">                           $parse = $instance->do_parse( $wxr_file ) );
</span><del>-               
</del><ins>+
</ins><span class="cx">           // set the parameters necessary for the process to run
</span><del>-               $this->assertTrue( 
</del><ins>+                $this->assertTrue(
</ins><span class="cx">                           $instance->set_param( 'imported_authors', $authors ) );
</span><span class="cx">          $this->assertEquals( 'start', $instance->advance( 'start' ) );
</span><span class="cx">          $this->assertTrue( $instance->is_allowed_user_creation() );
</span><del>-               
</del><ins>+
</ins><span class="cx">           // should be done in one cron run
</span><span class="cx">          $this->assertTrue( $instance->do_import() );
</span><span class="cx">          $this->assertNull( $instance->get_error() );
</span><span class="cx">          $this->assertEmpty( $instance->get_warnings() );
</span><span class="cx">          $instance->do_cleanup();
</span><del>-               
</del><ins>+
</ins><span class="cx">           // ensure that authors were imported correctly
</span><span class="cx">          $user_count = count_users();
</span><span class="cx">          $this->assertEquals( 3, $user_count['total_users'] );
</span><span class="lines">@@ -412,7 +412,7 @@
</span><span class="cx">          $author = get_user_by( 'login', 'author' );
</span><span class="cx">          $this->assertEquals( 'author', $author->user_login );
</span><span class="cx">          $this->assertEquals( 'author@example.org', $author->user_email );
</span><del>-               
</del><ins>+
</ins><span class="cx">           // check that terms were imported correctly
</span><span class="cx">          $this->assertEquals( 30, wp_count_terms( 'category' ) );
</span><span class="cx">          $this->assertEquals( 3, wp_count_terms( 'post_tag' ) );
</span><span class="lines">@@ -421,7 +421,7 @@
</span><span class="cx">          $bar = get_term_by( 'slug', 'bar', 'category' );
</span><span class="cx">          $foo_bar = get_term_by( 'slug', 'foo-bar', 'category' );
</span><span class="cx">          $this->assertEquals( $bar->term_id, $foo_bar->parent );
</span><del>-               
</del><ins>+
</ins><span class="cx">           // check that posts/pages were imported correctly
</span><span class="cx">          $post_count = wp_count_posts( 'post' );
</span><span class="cx">          $this->assertEquals( 5, $post_count->publish );
</span><span class="lines">@@ -431,8 +431,8 @@
</span><span class="cx">          $this->assertEquals( 1, $page_count->draft );
</span><span class="cx">          $comment_count = wp_count_comments();
</span><span class="cx">          $this->assertEquals( 1, $comment_count->total_comments );
</span><del>-               
-               $posts = get_posts( 
</del><ins>+
+               $posts = get_posts(
</ins><span class="cx">                           array(
</span><span class="cx">                                          'numberposts' => 20,
</span><span class="cx">                                          'post_type' => 'any',
</span><span class="lines">@@ -440,7 +440,7 @@
</span><span class="cx">                                          'orderby' => 'ID'
</span><span class="cx">                          ) );
</span><span class="cx">          $this->assertEquals( 11, count( $posts ) );
</span><del>-               
</del><ins>+
</ins><span class="cx">           $post = $posts[0];
</span><span class="cx">          $this->assertEquals( 'Many Categories', $post->post_title );
</span><span class="cx">          $this->assertEquals( 'many-categories', $post->post_name );
</span><span class="lines">@@ -450,7 +450,7 @@
</span><span class="cx">          $this->assertEquals( 0, $post->post_parent );
</span><span class="cx">          $cats = wp_get_post_categories( $post->ID );
</span><span class="cx">          $this->assertEquals( 27, count( $cats ) );
</span><del>-               
</del><ins>+
</ins><span class="cx">           $post = $posts[1];
</span><span class="cx">          $this->assertEquals( 'Non-standard post format', $post->post_title );
</span><span class="cx">          $this->assertEquals( 'non-standard-post-format', $post->post_name );
</span><span class="lines">@@ -461,7 +461,7 @@
</span><span class="cx">          $cats = wp_get_post_categories( $post->ID );
</span><span class="cx">          $this->assertEquals( 1, count( $cats ) );
</span><span class="cx">          $this->assertTrue( has_post_format( 'aside', $post->ID ) );
</span><del>-               
</del><ins>+
</ins><span class="cx">           $post = $posts[2];
</span><span class="cx">          $this->assertEquals( 'Top-level Foo', $post->post_title );
</span><span class="cx">          $this->assertEquals( 'top-level-foo', $post->post_name );
</span><span class="lines">@@ -469,13 +469,13 @@
</span><span class="cx">          $this->assertEquals( 'post', $post->post_type );
</span><span class="cx">          $this->assertEquals( 'publish', $post->post_status );
</span><span class="cx">          $this->assertEquals( 0, $post->post_parent );
</span><del>-               $cats = wp_get_post_categories( $post->ID, 
</del><ins>+                $cats = wp_get_post_categories( $post->ID,
</ins><span class="cx">                           array(
</span><span class="cx">                                          'fields' => 'all'
</span><span class="cx">                          ) );
</span><span class="cx">          $this->assertEquals( 1, count( $cats ) );
</span><span class="cx">          $this->assertEquals( 'foo', $cats[0]->slug );
</span><del>-               
</del><ins>+
</ins><span class="cx">           $post = $posts[3];
</span><span class="cx">          $this->assertEquals( 'Foo-child', $post->post_title );
</span><span class="cx">          $this->assertEquals( 'foo-child', $post->post_name );
</span><span class="lines">@@ -483,13 +483,13 @@
</span><span class="cx">          $this->assertEquals( 'post', $post->post_type );
</span><span class="cx">          $this->assertEquals( 'publish', $post->post_status );
</span><span class="cx">          $this->assertEquals( 0, $post->post_parent );
</span><del>-               $cats = wp_get_post_categories( $post->ID, 
</del><ins>+                $cats = wp_get_post_categories( $post->ID,
</ins><span class="cx">                           array(
</span><span class="cx">                                          'fields' => 'all'
</span><span class="cx">                          ) );
</span><span class="cx">          $this->assertEquals( 1, count( $cats ) );
</span><span class="cx">          $this->assertEquals( 'foo-bar', $cats[0]->slug );
</span><del>-               
</del><ins>+
</ins><span class="cx">           $post = $posts[4];
</span><span class="cx">          $this->assertEquals( 'Private Post', $post->post_title );
</span><span class="cx">          $this->assertEquals( 'private-post', $post->post_name );
</span><span class="lines">@@ -504,7 +504,7 @@
</span><span class="cx">          $this->assertEquals( 'tag1', $tags[0]->slug );
</span><span class="cx">          $this->assertEquals( 'tag2', $tags[1]->slug );
</span><span class="cx">          $this->assertEquals( 'tag3', $tags[2]->slug );
</span><del>-               
</del><ins>+
</ins><span class="cx">           $post = $posts[5];
</span><span class="cx">          $this->assertEquals( '1-col page', $post->post_title );
</span><span class="cx">          $this->assertEquals( '1-col-page', $post->post_name );
</span><span class="lines">@@ -512,9 +512,9 @@
</span><span class="cx">          $this->assertEquals( 'page', $post->post_type );
</span><span class="cx">          $this->assertEquals( 'publish', $post->post_status );
</span><span class="cx">          $this->assertEquals( 0, $post->post_parent );
</span><del>-               $this->assertEquals( 'onecolumn-page.php', 
</del><ins>+                $this->assertEquals( 'onecolumn-page.php',
</ins><span class="cx">                           get_post_meta( $post->ID, '_wp_page_template', true ) );
</span><del>-               
</del><ins>+
</ins><span class="cx">           $post = $posts[6];
</span><span class="cx">          $this->assertEquals( 'Draft Page', $post->post_title );
</span><span class="cx">          $this->assertEquals( '', $post->post_name );
</span><span class="lines">@@ -522,9 +522,9 @@
</span><span class="cx">          $this->assertEquals( 'page', $post->post_type );
</span><span class="cx">          $this->assertEquals( 'draft', $post->post_status );
</span><span class="cx">          $this->assertEquals( 0, $post->post_parent );
</span><del>-               $this->assertEquals( 'default', 
</del><ins>+                $this->assertEquals( 'default',
</ins><span class="cx">                           get_post_meta( $post->ID, '_wp_page_template', true ) );
</span><del>-               
</del><ins>+
</ins><span class="cx">           $post = $posts[7];
</span><span class="cx">          $this->assertEquals( 'Parent Page', $post->post_title );
</span><span class="cx">          $this->assertEquals( 'parent-page', $post->post_name );
</span><span class="lines">@@ -532,9 +532,9 @@
</span><span class="cx">          $this->assertEquals( 'page', $post->post_type );
</span><span class="cx">          $this->assertEquals( 'publish', $post->post_status );
</span><span class="cx">          $this->assertEquals( 0, $post->post_parent );
</span><del>-               $this->assertEquals( 'default', 
</del><ins>+                $this->assertEquals( 'default',
</ins><span class="cx">                           get_post_meta( $post->ID, '_wp_page_template', true ) );
</span><del>-               
</del><ins>+
</ins><span class="cx">           $post = $posts[8];
</span><span class="cx">          $this->assertEquals( 'Child Page', $post->post_title );
</span><span class="cx">          $this->assertEquals( 'child-page', $post->post_name );
</span><span class="lines">@@ -542,9 +542,9 @@
</span><span class="cx">          $this->assertEquals( 'page', $post->post_type );
</span><span class="cx">          $this->assertEquals( 'publish', $post->post_status );
</span><span class="cx">          $this->assertEquals( $posts[7]->ID, $post->post_parent );
</span><del>-               $this->assertEquals( 'default', 
</del><ins>+                $this->assertEquals( 'default',
</ins><span class="cx">                           get_post_meta( $post->ID, '_wp_page_template', true ) );
</span><del>-               
</del><ins>+
</ins><span class="cx">           $post = $posts[9];
</span><span class="cx">          $this->assertEquals( 'Sample Page', $post->post_title );
</span><span class="cx">          $this->assertEquals( 'sample-page', $post->post_name );
</span><span class="lines">@@ -552,9 +552,9 @@
</span><span class="cx">          $this->assertEquals( 'page', $post->post_type );
</span><span class="cx">          $this->assertEquals( 'publish', $post->post_status );
</span><span class="cx">          $this->assertEquals( 0, $post->post_parent );
</span><del>-               $this->assertEquals( 'default', 
</del><ins>+                $this->assertEquals( 'default',
</ins><span class="cx">                           get_post_meta( $post->ID, '_wp_page_template', true ) );
</span><del>-               
</del><ins>+
</ins><span class="cx">           $post = $posts[10];
</span><span class="cx">          $this->assertEquals( 'Hello world!', $post->post_title );
</span><span class="cx">          $this->assertEquals( 'hello-world', $post->post_name );
</span><span class="lines">@@ -572,8 +572,8 @@
</span><span class="cx">   * Although typically this wouldn't be used, the importer being tested uses
</span><span class="cx">   * a number of steps in protected methods.
</span><span class="cx">   *
</span><del>-        * @param object $object                
-        * @param string $name          
</del><ins>+         * @param object $object
+        * @param string $name
</ins><span class="cx">    * @param array $args
</span><span class="cx">   *              optional
</span><span class="cx">   */
</span><span class="lines">@@ -587,9 +587,9 @@
</span><span class="cx">  /**
</span><span class="cx">   * Uses Reflection to set otherwise inaccessible properties.
</span><span class="cx">   *
</span><del>-        * @param object $object                
-        * @param string $name          
-        * @param mixed $value          
</del><ins>+         * @param object $object
+        * @param string $name
+        * @param mixed $value
</ins><span class="cx">    */
</span><span class="cx">  protected static function set( $object, $name, $value ) {
</span><span class="cx">          $class = new \ReflectionClass( $object );
</span><span class="lines">@@ -601,8 +601,8 @@
</span><span class="cx">  /**
</span><span class="cx">   * Uses Reflection to get otherwise inaccessible properties.
</span><span class="cx">   *
</span><del>-        * @param object $object                
-        * @param string $name          
</del><ins>+         * @param object $object
+        * @param string $name
</ins><span class="cx">    * @throws \ReflectionException
</span><span class="cx">   */
</span><span class="cx">  protected static function get( $object, $name ) {
</span></span></pre>
</div>
</div>

</body>
</html>