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

wp db size doesn't like if-statements in wp-config.php #76

Closed
Ipstenu opened this issue Jan 6, 2018 · 10 comments
Closed

wp db size doesn't like if-statements in wp-config.php #76

Ipstenu opened this issue Jan 6, 2018 · 10 comments
Labels

Comments

@Ipstenu
Copy link

Ipstenu commented Jan 6, 2018

I have the following in my wp-config.php file:

if ( WP_DEBUG ) {
        @error_reporting( E_ALL );
        @ini_set( 'log_errors', true );
        @ini_set( 'log_errors_max_len', '0' );
        if ( !defined('WP_DEBUG_LOG' ) ) define( 'WP_DEBUG_LOG', true );
        if ( !defined('WP_DEBUG_DISPLAY' ) ) define( 'WP_DEBUG_DISPLAY', false);
        if ( !defined('CONCATENATE_SCRIPTS' ) ) define( 'CONCATENATE_SCRIPTS', false );
        if ( !defined('SAVEQUERIES' ) ) define( 'SAVEQUERIES', true );
}

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 |
+------------------+-------+

However all other commands I've tested work.

If WP_DEBUG is false, there's no error.

@schlessera
Copy link
Member

I cannot reproduce this behavior.

Is it possible to post the entire wp-config.php file (without any sensitive information) ?

Also what version are you running ( wp cli info ) ?

@Ipstenu
Copy link
Author

Ipstenu commented Jan 7, 2018

PHP version:	5.6.31
php.ini used:	/etc/php56/php.ini
WP-CLI root dir:	/usr/local/wp
WP-CLI vendor dir:	/usr/local/wp/vendor
WP_CLI phar path:
WP-CLI packages dir:
WP-CLI global config:
WP-CLI project config:
WP-CLI version:	1.4.1

The rest of the wp-config.php that's abnormal are defines like this:

// Akismet - Mika's Key
define( 'WPCOM_API_KEY', 'SECRETKEY' );

// DreamObjects Keys - Mika's Keys
define( 'DHO_ACCESS_KEY_ID', 'SECRETKEY' );
define( 'DHO_SECRET_ACCESS_KEY', 'SECRET-KEY' );

// Amazon affiliate keys - Mika's Keys
define( 'AMAZON_PRODUCT_API_KEY', 'SECRETKEY' );
define( 'AMAZON_PRODUCT_API_SECRET', 'SECRETKEY' );

// Limit revisions
define( 'WP_POST_REVISIONS', 3 );

define('JETPACK_IP_ADDRESS_OK', '12.34.56.78');

@schlessera
Copy link
Member

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.

@Ipstenu
Copy link
Author

Ipstenu commented Jan 8, 2018

That was my thought, however...

It literally only happens when I run wp db size

If I was loading it twice, it stands to reason that it would error every time, right?

@schlessera
Copy link
Member

Can you run the command --debug to see where exactly the error message is thrown?

@gitlost
Copy link
Contributor

gitlost commented Jan 8, 2018

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.

@schlessera
Copy link
Member

Ah, yes, @gitlost is right.

@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...

@Ipstenu
Copy link
Author

Ipstenu commented 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
Copy link
Author

Ipstenu commented 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
Copy link
Member

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...

Specifically, this was #57

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

No branches or pull requests

4 participants