ROOTPLOIT
Server: LiteSpeed
System: Linux in-mum-web1878.main-hosting.eu 5.14.0-570.21.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jun 11 07:22:35 EDT 2025 x86_64
User: u435929562 (435929562)
PHP: 7.4.33
Disabled: system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail
Upload Files
File: //opt/.wp-cli/packages/vendor/wp-cli/entity-command/features/post-meta-clean-duplicates.feature
Feature: Clean up duplicate post meta values

  Scenario: Clean up duplicate post meta values.
    Given a WP install
    And a session_no file:
      """
      n
      """
    And a session_yes file:
      """
      y
      """

    When I run `wp post meta add 1 foo bar`
    Then STDOUT should be:
      """
      Success: Added custom field.
      """

    When I run the previous command again
    Then the return code should be 0

    When I run the previous command again
    Then the return code should be 0

    When I run `wp post meta list 1 --keys=foo`
    Then STDOUT should be a table containing rows:
      | post_id | meta_key | meta_value |
      | 1       | foo      | bar        |
      | 1       | foo      | bar        |
      | 1       | foo      | bar        |

    When I run `wp post meta clean-duplicates 1 foo < session_no`
    # Check for contains only, as the string contains a trailing space.
    Then STDOUT should contain:
      """
      Are you sure you want to delete 2 duplicate meta values and keep 1 valid meta value? [y/n]
      """

    When I run `wp post meta list 1 --keys=foo --format=count`
    Then STDOUT should be:
      """
      3
      """

    When I run `wp post meta clean-duplicates 1 foo < session_yes`
    Then STDOUT should contain:
      """
      Cleaned up duplicate 'foo' meta values.
      """

    When I try the previous command again
    Then STDOUT should contain:
      """
      Success: Nothing to clean up: found 1 valid meta value and 0 duplicates.
      """

    When I try `wp post meta clean-duplicates 1 food`
    Then STDERR should be:
      """
      Error: No meta values found for 'food'.
      """
    And the return code should be 1