Skip to content

Commit

Permalink
Force order of precedence in ?? and &&
Browse files Browse the repository at this point in the history
The && operator happens before ?? so the localhost check is being
evaluated together with the null. This change forces the intended
behavior.

See: https://www.php.net/manual/en/language.operators.precedence.php
  • Loading branch information
kovshenin committed Feb 6, 2023
1 parent cc1840a commit 3334928
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion inc/namespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ function bootstrap() {
add_filter( 'altis.search.create_package_id', __NAMESPACE__ . '\\set_search_package_id', 10, 3 );

// If we're on Codespaces, the native host will be localhost.
if ( $config['codespaces_integration'] ?? null && $_SERVER['HTTP_HOST'] === 'localhost' ) {
if ( ( $config['codespaces_integration'] ?? null ) && $_SERVER['HTTP_HOST'] === 'localhost' ) {
// Use forwarded host if we can.
if ( ! empty( $_SERVER['HTTP_X_FORWARDED_HOST'] ) ) {
// phpcs:ignore HM.Security.ValidatedSanitizedInput
Expand Down

0 comments on commit 3334928

Please sign in to comment.