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

db size does not work with Bedrock #23

Closed
chesio opened this issue Jun 6, 2017 · 4 comments
Closed

db size does not work with Bedrock #23

chesio opened this issue Jun 6, 2017 · 4 comments

Comments

@chesio
Copy link

chesio commented Jun 6, 2017

Hi,

I'm using Bedrock as project boilerplate, so wp-config.php in WordPress root directory acts only as loader for actual configuration files that are included via require_once.

When running wp db size, I get:

Error: The site you have requested is not installed.
Run `wp core install`.

For some reason, $table_prefix is not read from config. Here's the stack trace:

[06-Jun-2017 08:35:08 UTC] PHP Notice:  Undefined variable: table_prefix in /[...]/wordpress/wp-settings.php on line 110
[06-Jun-2017 08:35:08 UTC] PHP Stack trace:
[06-Jun-2017 08:35:08 UTC] PHP   1. {main}() /[...]/wp-cli/wp-cli.phar:0
[06-Jun-2017 08:35:08 UTC] PHP   2. include() /[...]/wp-cli/wp-cli.phar:4
[06-Jun-2017 08:35:08 UTC] PHP   3. include() phar:///[...]/wp-cli/wp-cli.phar/php/boot-phar.php:8
[06-Jun-2017 08:35:08 UTC] PHP   4. WP_CLI\bootstrap() phar:///[...]/wp-cli/wp-cli.phar/php/wp-cli.php:23
[06-Jun-2017 08:35:08 UTC] PHP   5. WP_CLI\Bootstrap\LaunchRunner->process($state = class WP_CLI\Bootstrap\BootstrapState { private $state = array (...) }) phar:///[...]/wp-cli/wp-cli.phar/php/bootstrap.php:75
[06-Jun-2017 08:35:08 UTC] PHP   6. WP_CLI\Runner->start() phar:///[...]/wp-cli/wp-cli.phar/php/WP_CLI/Bootstrap/LaunchRunner.php:23
[06-Jun-2017 08:35:08 UTC] PHP   7. WP_CLI\Runner->_run_command() phar:///[...]/wp-cli/wp-cli.phar/php/WP_CLI/Runner.php:883
[06-Jun-2017 08:35:08 UTC] PHP   8. WP_CLI\Runner->run_command($args = array (0 => 'db', 1 => 'size'), $assoc_args = array (), $options = *uninitialized*) phar:///[...]/wp-cli/wp-cli.phar/php/WP_CLI/Runner.php:328
[06-Jun-2017 08:35:08 UTC] PHP   9. WP_CLI\Dispatcher\Subcommand->invoke($args = array (), $assoc_args = array (), $extra_args = array ()) phar:///[...]/wp-cli/wp-cli.phar/php/WP_CLI/Runner.php:321
[06-Jun-2017 08:35:08 UTC] PHP  10. call_user_func:{phar:///[...]/wp-cli/wp-cli.phar/php/WP_CLI/Dispatcher/Subcommand.php:401}(class Closure { public $static = array (...); public $parameter = array (...) }, array (), array ()) phar:///[...]/wp-cli/wp-cli.phar/php/WP_CLI/Dispatcher/Subcommand.php:401
[06-Jun-2017 08:35:08 UTC] PHP  11. WP_CLI\Dispatcher\CommandFactory::WP_CLI\Dispatcher\{closure}($args = array (), $assoc_args = array ()) phar:///[...]/wp-cli/wp-cli.phar/php/WP_CLI/Dispatcher/Subcommand.php:401
[06-Jun-2017 08:35:08 UTC] PHP  12. call_user_func:{phar:///[...]/wp-cli/wp-cli.phar/php/WP_CLI/Dispatcher/CommandFactory.php:67}(array (0 => class DB_Command { ... }, 1 => 'size'), array (), array ()) phar:///[...]/wp-cli/wp-cli.phar/php/WP_CLI/Dispatcher/CommandFactory.php:67
[06-Jun-2017 08:35:08 UTC] PHP  13. DB_Command->size($args = array (), $assoc_args = array ()) phar:///[...]/wp-cli/wp-cli.phar/php/WP_CLI/Dispatcher/CommandFactory.php:67
[06-Jun-2017 08:35:08 UTC] PHP  14. WP_CLI\Runner->load_wordpress() /[...]/.wp-cli/packages/vendor/wp-cli/db-command/src/DB_Command.php:566
[06-Jun-2017 08:35:08 UTC] PHP  15. require() phar:///[...]/wp-cli/wp-cli.phar/php/WP_CLI/Runner.php:988

Some more observations:

  1. I have no problem running other commands, db size is the only one causing this issue.
  2. I'm using WP-CLI via phar downloadable, but I manually installed latest dev version of db-command package.
  3. If files in wp-config.php are included via require instead of require_once, the issue is gone.
@danielbachhuber
Copy link
Member

wp db size loads WordPress internally, which means it also requires wp-config.php a second time. The reason require works but require_once does not is because wp-config.php is loaded twice.

For now, you can use require. Eventually, we'll address this with #15

@chesio
Copy link
Author

chesio commented Jun 6, 2017

Ok, I see. Thanks for explanation!

@coreyworrell
Copy link

coreyworrell commented Nov 2, 2017

@danielbachhuber After following suggestion here to use require, running wp db size no longer throws an error, but it doesn't return anything. same for wp db prefix, no output. Any ideas why?

EDIT: nevermind, I had a function defined in the file, so I had to wrap it in function_exists() conditional. Leaving comment here for future reference for myself and others.

@danielbachhuber
Copy link
Member

@coreyworrell Also, for future reference:

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

No branches or pull requests

3 participants