Skip to content

Close ProcessOutputStream in Runtime::eval_php_code_in_subprocess#265

Open
fredrikekelund wants to merge 1 commit intoWordPress:trunkfrom
fredrikekelund:f26d/close-php-subprocess-stream
Open

Close ProcessOutputStream in Runtime::eval_php_code_in_subprocess#265
fredrikekelund wants to merge 1 commit intoWordPress:trunkfrom
fredrikekelund:f26d/close-php-subprocess-stream

Conversation

@fredrikekelund
Copy link
Copy Markdown

Codex helped me diagnose and fix this issue.

When running the following blueprint using php-cli on Windows, I ran into an error like this:

View blueprint
{
	"$schema": "https://playground.wordpress.net/blueprint-schema.json",
	"landingPage": "/wp-admin/themes.php",
	"steps": [
		{
			"step": "installTheme",
			"themeData": {
				"resource": "wordpress.org/themes",
				"slug": "twentytwentyone"
			}
		},
		{
			"step": "activateTheme",
			"themeFolderName": "twentytwentyone"
		}
	]
}
View logs
{"type":"error","message":"Failed to remove directory: C:\/Users\/fredrik\/AppData\/Local\/Temp\/wp-blueprints-runtime-69f9bf3281ae4\/tmp_69f9bf32b8d62","details":{"exception":"WordPress\\Filesystem\\FilesystemException","message":"Failed to remove directory: C:\/Users\/fredrik\/AppData\/Local\/Temp\/wp-blueprints-runtime-69f9bf3281ae4\/tmp_69f9bf32b8d62","file":"phar:\/\/C:\/Users\/fredrik\/Documents\/GitHub\/studio\/apps\/studio\/out\/Studio-win32-arm64\/resources\/cli\/wp-files\/blueprints\/blueprints.phar\/components\/Filesystem\/class-localfilesystem.php","line":157,"trace":"#0 phar:\/\/C:\/Users\/fredrik\/Documents\/GitHub\/studio\/apps\/studio\/out\/Studio-win32-arm64\/resources\/cli\/wp-files\/blueprints\/blueprints.phar\/components\/Filesystem\/Mixin\/trait-rmdirrecursive.php(21): WordPress\\Filesystem\\LocalFilesystem->rmdir_single('C:\/Users\/fredri...', Array)\n#1 phar:\/\/C:\/Users\/fredrik\/Documents\/GitHub\/studio\/apps\/studio\/out\/Studio-win32-arm64\/resources\/cli\/wp-files\/blueprints\/blueprints.phar\/components\/Filesystem\/Mixin\/trait-rmdirrecursive.php(15): WordPress\\Filesystem\\LocalFilesystem->rmdir('C:\/Users\/fredri...', Array)\n#2 phar:\/\/C:\/Users\/fredrik\/Documents\/GitHub\/studio\/apps\/studio\/out\/Studio-win32-arm64\/resources\/cli\/wp-files\/blueprints\/blueprints.phar\/components\/Filesystem\/Layer\/class-chrootlayer.php(103): WordPress\\Filesystem\\LocalFilesystem->rmdir('C:\/Users\/fredri...', Array)\n#3 phar:\/\/C:\/Users\/fredrik\/Documents\/GitHub\/studio\/apps\/studio\/out\/Studio-win32-arm64\/resources\/cli\/wp-files\/blueprints\/blueprints.phar\/components\/Blueprints\/class-runner.php(291): WordPress\\Filesystem\\Layer\\ChrootLayer->rmdir('C:\/Users\/fredri...', Array)\n#4 phar:\/\/C:\/Users\/fredrik\/Documents\/GitHub\/studio\/apps\/studio\/out\/Studio-win32-arm64\/resources\/cli\/wp-files\/blueprints\/blueprints.phar\/components\/Blueprints\/bin\/blueprint.php(398): WordPress\\Blueprints\\Runner->run()\n#5 phar:\/\/C:\/Users\/fredrik\/Documents\/GitHub\/studio\/apps\/studio\/out\/Studio-win32-arm64\/resources\/cli\/wp-files\/blueprints\/blueprints.phar\/components\/Blueprints\/bin\/blueprint.php(675): handleExecCommand(Array, Array, Array, Object(JsonProgressReporter))\n#6 C:\\Users\\fredrik\\Documents\\GitHub\\studio\\apps\\studio\\out\\Studio-win32-arm64\\resources\\cli\\wp-files\\blueprints\\blueprints.phar(12): require('phar:\/\/C:\/Users...')\n#7 {main}"}}

This PR explicitly closes the ProcessOutputStream in Runtime::eval_php_code_in_subprocess before returning. I've confirmed that this fixes the issue on my Windows VM.

@fredrikekelund
Copy link
Copy Markdown
Author

I'd greatly appreciate a review on this, @adamziel or maybe @ashfame 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant