Open dd32 opened 6 months ago
Tested and received the following error, using wp-now
(same on playground.wordpress.net)
Uncaught Error: Call to undefined function wp_generate_attachment_metadata()
mode: playground
php: 8.0
wp: latest
WordPress latest folder already exists. Skipping download.
SQLite folder already exists. Skipping download.
blueprint steps: 2
Blueprint step completed: login
Blueprint step completed: installPlugin
PHP.run() output was: {
stdout: '<br />\n' +
'<b>Fatal error</b>: Uncaught Error: Call to undefined function wp_generate_attachment_metadata() in /var/www/html/wp-content/plugins/WordPress-Importer-master/class-wxr-importer.php:1067\n' +
'Stack trace:\n' +
"#0 /var/www/html/wp-content/plugins/WordPress-Importer-master/class-wxr-importer.php(861): **WXR_Importer->process_attachment**(Array, Array, 'https://i0.wp.c...')\n" +
'#1 /var/www/html/wp-content/plugins/WordPress-Importer-master/class-wxr-importer.php(383): **WXR_Importer->process_post**(Array, Array, Array, Array)\n' +
"#2 php-wasm run script(17): WXR_Importer->import('/tmp/import.wxr')\n" +
'#3 {main}\n' +
' thrown in <b>/var/www/html/wp-content/plugins/WordPress-Importer-master/class-wxr-importer.php</b> on line <b>1067</b><br />\n',
stderr: 'PHP Fatal error: Uncaught Error: Call to undefined function wp_generate_attachment_metadata() in /var/www/html/wp-content/plugins/WordPress-Importer-master/class-wxr-importer.php:1067\n' +
'Stack trace:\n' +
"#0 /var/www/html/wp-content/plugins/WordPress-Importer-master/class-wxr-importer.php(861): WXR_Importer->process_attachment(Array, Array, 'https://i0.wp.c...')\n" +
'#1 /var/www/html/wp-content/plugins/WordPress-Importer-master/class-wxr-importer.php(383): WXR_Importer->process_post(Array, Array, Array, Array)\n' +
"#2 php-wasm run script(17): WXR_Importer->import('/tmp/import.wxr')\n" +
'#3 {main}\n' +
' thrown in /var/www/html/wp-content/plugins/WordPress-Importer-master/class-wxr-importer.php on line 1067\n'
}
possible culprits WXR_Importer->process_attachment WXR_Importer->process_post
Error: PHP.run() failed with exit code 255 and the following output: PHP Fatal error: Uncaught Error: Call to undefined function wp_generate_attachment_metadata() in /var/www/html/wp-content/plugins/WordPress-Importer-master/class-wxr-importer.php:1067
Stack trace:
#0 /var/www/html/wp-content/plugins/WordPress-Importer-master/class-wxr-importer.php(861): WXR_Importer->process_attachment(Array, Array, 'https://i0.wp.c...')
#1 /var/www/html/wp-content/plugins/WordPress-Importer-master/class-wxr-importer.php(383): WXR_Importer->process_post(Array, Array, Array, Array)
#2 php-wasm run script(17): WXR_Importer->import('/tmp/import.wxr')
#3 {main}
thrown in /var/www/html/wp-content/plugins/WordPress-Importer-master/class-wxr-importer.php on line 1067
at _NodePHP.run (/Users/seth/.npm/_npx/7c65af5c66ec2a7e/node_modules/@php-wasm/node/index.cjs:72937:23)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Object.importWxr (file:///Users/seth/.npm/_npx/7c65af5c66ec2a7e/node_modules/@wp-playground/blueprints/index.js:912:3)
at async o (file:///Users/seth/.npm/_npx/7c65af5c66ec2a7e/node_modules/@wp-playground/blueprints/index.js:9413:30)
at async Object.run (file:///Users/seth/.npm/_npx/7c65af5c66ec2a7e/node_modules/@wp-playground/blueprints/index.js:9340:23)
at async runBlueprintSteps (file:///Users/seth/.npm/_npx/7c65af5c66ec2a7e/node_modules/@wp-playground/blueprints/index.js:9448:3)
at async startWPNow (file:///Users/seth/.npm/_npx/7c65af5c66ec2a7e/node_modules/@wp-now/wp-now/main.js:663:5)
at async startServer (file:///Users/seth/.npm/_npx/7c65af5c66ec2a7e/node_modules/@wp-now/wp-now/main.js:981:42)
at async Object.handler (file:///Users/seth/.npm/_npx/7c65af5c66ec2a7e/node_modules/@wp-now/wp-now/main.js:1167:25) {
blueprint
{
"$schema": "https://playground.wordpress.net/blueprint-schema.json",
"preferredVersions": {
"php": "8.2",
"wp": "6.5"
},
"phpExtensionBundles": [
"kitchen-sink"
],
"features": {
"networking": true
},
"steps": [
{
"step": "login",
"username": "admin",
"password": "password"
},
{
"step": "importWxr",
"file": {
"resource": "url",
"url": "https://raw.githubusercontent.com/WordPress/theme-test-data/try/cors-accessible-images/themeunittestdata.wordpress.xml"
}
}
]
}
Tested and received the following error, using
wp-now
(same on playground.wordpress.net)Uncaught Error: Call to undefined function wp_generate_attachment_metadata()
That's unrelated to this PR, that's either an Importer or Playground issue. I suspect the Importer isn't including the wp-admin related files, as it expects to be run within wp-admin only, and partly the fault of playground for not running the import in the context of wp-admin.
The fact you got to that point of the process suggets the image fetch worked though, so the PR is probably good, the above error not withstanding.
Ok, I tested it in another local dev environment.
For some reason it wasn't able to import the following posts, errors below
Failed to import Media “St. Louis Blues” Failed to import Media “2014-slider-mobile-behavior”
2024/05/03 15:48:59 [warn] 20232#0: *24 a client request body is buffered to a temporary file
.....client_body_temp/0000000001,
client: ::1,
server: ........,
request: "POST /wp-login.php HTTP/1.1",
host: "..........",
referrer: "http://......../wp-login.php?redirect_to=http%3A%2F%2F..........%2Fwp-admin%2F&reauth=1"
2024/05/03 15:50:33 [warn] 20232#0:
*221 a client request body is buffered to a temporary file .......,
client: ::1,
server: .........,
request: "POST /wp-admin/admin.php?import=wordpress&step=1&_wpnonce=......... HTTP/1.1",
host: "..........",
referrer: "http://............/wp-admin/import.php?import=wordpress"
otherwise the import seems to work as expected across domains
This PR isn't going to be viable.
While it's a quick fix for images, it doesn't work for the dozen .mov
files included.
I feel the correct option is to include the files in the repo instead.
I've converted this to pull from github instead, which works 100%.
The problem now is that Playground times out during import of attachments, as it times out waiting on PHP. Similar to what happens to most end-users during a WXR Import :)
Before merging this would need sed -i 's#try/cors-accessible-images#master#g' themeunittestdata.wordpress.xml
run on the file to reflect the new location of the branch files.
This PR attempts to replace the image URLs in the WXR with a variant that will be importable into Playground.
This has been untested as-is. This is provided such that others can give it a try. The WXR url to be used would be this:
See https://github.com/WordPress/theme-test-data/issues/82#issuecomment-2055567664 for the idea behind this.
See #82