Commit 6ebd956
authored
[Data Liberation] "Fetch from a different URL" button for failed media downloads, Interactivity API support (#2040)
## Description
Ships user-driven import error handling and makes the import UI more
useful by automatically refreshing the progress details.
### User-driven error handling
When a remote asset cannot be downloaded, most importers either stop or
ignore the error. This PR adds a user interaction to make an explicit
decision about what should happen next – do we ignore the missing asset?
Do we use another file instead?
https://github.com/user-attachments/assets/cea48258-b644-434c-9fb2-1b890c4d86d7
### Auto-Refreshing Import Status
This PR also re-expresses the entire data liberation wp-admin page using
the interactivity API, and auto-refreshes the progress:
https://github.com/user-attachments/assets/e093268b-5deb-4bc2-a1d2-e2bb1148e153
A part of #1894
## Technical overview
### User-driven error handling
During the frontloading stage, the `WP_Stream_Importer` exposes all the
frontloaded entities to the API consumer. The consumer then creates a
post of type `frontloading_placeholder` with an initial status
`awaiting_download` for each asset, and updates it with progress
information and status (success, failure, skipped) as the import
progresses.
The frontloading stage is not finished until all the frontloaded assets
have been processed with a non-error outcome. There's a few ways to
recover from errors:
* Retry the download – `WP_Stream_Importer` now retries the failed
assets URL (via `WP_Retry_Frontloading_Iterator`) before moving on to
entities provided by the usual entity source such as a WXR file.
* Changing the downloaded URL – done by the user on the wp-admin page
* Choosing to skip the download – done by the user on the wp-admin page
Sometimes we don't want to require user interactions, e.g. when running
the `importWxr` Blueprint step. In those scenarios, we could choose a
default error outcome, e.g. "skip failed downloads".
### Auto-refreshing admin page
Two `fetch()` requests running in an infinite loop are:
* Updating the JavaScript interactivity store with the latest import
state from the server
* Running the next import step
### Other changes
* Adds `php_userstreamop_read` to the Asyncify list – it crashed the
importer in `@wp-playground/cli` running in bun.
## Follow-up work
* Pretty UI transitions. Right now it's all sudden and jerky. We need
progress bars, smooth animations, clear visual causality.
* Prevent running the same import in two concurrent requests. This is a
serial importer not designed for parallelization.
* Run each import step in a transaction – either it all worked and we
can commit the changes and an updated cursor, or it didn't work and we
roll back the last step. Ideally we'll never see a scenario where an
entity was processed, but a crash happened before storing the updated
cursor and the next run reprocesses the same entity.
## Testing instructions
* Go to the data liberation admin page
* Upload a WXR export file
* Confirm the import processes automatically and doesn't error out1 parent 955be03 commit 6ebd956
File tree
20 files changed
+1772
-765
lines changed- packages
- docs/site/docs/main
- php-wasm
- compile/php
- node/asyncify
- 8_3_0
- playground/data-liberation
- src
- import
- wxr
- tests/wxr
20 files changed
+1772
-765
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | 15 | | |
17 | 16 | | |
18 | | - | |
| 17 | + | |
19 | 18 | | |
20 | 19 | | |
21 | 20 | | |
22 | | - | |
| 21 | + | |
23 | 22 | | |
24 | 23 | | |
25 | 24 | | |
26 | | - | |
| 25 | + | |
27 | 26 | | |
28 | 27 | | |
29 | 28 | | |
30 | | - | |
| 29 | + | |
31 | 30 | | |
32 | 31 | | |
33 | 32 | | |
34 | 33 | | |
35 | 34 | | |
36 | 35 | | |
37 | 36 | | |
38 | | - | |
39 | 37 | | |
40 | 38 | | |
41 | 39 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
21 | 20 | | |
22 | 21 | | |
23 | | - | |
| 22 | + | |
24 | 23 | | |
25 | 24 | | |
26 | 25 | | |
27 | | - | |
| 26 | + | |
28 | 27 | | |
29 | 28 | | |
30 | 29 | | |
31 | | - | |
| 30 | + | |
32 | 31 | | |
33 | 32 | | |
34 | 33 | | |
35 | | - | |
| 34 | + | |
36 | 35 | | |
37 | 36 | | |
38 | 37 | | |
39 | 38 | | |
40 | 39 | | |
41 | 40 | | |
42 | 41 | | |
43 | | - | |
44 | 42 | | |
45 | 43 | | |
46 | 44 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
569 | 569 | | |
570 | 570 | | |
571 | 571 | | |
| 572 | + | |
572 | 573 | | |
573 | 574 | | |
574 | 575 | | |
| |||
Binary file not shown.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
36 | 36 | | |
37 | | - | |
38 | | - | |
| 37 | + | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| 59 | + | |
| 60 | + | |
59 | 61 | | |
60 | 62 | | |
61 | 63 | | |
| |||
65 | 67 | | |
66 | 68 | | |
67 | 69 | | |
68 | | - | |
69 | | - | |
70 | | - | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
71 | 73 | | |
72 | 74 | | |
73 | 75 | | |
74 | 76 | | |
75 | | - | |
| 77 | + | |
76 | 78 | | |
77 | | - | |
| 79 | + | |
78 | 80 | | |
79 | 81 | | |
80 | 82 | | |
81 | | - | |
82 | | - | |
| 83 | + | |
| 84 | + | |
83 | 85 | | |
84 | 86 | | |
85 | 87 | | |
86 | 88 | | |
87 | | - | |
88 | | - | |
89 | | - | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
90 | 92 | | |
91 | 93 | | |
92 | 94 | | |
93 | | - | |
94 | | - | |
95 | | - | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
96 | 98 | | |
97 | 99 | | |
98 | 100 | | |
99 | | - | |
100 | | - | |
101 | | - | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
102 | 104 | | |
103 | 105 | | |
104 | 106 | | |
105 | | - | |
| 107 | + | |
106 | 108 | | |
107 | 109 | | |
108 | 110 | | |
109 | 111 | | |
110 | 112 | | |
111 | | - | |
| 113 | + | |
112 | 114 | | |
113 | 115 | | |
114 | 116 | | |
| |||
140 | 142 | | |
141 | 143 | | |
142 | 144 | | |
143 | | - | |
| 145 | + | |
144 | 146 | | |
145 | 147 | | |
146 | 148 | | |
| |||
0 commit comments