Skip to content

Error when executing Site_Command::create #392

@Rahe

Description

@Rahe

Bug Report

Describe the current, buggy behavior

When using the command site create, I have the error :

Because this code relies on get_super_admins() and that the key 0 is present. (https://github.com/wp-cli/entity-command/blob/main/src/Site_Command.php#L430)

On my case, the get_super_admins returns :

get_super_admins();
=> array(6) {
  [1]=>
  string(8) "aaaa"
  [2]=>
  string(8) "bbb"
  [3]=>
  string(6) "ccccc"
  [4]=>
  string(10) "dddd"
  [5]=>
  string(10) "ffff"
  [6]=>
  string(15) "gggg"
}

Describe how other contributors can replicate this bug
I do not know howto replicate this, maybe delete a super admin ?

Describe what you would expect as the correct outcome

That the code find the first by using PHP function.

Let us know what environment you are running this on

OS:     Linux 5.10.0-21-amd64 #1 SMP Debian 5.10.162-1 (2023-01-21) x86_64
Shell:  /bin/bash
PHP binary:     /usr/local/share/php8.0/bin/php
PHP version:    8.0.28
php.ini used:   /usr/local/share/php8.0/etc/php.ini
MySQL binary:   /usr/bin/mysql
MySQL version:  mysql  Ver 15.1 Distrib 10.8.5-MariaDB, for debian-linux-gnu (x86_64) using readline 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 phar path:       /home/recette/www/web
WP-CLI packages dir:    /home/recette/.wp-cli/packages/
WP-CLI cache dir:       /home/recette/.wp-cli/cache
WP-CLI global config:   /home/recette/.wp-cli/config.yml
WP-CLI project config:  /home/recette/www/wp-cli.yml
WP-CLI version: 2.7.1

Provide a possible solution

Using reset to get the first ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions