WordPress / WordPress/wordpress-importer

Improvement - import in batches using AJAX or background job?

Open
#64 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

[Type] Enhancement
Dominant language
PHP
Stars
89
Forks
96
Avg merge
1h 13m
Merged PRs (30d)
2

Description

When doing larger imports it often happens that the import script breaks/time outs.

One possible solution is to increase timeout in the php.ini, but not all users have this ability (especially those on shared hostings).

One solution would be to import items in batches using ajax - this will make the script less prone to timeouts.

Another solution would be to register and immediately execute running a background job using wp_schedule_single_event()

wp_schedule_single_event( time() - 1, 'wp_import_all_things' );

This should start the import job in the background, as a separate process, so, in theory, it would also be less prone to errors and timeouts.

However we would need some indication if the job is running, has run successfully or if it has errored out for some reason.

Any thoughts?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the existing import flow and reviewing the proposed wp_schedule_single_event() call for wp_import_all_things. Compare the batch/AJAX and background-job approaches, then define how running, successful, and failed imports would be reported. Done means large imports avoid request timeouts and expose their outcome.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.