Skip to content

Export functionality limited to hardcoded post statuses #120

@ouikhuan

Description

@ouikhuan

Bug Report

Describe the current, buggy behavior

The export command is currently limited to exporting posts with only four hardcoded statuses (publish, pending, draft, private) due to the use of get_post_statuses(). This prevents exporting posts with other valid statuses like 'future' scheduled posts or any custom post statuses registered in the WordPress instance.

Describe how other contributors can replicate this bug

  • Try to create a post and scheduled it to future.
  • Run wp export command with post_status set to future wp export --post_type=post --post_status=future
  • You'll get a warning llike Warning: Could not find a post_status matching future. Here is a list of available stati: draft, pending, private, publish

Describe what you would expect as the correct outcome

The export command should include all posts regardless of their status, as long as the status is registered in WordPress. This includes core statuses like 'future' for scheduled posts.

Let us know what environment you are running this on

OS:	Darwin 23.5.0 Darwin Kernel Version 23.5.0: Wed May  1 20:12:58 PDT 2024; root:xnu-10063.121.3~5/RELEASE_ARM64_T6000 arm64
Shell:	/bin/zsh
PHP binary:	/opt/homebrew/Cellar/php/8.3.9/bin/php
PHP version:	8.3.9
php.ini used:	/opt/homebrew/etc/php/8.3/php.ini
MySQL binary:	/opt/homebrew/opt/[email protected]/bin/mysql
MySQL version:	mysql  Ver 14.14 Distrib 5.7.44, for osx10.17 (x86_64) using  EditLine wrapper
SQL modes:
WP-CLI root dir:	phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir:	phar://wp-cli.phar/vendor
WP-CLI version:	2.7.1

Provide a possible solution

Replace the usage of get_post_statuses() with get_post_stati() in the export command implementation. The get_post_stati() function returns all registered post statuses in WordPress, making it more comprehensive and future-proof.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions