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

WordPress database error Table 'wordpress.wp_blogs' doesn't exist #324

Open
stuartshields opened this issue Jan 29, 2017 · 2 comments
Open
Assignees

Comments

@stuartshields
Copy link

How to replicate the issue:

  1. Clone chassis into a new folder
  2. vagrant up --provision
  3. Go into config.yaml make multisite: subdomains
  4. clone an extension that has uses wp::plugin or even create a custom one that uses it. I just cloned the debugging one, - this isn’t the steps in the debugging one I know however it replicates the issue easily - git clone [email protected]:Chassis/Debugging.git extensions/debugging
  5. vagrant provision
  6. wait and vagrant provision again (I don’t go to the site at all in between the two provisions` (I think the second provision must activate the plugins via network or some shit and returns a bunch of errors)
  7. vagrant ssh > cd /vagrant/wp/ > wp site list --field=url will return a bunch of errors.
@BronsonQuick
Copy link
Member

Alrighty so after lots of debugging I'm going to post some notes at where I'm at with this. So the core reason for this falls down to this block of code:

exec {"wp install $location":
		command => "/usr/bin/wp core $install --title='$sitename' --admin_email='$admin_email' --admin_name='$admin_user' --admin_password='$admin_password'",
		cwd => $location,
		user => $::wp::user,
		require => [ Class['wp::cli'] ],
		unless => '/usr/bin/wp core is-installed'
	}

Specifically the unless => '/usr/bin/wp core is-installed' line. If that line is removed then WP-CLI will run the multisite-install commands which create the multisite tables it needs however, if we remove that line then a new provision will error out as follows:

==> default: Notice: /Stage[main]/Main/Chassis::Wp[vagrant.local]/Chassis::Site[vagrant.local]/Mysql::Db[wordpress]/Database_grant[wordpress@localhost/wordpress]/privileges: privileges changed '' to 'all'
==> default: Notice: /Stage[main]/Main/Chassis::Wp[vagrant.local]/Chassis::Site[vagrant.local]/Wp::Site[/vagrant/wp]/Exec[wp install /vagrant/wp]/returns: PHP Fatal error:  Uncaught Error: Call to undefined function Chassis\Hosts\get_sites() in /vagrant/local-config-hosts.php:39
==> default: Notice: /Stage[main]/Main/Chassis::Wp[vagrant.local]/Chassis::Site[vagrant.local]/Wp::Site[/vagrant/wp]/Exec[wp install /vagrant/wp]/returns: Stack trace:
==> default: Notice: /Stage[main]/Main/Chassis::Wp[vagrant.local]/Chassis::Site[vagrant.local]/Wp::Site[/vagrant/wp]/Exec[wp install /vagrant/wp]/returns: #0 /vagrant/local-config-hosts.php(26): Chassis\Hosts\write_hosts()
==> default: Notice: /Stage[main]/Main/Chassis::Wp[vagrant.local]/Chassis::Site[vagrant.local]/Wp::Site[/vagrant/wp]/Exec[wp install /vagrant/wp]/returns: #1 /vagrant/wp/wp-includes/class-wp-hook.php(298): Chassis\Hosts\maybe_add_host('')
==> default: Notice: /Stage[main]/Main/Chassis::Wp[vagrant.local]/Chassis::Site[vagrant.local]/Wp::Site[/vagrant/wp]/Exec[wp install /vagrant/wp]/returns: #2 /vagrant/wp/wp-includes/class-wp-hook.php(323): WP_Hook->apply_filters(NULL, Array)
==> default: Notice: /Stage[main]/Main/Chassis::Wp[vagrant.local]/Chassis::Site[vagrant.local]/Wp::Site[/vagrant/wp]/Exec[wp install /vagrant/wp]/returns: #3 /vagrant/wp/wp-includes/plugin.php(453): WP_Hook->do_action(Array)
==> default: Notice: /Stage[main]/Main/Chassis::Wp[vagrant.local]/Chassis::Site[vagrant.local]/Wp::Site[/vagrant/wp]/Exec[wp install /vagrant/wp]/returns: #4 /vagrant/wp/wp-settings.php(449): do_action('init')
==> default: Notice: /Stage[main]/Main/Chassis::Wp[vagrant.local]/Chassis::Site[vagrant.local]/Wp::Site[/vagrant/wp]/Exec[wp install /vagrant/wp]/returns: #5 phar:///usr/local/src/wp-cli/bin/wp/php/WP_CLI/Runner.php(1008): require('/vagrant/wp/wp-...')
==> default: Notice: /Stage[main]/Main/Chassis::Wp[vagrant.local]/Chassis::Site[vagrant.local]/Wp::Site[/vagrant/wp]/Exec[wp install /vagrant/wp]/returns: #6 phar:///usr/local/src/wp-cli/bin/wp/php/WP_CLI/Runner.php(945): WP_CLI\Runner->load_wordpress()
==> default: Notice: /Stage[main]/Main/Chassis::Wp[vagrant.local]/Chassis::Site[vagrant.local]/Wp::Site[/vagrant/wp]/Exec[wp install /vagrant/wp]/returns: #7 phar:///usr/local/src/wp-cli/bin/wp/php/wp-cli.php(21): WP_CLI\Runner->start()
==> default: Notice: /Stage[main]/Main/Chassis::Wp[vagrant.local]/Chassis::Site[vagrant.local]/Wp::Site[/vagrant/wp]/Exec[wp install /vagrant/wp]/returns: #8 phar:///usr/local/src/wp-cli/bin/wp/php/boot-phar.php(5): include('phar:///usr/loc...')
==> default: Notice: /Stage[main]/Main/Chassis::Wp[vagrant.local]/Chassis::Site[vagrant.local]/Wp::Site[/vagrant/wp]/Exec[wp install /vagrant/wp]/returns: #9 /usr/local/src/wp-cli/bin/wp(4): include('phar:///usr/loc...')
==> default: Notice: /Stage[main]/Main/Chassis::Wp[vagrant.local]/Chassis::Site[vagrant.local]/Wp::Site[/vagrant/wp]/Exec[wp install /vagrant/wp]/returns: #10 {main}
==> default: Notice: /Stage[main]/Main/Chassis::Wp[vagrant.local]/Chassis::Site[vagrant.local]/Wp::Site[/vagrant/wp]/Exec[wp install /vagrant/wp]/returns:   thrown in /vagrant/local-config-hosts.php on line 39
==> default: Notice: /Stage[main]/Main/Chassis::Wp[vagrant.local]/Chassis::Site[vagrant.local]/Wp::Site[/vagrant/wp]/Exec[wp install /vagrant/wp]/returns: Fatal error: Uncaught Error: Call to undefined function Chassis\Hosts\get_sites() in /vagrant/local-config-hosts.php:39
==> default: Notice: /Stage[main]/Main/Chassis::Wp[vagrant.local]/Chassis::Site[vagrant.local]/Wp::Site[/vagrant/wp]/Exec[wp install /vagrant/wp]/returns: Stack trace:
==> default: Notice: /Stage[main]/Main/Chassis::Wp[vagrant.local]/Chassis::Site[vagrant.local]/Wp::Site[/vagrant/wp]/Exec[wp install /vagrant/wp]/returns: #0 /vagrant/local-config-hosts.php(26): Chassis\Hosts\write_hosts()
==> default: Notice: /Stage[main]/Main/Chassis::Wp[vagrant.local]/Chassis::Site[vagrant.local]/Wp::Site[/vagrant/wp]/Exec[wp install /vagrant/wp]/returns: #1 /vagrant/wp/wp-includes/class-wp-hook.php(298): Chassis\Hosts\maybe_add_host('')
==> default: Notice: /Stage[main]/Main/Chassis::Wp[vagrant.local]/Chassis::Site[vagrant.local]/Wp::Site[/vagrant/wp]/Exec[wp install /vagrant/wp]/returns: #2 /vagrant/wp/wp-includes/class-wp-hook.php(323): WP_Hook->apply_filters(NULL, Array)
==> default: Notice: /Stage[main]/Main/Chassis::Wp[vagrant.local]/Chassis::Site[vagrant.local]/Wp::Site[/vagrant/wp]/Exec[wp install /vagrant/wp]/returns: #3 /vagrant/wp/wp-includes/plugin.php(453): WP_Hook->do_action(Array)
==> default: Notice: /Stage[main]/Main/Chassis::Wp[vagrant.local]/Chassis::Site[vagrant.local]/Wp::Site[/vagrant/wp]/Exec[wp install /vagrant/wp]/returns: #4 /vagrant/wp/wp-settings.php(449): do_action('init')
==> default: Notice: /Stage[main]/Main/Chassis::Wp[vagrant.local]/Chassis::Site[vagrant.local]/Wp::Site[/vagrant/wp]/Exec[wp install /vagrant/wp]/returns: #5 phar:///usr/local/src/wp-cli/bin/wp/php/WP_CLI/Runner.php(1008): require('/vagrant/wp/wp-...')
==> default: Notice: /Stage[main]/Main/Chassis::Wp[vagrant.local]/Chassis::Site[vagrant.local]/Wp::Site[/vagrant/wp]/Exec[wp install /vagrant/wp]/returns: #6 phar:///usr/local/src/wp-cli/bin/wp/php/WP_CLI/Runner.php(945): WP_CLI\Runner->load_wordpress()
==> default: Notice: /Stage[main]/Main/Chassis::Wp[vagrant.local]/Chassis::Site[vagrant.local]/Wp::Site[/vagrant/wp]/Exec[wp install /vagrant/wp]/returns: #7 phar:///usr/local/src/wp-cli/bin/wp/php/wp-cli.php(21): WP_CLI\Runner->start()
==> default: Notice: /Stage[main]/Main/Chassis::Wp[vagrant.local]/Chassis::Site[vagrant.local]/Wp::Site[/vagrant/wp]/Exec[wp install /vagrant/wp]/returns: #8 phar:///usr/local/src/wp-cli/bin/wp/php/boot-phar.php(5): include('phar:///usr/loc...')
==> default: Notice: /Stage[main]/Main/Chassis::Wp[vagrant.local]/Chassis::Site[vagrant.local]/Wp::Site[/vagrant/wp]/Exec[wp install /vagrant/wp]/returns: #9 /usr/local/src/wp-cli/bin/wp(4): include('phar:///usr/loc...')
==> default: Notice: /Stage[main]/Main/Chassis::Wp[vagrant.local]/Chassis::Site[vagrant.local]/Wp::Site[/vagrant/wp]/Exec[wp install /vagrant/wp]/returns: #10 {main}
==> default: Notice: /Stage[main]/Main/Chassis::Wp[vagrant.local]/Chassis::Site[vagrant.local]/Wp::Site[/vagrant/wp]/Exec[wp install /vagrant/wp]/returns:   thrown in /vagrant/local-config-hosts.php on line 39
==> default: Error: /usr/bin/wp core install --url='http://vagrant.local/' --title='WordPress Site' --admin_email='[email protected]' --admin_name='admin' --admin_password='password' returned 255 instead of one of [0]
==> default: Error: /Stage[main]/Main/Chassis::Wp[vagrant.local]/Chassis::Site[vagrant.local]/Wp::Site[/vagrant/wp]/Exec[wp install /vagrant/wp]/returns: change from notrun to 0 failed: /usr/bin/wp core install --url='http://vagrant.local/' --title='WordPress Site' --admin_email='[email protected]' --admin_name='admin' --admin_password='password' returned 255 instead of one of [0]
==> default: Notice: /Stage[main]/Main/Chassis::Wp[vagrant.local]/File[/vagrant/local-config-extensions.php]/content: content changed '{md5}581fb6d4b83b547e89f5cb2bd4d004ce' to '{md5}47ee3e8cf0ef103ad8ed8aef19a9d0fe'
==> default: Notice: /Stage[main]/Chassis/File[/etc/nginx/nginx.conf]/content: content changed '{md5}63ffd8673a37159cae0974918625189c' to '{md5}e0e3b649b7fdf636f726ec41ecdc380d'
==> default: Notice: /Stage[main]/Main/Chassis::Wp[vagrant.local]/Chassis::Site[vagrant.local]/File[/etc/nginx/sites-available/vagrant.local]/ensure: defined content as '{md5}439d41d40de082502c710c1dbcf0fa91'
==> default: Notice: /Stage[main]/Main/Chassis::Wp[vagrant.local]/Chassis::Site[vagrant.local]/File[/etc/nginx/sites-enabled/vagrant.local]/ensure: created
==> default: Notice: /Stage[main]/Chassis/Service[nginx]/ensure: ensure changed 'stopped' to 'running'
==> default: Notice: Finished catalog run in 181.34 seconds

I've tried a few things including adding some logic to run different unless commands for multisite. e.g. unless => '/usr/bin/wp core is-installed --network' and trying to use wp core multisite-convert but that command does seem to create the tables for me even though that's in the docs

I'll try and have a think about this over the next few days and see if I can figure out a solution. 🤔

@BronsonQuick
Copy link
Member

Props to @stuartshields for reminding me that he had trouble with $_SERVER['HTTP_HOST'] in his extension. We've got a check for this which is incorrect at the moment. Correcting the check means I can run the wp core multisite-convert command.

chassisvip__fish__vagrantcontent__ssh__vagrant_ssh_2017-02-04_16-54-30

I'll open a new issue and PR for that part now. Props @stuartshields!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants