Skip to content

WP_CLI::runcommand() reusing the process does not attach media to a post #6025

@slavicd

Description

@slavicd

Bug Report

This results in an attachment being created, but not attached to any particular post.

WP_CLI::runcommand(
            sprintf('media import "%s" --post_id="%d" --featured_image --porcelain', $img_path, $post_id),
            ['return' => true, 'launch' => false]
        );

This results in an attachment being created, and attached to the post (expected behaviour).

WP_CLI::runcommand(
            sprintf('media import "%s" --post_id="%d" --featured_image --porcelain', $img_path, $post_id),
            ['return' => true, 'launch' => true]
        );

Let us know what environment you are running this on

wp cli info
OS:	Linux 5.15.0-1061-gke #67-Ubuntu SMP Wed Jun 12 18:17:06 UTC 2024 x86_64
Shell:	/bin/bash
PHP binary:	/usr/bin/php8.2-zend
PHP version:	8.2.24
php.ini used:	/etc/php/8.2-zend/cli/php.ini
MySQL binary:	/usr/bin/mysql
MySQL version:	mysql  Ver 8.0.39-0ubuntu0.22.04.1 for Linux on x86_64 ((Ubuntu))
SQL modes:	STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
WP-CLI root dir:	phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir:	phar://wp-cli.phar/vendor
WP_CLI phar path:	/nas/content/live/rcmathewsdev
WP-CLI packages dir:	
WP-CLI cache dir:	/home/wpe-user/.wp-cli/cache
WP-CLI global config:	/home/wpe-user/.wp-cli/config.yml
WP-CLI project config:	
WP-CLI version:	2.11.0

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions