Skip to content

PHP warning in wp comment recount command with invalid post ID #464

@ernilambar

Description

@ernilambar

Bug Report

Describe the current, buggy behavior

In comment recount command, if Post ID does not exist, PHP warnings are generated.

wp comment recount 111

PHP Warning:  Attempt to read property "ID" on null in /Users/nilambarsharma/.../extension-command/vendor/wp-cli/entity-command/src/Comment_Command.php on line 680
Warning: Attempt to read property "ID" on null in /Users/nilambarsharma/.../extension-command/vendor/wp-cli/entity-command/src/Comment_Command.php on line 680
Warning: Post  doesn't exist.

Describe what you would expect as the correct outcome

Proper message should be displayed without PHP warnings.

Let us know what environment you are running this on

OS:     Darwin 22.6.0 Darwin Kernel Version 22.6.0: Tue Nov  7 21:48:06 PST 2023; root:xnu-8796.141.3.702.9~2/RELEASE_X86_64 x86_64
Shell:  /bin/zsh
PHP binary:     /usr/local/Cellar/[email protected]/8.2.15/bin/php
PHP version:    8.2.15
php.ini used:   /usr/local/etc/php/8.2/php.ini
MySQL binary:   /usr/local/bin/mysql
MySQL version:  mysql  Ver 8.3.0 for macos13.6 on x86_64 (Homebrew)
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 phar path:       /Users/nilambarsharma/Sites/staging
WP-CLI packages dir:    /Users/nilambarsharma/.wp-cli/packages/
WP-CLI cache dir:       /Users/nilambarsharma/.wp-cli/cache
WP-CLI global config:   /Users/nilambarsharma/.wp-cli/config.yml
WP-CLI project config:  /Users/nilambarsharma/Sites/staging/wp-cli.local.yml
WP-CLI version: 2.10.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions