<!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>[2156] 2013/frederickding/importer/trunk: Reorganized class properties for organization.</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/2156">2156</a></dd>
<dt>Author</dt> <dd>frederick.ding</dd>
<dt>Date</dt> <dd>2013-07-26 21:36:02 +0000 (Fri, 26 Jul 2013)</dd>
</dl>

<h3>Log Message</h3>
<pre>Reorganized class properties for organization.

- until XML parsing is changed, we still need to store properties for authors,
  categories, tags, and terms that are in options; refer to <a href="http://gsoc.trac.wordpress.org/ticket/327">#327</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#2013frederickdingimportertrunkclasswordpressimporterphp">2013/frederickding/importer/trunk/class-wordpress-importer.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 (2155 => 2156)</h4>
<pre class="diff"><span>
<span class="info">--- 2013/frederickding/importer/trunk/class-wordpress-importer.php   2013-07-25 18:16:13 UTC (rev 2155)
+++ 2013/frederickding/importer/trunk/class-wordpress-importer.php      2013-07-26 21:36:02 UTC (rev 2156)
</span><span class="lines">@@ -57,14 +57,69 @@
</span><span class="cx">   * @var string
</span><span class="cx">   */
</span><span class="cx">  protected $wxr_file;
</span><ins>+
+       /**
+        * The raw parsed data from the WXR file.
+        *
+        * @var array
+        */
+       protected $_wxr_data = array();
</ins><span class="cx">   
</span><ins>+       /*
+        * SECTION: parsed data from import file
+        */
+       
+       /**
+        * 
+        * @see process_authors()
+        * @var array
+        */
</ins><span class="cx">   protected $authors = array();
</span><span class="cx">  
</span><ins>+       /**
+        *
+        * @see process_categories()
+        * @var array
+        */
+       protected $categories = array();
+       
+       /**
+        * 
+        * @see process_tags()
+        * @var array
+        */
+       protected $tags = array();
+       
+       /**
+        * 
+        * @see process_terms()
+        * @var array
+        */
+       protected $terms = array();
+       
+       /*
+        * SECTION: mappings from old information to new
+        */
+       
+       /**
+        * 
+        * @see process_author_mappings()
+        * @var array
+        */
</ins><span class="cx">   protected $processed_authors = array();
</span><span class="cx">  
</span><del>-       protected $author_mappings = array();
</del><ins>+        /**
+        *
+        * @see process_author_mappings()
+        * @var array
+        */
+       protected $processed_author_mappings = array();
</ins><span class="cx">   
</span><del>-       protected $_data = array();
</del><ins>+        /**
+        * 
+        * @var array
+        */
+       protected $processed_terms = array();
</ins><span class="cx">   
</span><span class="cx">  /**
</span><span class="cx">   * Stores user-submitted choices on how to proceed with the process.
</span><span class="lines">@@ -111,7 +166,12 @@
</span><span class="cx">          
</span><span class="cx">          $this->version = $version;
</span><span class="cx">          $this->wxr_file = $file;
</span><del>-               $this->_data = $data;
</del><ins>+                $this->categories = $data['categories'];
+               $this->tags = $data['tags'];
+               $this->terms = $data['terms'];
+               $this->posts = $data['posts'];
+               
+               $this->_wxr_data = $data;
</ins><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><span class="lines">@@ -256,15 +316,15 @@
</span><span class="cx">   */
</span><span class="cx">  protected function process_authors() {
</span><span class="cx">          // check for availability of data
</span><del>-               if ( empty( $this->wxr_file ) || empty( $this->_data ) ) {
</del><ins>+                if ( empty( $this->wxr_file ) || empty( $this->_wxr_data ) ) {
</ins><span class="cx">                   $this->error = new WP_Error( 'import_process_wxr_error', 
</span><span class="cx">                                  __( 'No parsed data available for processing', 
</span><span class="cx">                                                  'wordpress-importer' ) );
</span><span class="cx">                  return false;
</span><span class="cx">          }
</span><span class="cx">          
</span><del>-               if ( ! empty( $this->_data['authors'] ) ) {
-                       $this->authors = $this->_data['authors'];
</del><ins>+                if ( ! empty( $this->_wxr_data['authors'] ) ) {
+                       $this->authors = $this->_wxr_data['authors'];
</ins><span class="cx">           } else {
</span><span class="cx">                  // no author information, grab it from the posts
</span><span class="cx">                  foreach ( $this->_['posts'] as $post ) {
</span><span class="lines">@@ -293,7 +353,7 @@
</span><span class="cx">  }
</span><span class="cx"> 
</span><span class="cx">  /**
</span><del>-        * Map old author logins to local user IDs based on decisions.
</del><ins>+         * Maps old author logins to local user IDs based on decisions.
</ins><span class="cx">    *
</span><span class="cx">   * Can map to an existing user, create a new user, or falls back to the
</span><span class="cx">   * current user in case of an error with the other cases.
</span><span class="lines">@@ -330,7 +390,7 @@
</span><span class="cx">                          if ( isset( $user->ID ) ) {
</span><span class="cx">                                  if ( $old_id )
</span><span class="cx">                                          $this->processed_authors[$old_id] = $user->ID;
</span><del>-                                       $this->author_mappings[$sanitized_old_login] = $user->ID;
</del><ins>+                                        $this->processed_author_mappings[$sanitized_old_login] = $user->ID;
</ins><span class="cx">                           }
</span><span class="cx">                  } elseif ( $create_users ) {
</span><span class="cx">                          // make a user for an unmapped author only if allowed
</span><span class="lines">@@ -357,7 +417,7 @@
</span><span class="cx">                                  // successful user creation; add to mappings
</span><span class="cx">                                  if ( $old_id )
</span><span class="cx">                                          $this->processed_authors[$old_id] = $user_id;
</span><del>-                                       $this->author_mappings[$sanitized_old_login] = $user_id;
</del><ins>+                                        $this->processed_author_mappings[$sanitized_old_login] = $user_id;
</ins><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><span class="lines">@@ -382,11 +442,11 @@
</span><span class="cx">                   * scope by calling $importer->set_param('admin_user_id', $a_value)
</span><span class="cx">                   * after do_parse().
</span><span class="cx">                   */
</span><del>-                       if ( ! isset( $this->author_mappings[$sanitized_old_login] ) ) {
</del><ins>+                        if ( ! isset( $this->processed_author_mappings[$sanitized_old_login] ) ) {
</ins><span class="cx">                           if ( $old_id )
</span><span class="cx">                                  $this->processed_authors[$old_id] = (int) $this->get_param( 
</span><span class="cx">                                                  'admin_user_id', 0 );
</span><del>-                               $this->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><span class="lines">@@ -396,7 +456,7 @@
</span><span class="cx">           * emit a warning if the number of mapped authors is fewer than the 
</span><span class="cx">           * number of authors identified from the import data.
</span><span class="cx">           */
</span><del>-               if ( count( $this->author_mappings ) < count( $this->authors ) ) {
</del><ins>+                if ( count( $this->processed_author_mappings ) < count( $this->authors ) ) {
</ins><span class="cx">                   $this->warnings[] = new WP_Error( 
</span><span class="cx">                                  'import_process_author_mappings_warning', 
</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 (2155 => 2156)</h4>
<pre class="diff"><span>
<span class="info">--- 2013/frederickding/importer/trunk/tests/test-class-wordpress-importer.php        2013-07-25 18:16:13 UTC (rev 2155)
+++ 2013/frederickding/importer/trunk/tests/test-class-wordpress-importer.php   2013-07-26 21:36:02 UTC (rev 2156)
</span><span class="lines">@@ -200,7 +200,8 @@
</span><span class="cx">          
</span><span class="cx">          // however, mappings will exist for all provided users
</span><span class="cx">          $this->assertCount( count( $users ), 
</span><del>-                               $author_mappings = self::get( $instance, 'author_mappings' ) );
</del><ins>+                                $author_mappings = self::get( $instance, 
+                                               'processed_author_mappings' ) );
</ins><span class="cx">           $this->assertEquals( array_keys( $users ), 
</span><span class="cx">                          array_keys( $author_mappings ) );
</span><span class="cx">          foreach ( $author_mappings as $username => $map ) {
</span></span></pre>
</div>
</div>

</body>
</html>