Skip to content

Commit e8257c6

Browse files
committed
Site_Command: Do not assume get_super_admins() has the 0 array
index Fixes #392
1 parent 45d4f3a commit e8257c6

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

features/site-create.feature

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,51 @@ Feature: Create a new site on a WP multisite
4646
| blog_id | url |
4747
| 1 | http://localhost/dev/ |
4848
| 2 | http://localhost/dev/newsite/ |
49+
50+
Scenario: Create new site with custom `$super_admins` global
51+
Given an empty directory
52+
And WP files
53+
And a database
54+
And a extra-config file:
55+
"""
56+
define( 'WP_ALLOW_MULTISITE', true );
57+
define( 'MULTISITE', true );
58+
define( 'SUBDOMAIN_INSTALL', false );
59+
define( 'DOMAIN_CURRENT_SITE', 'localhost' );
60+
define( 'PATH_CURRENT_SITE', '/' );
61+
define('SITE_ID_CURRENT_SITE', 1);
62+
define('BLOG_ID_CURRENT_SITE', 1);
63+
64+
$super_admins = array( 1 => 'admin' );
65+
"""
66+
When I run `wp core config {CORE_CONFIG_SETTINGS} --extra-php < extra-config`
67+
Then STDOUT should be:
68+
"""
69+
Success: Generated 'wp-config.php' file.
70+
"""
71+
72+
# Old versions of WP can generate wpdb database errors if the WP tables don't exist, so STDERR may or may not be empty
73+
When I try `wp core multisite-install --url=localhost --title=Test --admin_user=admin [email protected]`
74+
Then STDOUT should contain:
75+
"""
76+
Success: Network installed. Don't forget to set up rewrite rules
77+
"""
78+
And the return code should be 0
79+
80+
When I run `wp site list --fields=blog_id,url`
81+
Then STDOUT should be a table containing rows:
82+
| blog_id | url |
83+
| 1 | http://localhost/ |
84+
85+
When I run `wp site create --slug=newsite`
86+
Then STDOUT should be:
87+
"""
88+
Success: Site 2 created: http://localhost/newsite/
89+
"""
90+
91+
When I run `wp site list --fields=blog_id,url`
92+
Then STDOUT should be a table containing rows:
93+
| blog_id | url |
94+
| 1 | http://localhost/ |
95+
| 2 | http://localhost/newsite/ |
96+

src/Site_Command.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ public function create( $args, $assoc_args ) {
435435
$email = '';
436436
if ( ! empty( $super_admins ) && is_array( $super_admins ) ) {
437437
// Just get the first one
438-
$super_login = $super_admins[0];
438+
$super_login = reset( $super_admins );
439439
$super_user = get_user_by( 'login', $super_login );
440440
if ( $super_user ) {
441441
$email = $super_user->user_email;

0 commit comments

Comments
 (0)