WordPress.org

WordPRess GSoC Trac

Opened 9 months ago

Closed 9 months ago

Last modified 8 months ago

#327 closed enhancement (fixed)

Convert current WP_Import tasks for statefulness

Reported by: frederick.ding Owned by:
Milestone: 2013 Midterm (Beta) Priority: normal
Component: Migration & Portability Keywords: needs-unit-tests
Cc: john@…

Change History (25)

comment:1 frederick.ding9 months ago

In 2124:

Add PHPDoc to explain more thoroughly all WP_Importer_Cron methods.

See #327

comment:2 frederick.ding9 months ago

In 2132:

Start separating importer tasks to a subclass of WP_Importer_Cron; see #327

  • Much is still TODO
  • Method visibility defined as protected for process tasks
  • Omitting anything that produces output directly; see #331

comment:3 frederick.ding9 months ago

In 2134:

Add parsing action to WordPress_Importer cron class; see #327

  • Whitespace/formatting changes

comment:4 frederick.ding9 months ago

In 2135:

Separate reading authors from WXR data from mapping users; see #327.

  • Also add an advance() method for going to another step

comment:5 frederick.ding9 months ago

In 2137:

Add author mapping process step.

  • Modified to use internal class variable $params (with getters/setters) to eliminate dependence on $_POST, which wouldn't be usable from a cron job
  • See #327

comment:6 frederick.ding9 months ago

In 2157:

Port category processing to cron; see #327 and #331

  • Directly outputted messages now in WP_Error objects as warnings

comment:7 frederick.ding9 months ago

In 2158:

Add tag processing; see #327, #331

comment:8 frederick.ding9 months ago

In 2159:

Add term processing; see #327, #331

comment:9 frederick.ding9 months ago

In 2163:

Prevent caching upon construction of importer class; see #327

comment:10 frederick.ding9 months ago

In 2164:

Add post process step.

  • Attachment fetching temporarily unimplemented.
  • See #327

comment:11 frederick.ding9 months ago

In 2166:

Remove distinct attachments step; see #327.

comment:12 frederick.ding9 months ago

In 2167:

Change step handling to fix bugs; see #327

  • Fixed elseif bug with advancing steps
  • Changed each process step to advance to the next one if it has nothing to do
  • Added get_step()

comment:13 frederick.ding9 months ago

In 2168:

Add attachment processing (verbatim) and use a stateful iterator for posts.

  • Currently using ArrayIterator that is stored between cron runs
  • At the end of each foreach iteration in process_posts(), break if we're out of time; see #327

comment:14 frederick.ding9 months ago

In 2172:

Ported process_menu_item() and fetch_remote_file() from non-cron importer.

  • Includes a few changes to use the $this->warnings queue
  • See #327

comment:15 frederick.ding9 months ago

In 2173:

Add backfill_parents step. See #327.

  • Switched to using wp_update_post() instead of a direct $wpdb query

comment:16 frederick.ding9 months ago

In 2175:

General cleanup of inline documentation and whitespace; see #327, #331.

  • Also fixed process_attachment() to use true base_url param and to check is_allowed_attachment_fetch().
  • Exposed fetch_remote_file() to public visibility.

comment:17 frederick.ding9 months ago

In 2176:

Add URL backfill and featured images remapping; see #327.

  • URL backfill step will honour cron $this->have_time(); as of right now, only process_posts() and process_urls() check for time left

comment:18 frederick.ding9 months ago

  • Resolution set to fixed
  • Status changed from new to closed

Closing; revisions above have completed this ticket.

Further UI work will be tracked in #340.

comment:19 frederick.ding9 months ago

In 2177:

Big change: removing all previously-ported processes from the plugin class.

  • See #327, #340
  • Some cleanup actions are also removed from the cron class while some setup actions are added.

comment:20 frederick.ding9 months ago

In 2182:

Fix an uncaught typo from [2172]. See #327.

comment:21 frederick.ding9 months ago

In 2183:

Add abort button (see #340) and fix iterator state (see #327).

  • Store counter and seek instead of trying to store iterator

comment:22 JohnC289 months ago

Hi Frederick

Two things:

Any chance you could modify line 1588 of class-wordpress-importer.php to this:

if ( ! isset( $this->params[$this->wxr_file] ) || ! is_array( $this->params[$this->wxr_file] ) )

It would stop an annoying "Undefined index" notice appearing with debug output on.

Also, what change of adding a filter similar to 'import_allow_create_users' for menu items?

I have a special case where I don't ever want to import menus. Currently I'm extending your class to override the process_menu_item method just to return 0. But a filter at the start of that method (and, really, all the other entity methods: comments, taxonomies etc) would make it easy to prevent import of unwanted items.

Thanks

John

Last edited 9 months ago by JohnC28 (previous) (diff)

comment:23 frederick.ding9 months ago

Hey John; just changed line 1588 to change is_array to isset. I noticed the same thing earlier today when running on a site with XDebug enabled.

There's another notice with the use of $_POST['abort'] around line 401 that I just fixed.

See [2204].

Would you mind adding a new ticket for the menu item filter?

Last edited 9 months ago by frederick.ding (previous) (diff)

comment:24 JohnC288 months ago

Thanks Frederick.

Ticket added #349, along with a suggestion for implementation.

comment:25 JohnC288 months ago

  • Cc john@… added
Note: See TracTickets for help on using tickets.