Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wp config simplifed to avoid complications on non live envs #17

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 1 addition & 25 deletions inc/network/includes-network.php
Original file line number Diff line number Diff line change
Expand Up @@ -496,33 +496,9 @@ function network_step2( $errors = false ) {
</label></p>
<textarea id="network-wpconfig-rules" class="code" readonly="readonly" cols="100" rows="31" aria-describedby="network-wpconfig-rules-description">
<?php ob_start(); ?>
if ( !empty( $_ENV['PANTHEON_ENVIRONMENT'] )) {
$site_name = $_ENV['PANTHEON_SITE_NAME'];
// Override $hostname value as needed.
switch ( $_ENV['PANTHEON_ENVIRONMENT'] ) {
case 'live':
$hostname = $_SERVER['HTTP_HOST'];
break;
case 'test':
$hostname = 'test-' . $site_name . '.pantheonsite.io';
break;
case 'dev':
$hostname = 'dev-' . $site_name . '.pantheonsite.io';
break;
case 'lando':
$hostname = $site_name . '.lndo.site';
break;
default:
$hostname = $_ENV['PANTHEON_ENVIRONMENT'] . '-' . $site_name . '.pantheonsite.io';
break;
}
} else {
// Override with a default hostname.
$hostname = '<?php echo $hostname ?>';
}
define( 'MULTISITE', true );
define( 'SUBDOMAIN_INSTALL', <?php echo $subdomain_install ? 'true' : 'false'; ?> );
define( 'DOMAIN_CURRENT_SITE', $hostname );
define( 'DOMAIN_CURRENT_SITE', $_SERVER['HTTP_HOST'] );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tested with Lando to confirm dropping the hard-coded hostname doesn't break anything locally?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested with Lando and found issues:

  1. Getting a PHP Notice when running lando wp cli commands: PHP Notice: Undefined index: HTTP_HOST in phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1296) : eval()'d code on line 90
  2. When pulling a WPMS site, users need to do a lando wp search-replace with --all-tables flag to include the wp_blogs & wp_site entries to be updated

Updated my PR to to fix the 1

For the 2 error, we might need to add a more verbose error to the generic error Error establishing a database connection to make sure that all the URLs are replaced accordingly

define( 'PATH_CURRENT_SITE', '<?php echo $base; ?>' );
define( 'SITE_ID_CURRENT_SITE', 1 );
define( 'BLOG_ID_CURRENT_SITE', 1 );
Expand Down
6 changes: 3 additions & 3 deletions pantheon.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@
if ( defined( 'WP_CLI' ) && WP_CLI ) {
require_once 'inc/cli.php';
}
if ( defined( 'MULTISITE' ) && defined( 'WP_ALLOW_MULTISITE' ) && WP_ALLOW_MULTISITE ) {
require_once 'inc/pantheon-network-setup.php';
}
if ( ! defined( 'FS_METHOD' ) ) {
/**
* When this constant is not set, WordPress writes and then deletes a
Expand All @@ -45,6 +42,9 @@
if ( getenv( 'FRAMEWORK' ) === 'wordpress_network' && ! defined( 'WP_ALLOW_MULTISITE' ) ) {
define( 'WP_ALLOW_MULTISITE', true );
}
if ( defined( 'MULTISITE' ) && defined( 'WP_ALLOW_MULTISITE' ) && WP_ALLOW_MULTISITE ) {
require_once 'inc/pantheon-network-setup.php';
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These lines are unrelated and merged in #21. Can you remove these from the PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the review. merged with the latest branch

if ( defined( 'WP_ALLOW_MULTISITE' ) && ( ! defined( 'MULTISITE' ) || empty( MULTISITE ) ) ) {
require_once 'inc/pantheon-multisite-finalize.php';
}
Expand Down