Deploy to Kinsta failing during "WordPress Installed?" task, related to tmp_multisite_constants.php

Something funky is happening all of a sudden with deployment to Kinsta. I’ve been deploying this site with Trellis for a while, and it has stopped working.

The problem happens in the “WordPress Installed?” step of the finalize-before.yml deploy hook. The error output is dozens of repetitions of this line:

Warning: strpos(): Empty needle in /www/examplecom_123/public/releases/20220322225856/web/wp/wp-includes/link-template.php on line 3535

Line 3535 is part of the plugins_url() function. The problem appears to be that Trellis’s tmp_multisite_constants.php file includes define('WPMU_PLUGIN_DIR', null);. Unfortunately plugins_url() is trying to use that as the search term in strpos().

I’ve reproduced the error myself by ssh-ing into the server and running the same command in the release directory:

wp core is-installed --skip-plugins --skip-themes --require=/www/examplecom_123/public/shared/tmp_multisite_constants.php

However, it works fine if I leave off the --require bit.

It also works fine if I remove define('WPMU_PLUGIN_DIR', null); from the constants file itself.

I have no idea why plugins_url() would be getting called, when theme and plugin loading has been skipped. This commit 5 years ago set up this deploy task, and after reading the message I’m even more confused.

Nonetheless, since this is not a multisite install, would it be safe to just override finalize-before with my own deploy hook and skip the --require part?

I might have found what’s causing plugins_url() to be called. Kinsta’s kinsta-mu-plugins adds some CLI commands, and those might be trying to run. I found these when adding --debug`` to wp core is-installed` :

Debug (commands): Deferring command: kinsta plugin list (0.187s)
Debug (commands): Deferring command: kinsta cache purge (0.187s)

I haven’t dug into the command code far enough to find the source, but it does looks like it’s enumerating plugins, so I suspect it’s where the error comes from.

For now the deployment is working fine with a custom deploy-hooks/finalize-before.yml:

# Customized WP installation check that should run without issue on Kinsta's servers.

- name: WordPress Installed?
  command: wp core is-installed --skip-plugins --skip-themes
    chdir: "{{ deploy_helper.new_release_path }}"
  register: wp_installed
  changed_when: false
  failed_when: wp_installed.stderr | default("") != "" or wp_installed.rc > 1

- name: Get WP theme template and stylesheet roots
  shell: >
    {% if not project.multisite.enabled | default(false) %}
      wp option get {{ item }} --skip-plugins --skip-themes
    {% else %}
      wp site list --field=url | xargs -I {} bash -c 'export url="{}"; echo -n "$url " && wp option get {{ item }} --skip-plugins --skip-themes --url=$url || echo'
    {% endif %}
    chdir: "{{ deploy_helper.current_path }}"
  register: wp_template_root
  changed_when: false
  failed_when: wp_template_root.stderr | default('') is not match("(|.*Could not get '" + item + "' option\. Does it exist\?)")
    - wp_installed.rc == 0
    - project.update_wp_theme_paths | default(update_wp_theme_paths | default(true)) | bool
    - template_root
    - stylesheet_root

Thanks for the detailed troubleshooting!

Technically Trellis could conditionally use a different is-installed command for non-multisite cases, but it’s never been an issue so I’ll assume this is related to that Kinsta plugin.