WordPress.org

Make WordPress Core

Opened 6 years ago

Closed 6 years ago

#28697 closed defect (bug) (fixed)

Fix ms_subdomain_constants()

Reported by: TobiasBg Owned by: wonderboymusic
Milestone: 4.0 Priority: normal
Severity: normal Version: 3.0
Component: Bootstrap/Load Keywords: has-patch
Focuses: multisite Cc:

Description

ms_subdomain_constants() brings parity between the SUBDOMAIN_INSTALL and the deprecated VHOST constants, introduced in [14452].

It's a two-step process, where the first run of the function checks and sets the constants as necessary, and where the second run is used to print debug warnings/errors.

However, the function does not account for "internal success". If the VHOST constant was not set (it shouldn't be anymore), it doesn't set $error=false; so that all checks are unnecessarily performed again in the next evaluation of the function (the if-condition false === $error further up in the function is never true).
(If one then runs the function for a third time, an error will be shown, although nothing was wrong initially.)

Also, one of the if-conditions can be simplified.

Attachments (1)

28697.diff (1.3 KB) - added by TobiasBg 6 years ago.

Download all attachments as: .zip

Change History (5)

@TobiasBg
6 years ago

#1 @wonderboymusic
6 years ago

  • Owner set to wonderboymusic
  • Resolution set to fixed
  • Status changed from new to closed

In 29200:

Properly set $subdomain_error to false when applicable in ms_subdomain_constants(). This was previously untestable because it used static vars: use globals instead.

Adds unit test.
Fixes #28697.

#2 @wonderboymusic
6 years ago

Props TobiasBg.

Version 0, edited 6 years ago by wonderboymusic (next)

#3 @SergeyBiryukov
6 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

I don't think the unit test here is important enough to replace static variables with globals.

#4 @wonderboymusic
6 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

In 29250:

After [29200], switch back to using static vars instead of adding 2 globals, as per Sergey.

Fixes #28697.

Note: See TracTickets for help on using tickets.