Aborted trying to redefine constant 'MULTISITE'

I succesfully setup a local multisite, but when I try to deploy it on my staging environment (DigitalOcean droplet), I run into this error.

non-zero return code
PHP Fatal error:  Uncaught
Roots\WPConfig\Exceptions\ConstantAlreadyDefinedException: Aborted trying to
redefine constant 'MULTISITE'. `define('MULTISITE', ...)` has already been
occurred elsewhere. in /srv/www/staging.website.nl/releases/20191119124427/vendor/roots/wp-
Stack trace:
#0 /srv/www/staging.website.nl/releases/20191119124427/vendor/roots
/wp-config/src/Config.php(26): Roots\WPConfig\Config::defined('MULTISITE')
#1 /srv/www/staging.website.nl/releases/20191119124427/config/application.php(89):
Roots\WPConfig\Config::define('MULTISITE', true)
#2 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1198) :
eval()'d code(7): require_once('/srv/www/stagin...')
#3 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1198):
#4 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1159):
#5 phar:///usr/bin/wp/vendor/wp-cli/wp-
cli/php/WP_CLI/Bootstrap/LaunchRunner.php(23): WP_CLI\Runner->start()
#6 phar:///usr/bi in /srv/www/staging.website.nl/releases/20191119124427/vendor/roots/wp-config/src/Config.php on
line 106
fatal: []: FAILED! => {"changed": false, "cmd": ["wp", "core", "is-installed", "--skip-plugins", "--skip-themes", "--require=/srv/www/stagingwebsite.nl/shared/tmp_multisite_constants.php"], "delta": "0:00:00.137466", "end": "2019-11-19 12:44:55.781089", "failed_when_result": true, "rc": 255, "start": "2019-11-19 12:44:55.643623", "stderr_lines": ["PHP Fatal error:  Uncaught Roots\\WPConfig\\Exceptions\\ConstantAlreadyDefinedException: Aborted trying to redefine constant 'MULTISITE'. `define('MULTISITE', ...)` has already been occurred elsewhere. in /srv/www/staging.website.nl/releases/20191119124427/vendor/roots/wp-config/src/Config.php:106", "Stack trace:", "#0 /srv/www/staging.website.nl/releases/20191119124427/vendor/roots/wp-config/src/Config.php(26): Roots\\WPConfig\\Config::defined('MULTISITE')", "#1 /srv/www/staging.website.nl/releases/20191119124427/config/application.php(89): Roots\\WPConfig\\Config::define('MULTISITE', true)", "#2 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1198) : eval()'d code(7): require_once('/srv/www/stagin...')", "#3 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1198): eval()", "#4 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1159): WP_CLI\\Runner->load_wordpress()", "#5 phar:///usr/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/LaunchRunner.php(23): WP_CLI\\Runner->start()", "#6 phar:///usr/bi in /srv/www/staging.website.nl/releases/20191119124427/vendor/roots/wp-config/src/Config.php on line 106"], "stdout": "", "stdout_lines": []}

I tried following the instructions in the documentation: https://roots.io/trellis/docs/multisite/, but they were not entirely clear to me. This part in particular:

Trellis assumes your WordPress configuration already has multisite set up. If not, ensure the following values are placed somewhere in Bedrock’s config/application.php before provisioning your server:

This reads like I shouldn’t have to make any changes to config/application.php, but if I don’t add those changes, my website won’t work locally. If I do add these changes, it works locally, but won’t work when I try to deploy to my staging environment.

I found two threads with the same issue, but they were not much help.

  1. Aborted trying to redefine constant 'MULTISITE'. `define('MULTISITE', ...)` has already been occurred elsewhere
  2. Aborted trying to redefine constant ‘MULTISITE’. `define(‘MULTISITE’, …)

Would appreciate any insight into solving this, thanks!

I found this issue in the Github repo: https://github.com/roots/trellis/issues/1025

Removing the Config:: part of all the multisite define statements fixes my problem. The site works locally and on my staging server.

Hey @baardbaard, you might find this post helpful as it did the work for me:

Somwehere in the middle @knowler stated:

Note, I’m using define() rather than \Roots\Config::define() since Trellis will temporarily add these constants when it deploys. The latter will throw an error that stops the deploy while the former is silent (even though constants are being redefined).


This topic was automatically closed after 42 days. New replies are no longer allowed.