Issue with Multisite + Gutenberg

Running into a bunch of issues with Multisite and Gutenberg. I have the **Multisite URL Fixer *** enabled in mu plugins

My subsite’s info is:

Site Address: http://subsite.tst/
Site URL: http://subsite.tst
Home: http://subsite.tst/wp

I can’t seem to change the latter two, I believe it may be due to the MU plugin? When I try to save it reverts.

I read through the documentation multiple times and can’t seem to figure out what the issue is.

Note: Locally I am using apache (MAMP), but upstream using trellis, I’m having the same problems in both environments.

I hope to turn my learning experiences here into a guide so that others can learn from what I am doing…

I created a brand new multisite using the following:

(NOTE: The repo I used for this site can be found @ GitHub - matgargano/multisite …)

{
  "name": "roots/bedrock",
  "type": "project",
  "license": "MIT",
  "description": "WordPress boilerplate with modern development tools, easier configuration, and an improved folder structure",
  "homepage": "https://roots.io/bedrock/",
  "authors": [
    {
      "name": "Scott Walkinshaw",
      "email": "scott.walkinshaw@gmail.com",
      "homepage": "https://github.com/swalkinshaw"
    },
    {
      "name": "Ben Word",
      "email": "ben@benword.com",
      "homepage": "https://github.com/retlehs"
    }
  ],
  "keywords": [
    "bedrock", "composer", "roots", "wordpress", "wp", "wp-config"
  ],
  "support": {
    "issues": "https://github.com/roots/bedrock/issues",
    "forum": "https://discourse.roots.io/category/bedrock"
  },
  "config": {
    "preferred-install": "dist"
  },
  "repositories": [
    {
      "type": "composer",
      "url": "https://wpackagist.org"
    }
  ],
  "require": {
    "php": ">=7.0",
    "composer/installers": "^1.4",
    "vlucas/phpdotenv": "^3.0.0",
    "oscarotero/env": "^1.1.0",
    "roots/wordpress": "5.1.1",
    "roots/wp-config": "1.0.0",
    "roots/wp-password-bcrypt": "1.0.0",
    "roots/multisite-url-fixer": "^1.1"
  },
  "require-dev": {
    "squizlabs/php_codesniffer": "^3.0.2",
    "roave/security-advisories": "dev-master"
  },
  "extra": {
    "installer-paths": {
      "web/app/mu-plugins/{$name}/": ["type:wordpress-muplugin"],
      "web/app/plugins/{$name}/": ["type:wordpress-plugin"],
      "web/app/themes/{$name}/": ["type:wordpress-theme"]
    },
    "wordpress-install-dir": "web/wp"
  },
  "scripts": {
    "post-root-package-install": [
      "php -r \"copy('.env.example', '.env');\""
    ],
    "test": [
      "phpcs"
    ]
  }
}

and my wordpress_sites.yml

# Documentation: https://roots.io/trellis/docs/remote-server-setup/
# `wordpress_sites` options: https://roots.io/trellis/docs/wordpress-sites
# Define accompanying passwords/secrets in group_vars/production/vault.yml

wordpress_sites:
  manage.matgargano.com:
    site_hosts:
      - canonical: manage.matgargano.com

    local_path: ../site # path targeting local Bedrock site directory (relative to Ansible root)
    repo: git@github.com:matgargano/multisite.git
    repo_subtree_path: site # relative path to your Bedrock/WP directory in your repo
    branch: master
    multisite:
      enabled: true
      subdomains: true
    ssl:
      enabled: true
      provider: letsencrypt
    cache:
      enabled: false
    env:
      domain_current_site: manage.matgargano.com

I left tmp_multisite_constants.php as it naturally is and added nothing (yet) to application.php

<?php
error_reporting(E_ALL & ~E_NOTICE);
define('MULTISITE', false);
define('SUBDOMAIN_INSTALL', false);
define('WPMU_PLUGIN_DIR', null);
define('WP_PLUGIN_DIR', null);
define('WP_USE_THEMES', false);

Provisioned using (trellis provision production … see GitHub - roots/trellis-cli: A CLI to manage Trellis projects for the tool i used), then commented out all the PHP in tmp_multisite_constants.phpand added to application.php the following:

Config::define('WP_ALLOW_MULTISITE', true);
Config::define('MULTISITE', true);
Config::define('SUBDOMAIN_INSTALL', true); // Set to true if using subdomains
Config::define('DOMAIN_CURRENT_SITE', env('DOMAIN_CURRENT_SITE'));
Config::define('PATH_CURRENT_SITE', env('PATH_CURRENT_SITE') ?: '/');
Config::define('SITE_ID_CURRENT_SITE', env('SITE_ID_CURRENT_SITE') ?: 1);
Config::define('BLOG_ID_CURRENT_SITE', env('BLOG_ID_CURRENT_SITE') ?: 1);
Config::define('ADMIN_COOKIE_PATH', '/');
Config::define('COOKIE_DOMAIN', '');
Config::define('COOKIEPATH', '');
Config::define('SITECOOKIEPATH', '');

I then deployed using trellis deploy production manage.matgargano.com … see GitHub - roots/trellis-cli: A CLI to manage Trellis projects for the tool i used

I setup the Multisite using WP CLI on the box wp core multisite-install --title="site title" --admin_user="mat" --admin_password="gotcha" --admin_email="mat@me.com"

I logged into the multisite network admin and I went to use the created manage.matgargano.com

When I go to https://manage.matgargano.com/wp/wp-admin/post.php?post=2&action=edit and try to update a post that has with Gutenberg I get a failure.

However if I go to (note that I removed the /wp/) https://manage.matgargano.com/wp-admin/post.php?post=2&action=edit I can update the post without issue,

but if I try to customize with and without /wp/ e.g., https://manage.matgargano.com/wp/wp-admin/customize.php?return=%2Fwp%2Fwp-admin%2F OR https://manage.matgargano.com/wp-admin/customize.php?return=%2Fwp%2Fwp-admin%2F … I get the following failure no matter what I try

You need a higher level of permission.
Sorry, you are not allowed to customize this site.

My questions boil down to –

  • Am I doing anything wrong? I’d like to stay as close to the right way of using Trellis as possible…

  • How can I get the customizer to work?

Note that here are my site settings for manage.matgargano.com

Hi, Im experiencing a similar issue. Have you found a solve?

I have not – I can’t see how anyone can use the customizer on a multisite with trellis, though I am likely doing something wrong

Just to confirm, everything else with this install seems to work? It’s only an issue with Gutenberg posts?

And then the customizer issue is separate?

Am I doing anything wrong? I’d like to stay as close to the right way of using Trellis as possible…

Doesn’t look like it but honestly I don’t have much experience with multisite on Trellis myself

How can I get the customizer to work?

The most likely answer is there’s a bug somewhere… I’m not really much help though :frowning_face:

Can you check/post the contents of the generated .env file (on your VM/server in the web root).

Yes, I’m sorry the two get a bit conflated here, but I did not want to flood with new topics. So, breaking down the two issues here, which are potentially related:

“Out of the box” using the install that I describe above, neither Gutenberg, nor the customizer work.

Gutenberg:

A temporary bandaid fix for Gutenberg is adding a 301 redirect for :

/wp/wp-admin/post.php* to /wp-admin/post.php*
/wp/wp-admin/post-new.php* to /wp-admin/post-new.php*

Customizer:

I tried the same style fix for customizer, i.e. adding a redirect for the Customizer

/wp/wp-admin/customize.php?return=%2Fwp%2Fwp-admin%2Fedit.php to /wp-admin/customize.php?return=%2Fwp%2Fwp-admin%2Fedit.php

I get the same results as if I do not redirect


In my trellis built server here is my .env

AUTH_KEY='{redacted}'
AUTH_SALT='{redacted}'
DB_HOST='localhost'
DB_NAME='manage_matgargano_com_production'
DB_PASSWORD='{redacted}'
DB_USER='{redacted}'
DISABLE_WP_CRON='True'
DOMAIN_CURRENT_SITE='manage.matgargano.com'
LOGGED_IN_KEY='{redacted}'
LOGGED_IN_SALT='{redacted}'
NONCE_KEY='{redacted}'
NONCE_SALT='{redacted}'
SECURE_AUTH_KEY='{redacted}'
SECURE_AUTH_SALT='{redacted}'
WP_ENV='production'
WP_HOME='https://manage.matgargano.com'
WP_SITEURL='https://manage.matgargano.com/wp'

You can recreate my issue using the repo I am using GitHub - matgargano/multisite

or I can easily give you access to everything, feel free to message me on slack and then whatever the solution is that we get to I will summarize for the rest of the community.

1 Like

any thoughts here? I may have to abandon MU for client sites if this is an issue. This would really neatly allow me to host multiple client sites on the same server.

There’s a 100% chance this can be fixed.

I currently don’t have the free time to look into this myself.

@mgargano I think I’m experiencing this issue as well. I’ll report back with my findings.

@knowler :+1: I am at a loss at this point.

The solution seems to be as simple as setting the following in config/application.php:

Config::define('COOKIE_DOMAIN', $_SERVER['HTTP_HOST']);

For me the issues had to do with the nonce cookie not being able to verify since the sub-site domain was different than the cookie domain. I was having difficulty with Gutenberg and a multisite using custom domains for sub-sites. So I don’t know if this will work for your issue.

This does not work in my configuration.

Can you test if this works for your Customizer?

Also can you post your application.php

mine is: config.php · GitHub

Customizer seems to work fine. Here’s my Bedrock config:

https://gist.github.com/knowler/3727742a753cdd34750895c8303c259c

OK Few things —

First and foremost : https://gist.github.com/knowler/3727742a753cdd34750895c8303c259c#file-application-php-L102 any issue with the single colon? I’ve literally never seen that in PHP

Do you have all subdirectories? subdomains? Do you have any TLD mapped domains?

Thanks for the assistance so far…

Ok some more things…

If I use a subdomain, e.g. manage.matgargano.com and multisite.matgargano.com i am able to do everything without any issue.

if i map to a separate domain (foobar.com) that’s when i have the issue… still digging further…

My bad that’s a syntax error.

I have mapped domains with a subdomain setup.

Have you tried mapping TLDs and not subdomains? If not- can you? I can supply the domain if you need one.

Something isn’t adding up… likely something I’m doing. Would you want to walk through the whole process with trellis and bedrock with me to see where I’m possibly doing something wrong.

-Mat

@knowler any update here?

See this: