Skip to content

Commit cbfb90e

Browse files
Copilotswissspidy
andcommitted
Fix multinetwork test: verify isolation via count and absent URLs
The wp-config.php SITE_ID_CURRENT_SITE swap approach cannot change the network context because WordPress also reads BLOG_ID_CURRENT_SITE=1 (hardcoded, can't be changed without knowing the network-2 blog ID), and since blog 1 belongs to network 1, WordPress overrides $current_site back to network 1 regardless of SITE_ID_CURRENT_SITE. Instead, verify the site_id filter works by: 1. Creating 5 active sites (3 in network 1, 2 in network 2) 2. Running wp core update-db --network and asserting "3/3 sites" not "5/5" 3. Asserting that net2-site1 URL is absent from output This is a true regression test: without the site_id filter the old code would have processed all 5 sites (5/5), and network-2 URLs would appear. Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
1 parent 04cfa08 commit cbfb90e

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

features/core-update-db.feature

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ Feature: Update core's database
153153

154154
# This test downgrades to an older WordPress version, but the SQLite plugin requires 6.0+
155155
@require-mysql
156-
Scenario: Update db targets only the specified network in multinetwork setup
156+
Scenario: Update db only updates sites from the current network in multinetwork setup
157157
Given a WP multisite install
158158
And a disable_sidebar_check.php file:
159159
"""
@@ -166,10 +166,10 @@ Feature: Update core's database
166166
And I run `wp core download --version=5.4 --force`
167167
And I run `wp option update db_version 45805 --require=disable_sidebar_check.php`
168168
And I run `wp site option update wpmu_upgrade_site 45805`
169-
# Create 2 sites in network 1 (main site already exists; 3 total in network 1)
169+
# Create 2 additional sites in network 1 (main site already exists; 3 total in network 1)
170170
And I run `wp site create --slug=net1-site1`
171171
And I run `wp site create --slug=net1-site2`
172-
# Create 2 sites that will be moved to a second network
172+
# Create 2 sites that will be moved to a second network (5 sites total)
173173
And I run `wp site create --slug=net2-site1 --porcelain`
174174
And save STDOUT as {NET2_SITE1_ID}
175175
And I run `wp site create --slug=net2-site2 --porcelain`
@@ -181,28 +181,24 @@ Feature: Update core's database
181181
When I run `wp site option get wpmu_upgrade_site`
182182
Then save STDOUT as {UPDATE_VERSION}
183183

184-
# With SITE_ID_CURRENT_SITE=1, only the 3 network-1 sites are processed (not all 5)
184+
# Only the 3 network-1 sites should be processed (not all 5 active sites).
185+
# If the site_id filter were absent, the count would be 5/5 and net2 URLs would appear.
185186
When I run `wp core update-db --network`
186187
Then STDOUT should contain:
187188
"""
188189
Success: WordPress database upgraded on 3/3 sites.
189190
"""
191+
And STDOUT should not contain:
192+
"""
193+
net2-site1
194+
"""
190195

191196
When I run `wp site option get wpmu_upgrade_site`
192197
Then STDOUT should not contain:
193198
"""
194199
{UPDATE_VERSION}
195200
"""
196201

197-
# Switch wp-config.php to network 2 context; only network 2's 2 sites should be processed
198-
And "define( 'SITE_ID_CURRENT_SITE', 1 );" replaced with "define( 'SITE_ID_CURRENT_SITE', 2 );" in the wp-config.php file
199-
200-
When I run `wp core update-db --network`
201-
Then STDOUT should contain:
202-
"""
203-
Success: WordPress database upgraded on 2/2 sites.
204-
"""
205-
206202
Scenario: Ensure update-db sets WP_INSTALLING constant
207203
Given a WP install
208204
And a before.php file:

0 commit comments

Comments
 (0)