You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
wp db size doesn't like if-statements in wp-config.php #76
If I have any defines after that section, any time I run wp db size I'll get this:
$ wp db size
PHP Notice: Constant Mika_Test already defined in /usr/local/wp/php/WP_CLI/Runner.php(1070) : eval()'d code on line 99
Notice: Constant Mika_Test already defined in /usr/local/wp/php/WP_CLI/Runner.php(1070) : eval()'d code on line 99
+------------------+-------+
| Name | Size |
+------------------+-------+
| my_test_domain | 40 MB |
+------------------+-------+
My suspicion is that you're loading your wp-config.php twice, but you're only getting redefinition errors because of this after enabling the error reporting in your above conditional. So, I don't think the conditional is the cause, but rather the thing that enables you to see the symptoms after that point.
Now, why would your wp-config.php be loaded twice?
I have to assume this is a problem of your environment, not of WP-CLI source code, so I'm closing this for now. But please ping me on the Slack #cli team to discuss and debug further. If we should indeed locate a bug, I'll reopen of course.
Note there was a hack used to call Runner::load_wordpress() in the db commands db size, db prefix and db search with error suppression in WP-CLI 1.4.1 to make sure $wpdb was available, even though Runner::get_wp_config_code() had already been called, so that's why wp-config.php is getting loaded twice.
However you should get the same error running db prefix or db search.
@Ipstenu Can you try the same command with the nightly to check whether the error is gone for you? It should already be fixed with the current master code...
Activity
schlessera commentedon Jan 6, 2018
I cannot reproduce this behavior.
Is it possible to post the entire
wp-config.phpfile (without any sensitive information) ?Also what version are you running (
wp cli info) ?Ipstenu commentedon Jan 7, 2018
The rest of the wp-config.php that's abnormal are defines like this:
schlessera commentedon Jan 8, 2018
My suspicion is that you're loading your
wp-config.phptwice, but you're only getting redefinition errors because of this after enabling the error reporting in your above conditional. So, I don't think the conditional is the cause, but rather the thing that enables you to see the symptoms after that point.Now, why would your
wp-config.phpbe loaded twice?I have to assume this is a problem of your environment, not of WP-CLI source code, so I'm closing this for now. But please ping me on the Slack #cli team to discuss and debug further. If we should indeed locate a bug, I'll reopen of course.
Ipstenu commentedon Jan 8, 2018
That was my thought, however...
It literally only happens when I run
wp db sizeIf I was loading it twice, it stands to reason that it would error every time, right?
schlessera commentedon Jan 8, 2018
Can you run the command
--debugto see where exactly the error message is thrown?gitlost commentedon Jan 8, 2018
Note there was a hack used to call
Runner::load_wordpress()in the db commandsdb size,db prefixanddb searchwith error suppression in WP-CLI 1.4.1 to make sure$wpdbwas available, even thoughRunner::get_wp_config_code()had already been called, so that's whywp-config.phpis getting loaded twice.However you should get the same error running
db prefixordb search.schlessera commentedon Jan 8, 2018
Ah, yes, @gitlost is right.
@Ipstenu Can you try the same command with the
nightlyto check whether the error is gone for you? It should already be fixed with the currentmastercode...Ipstenu commentedon Jan 8, 2018
Confirmed it happens using
db prefix- I'll spin up a box and update to nightly to test that as soon as I can.Ipstenu commentedon Jan 11, 2018
The first two tests I did make me think this will work. I'm rebuilding one of the exact sites from the field to be double sure :)
danielbachhuber commentedon Jan 16, 2018
Specifically, this was #57