Skip to content

Conversation

adamziel
Copy link
Collaborator

@adamziel adamziel commented Nov 18, 2024

Motivation for the change, related issues

A rough mockup of a wp-admin page for data liberation imports:

CleanShot 2024-11-18 at 19 23 52@2x

It actually allows you to import a WXR file, but almost nothing else works. This PR is only meant to provide a starting point to expand.

Testing Instructions (or ideally a Blueprint)

  • Run Playground with the data-liberation plugin installed:
cd packages/playground/data-liberation/tests/import
bash run.sh

cc @brandonpayton @zaerl

@adamziel adamziel merged commit 1d18f36 into trunk Nov 18, 2024
6 checks passed
@adamziel adamziel deleted the wp-admin-import-screen branch November 18, 2024 18:31
@adamziel
Copy link
Collaborator Author

I'll go ahead and merge so we can start expanding that UI


public function current(): object {
if ( null === $this->entity_data && ! $this->is_finished() && ! $this->get_last_error() ) {
$this->next();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@adamziel What is the purpose of calling next() within current()?

From the outside, I would expect current() to have no side-effects. It seems like it could also lead to consumers unintentionally skipping a first entity if current() happens to be called before the consumers' first explicit next() call.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's for lazy initializing the iterator. Foreach() calls next() after every iteration but not before. We can either eagerly initialize the iterator in the constructor or in the first current() call. An inline comment to document that could be useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants