Notice: Undefined index: REQUEST_SCHEME in thrown in WP-CLI
-
After installing WordPress via Quick app, in config file it adds two lines:
define('WP_SITEURL', $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST']); define('WP_HOME', $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST']);
Because of that, In WP CLI we receive notice while executing commands:
$ wp plugin activate woocommerce Notice: Undefined index: REQUEST_SCHEME in phar://C:/laragon/usr/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1150) : eval()'d code on line 29 Call Stack: 0.2760 393544 1. {main}() C:\laragon\usr\bin\wp:0 0.4327 879272 2. include('phar://C:/laragon/usr/bin/wp/php/boot-phar.php') C:\laragon\usr\bin\wp:4 0.4462 886408 3. include('phar://C:/laragon/usr/bin/wp/vendor/wp-cli/wp-cli/php/wp-cli.php') phar://C:/laragon/usr/bin/wp/php/boot-phar.php:11 0.4556 897896 4. WP_CLI\bootstrap() phar://C:/laragon/usr/bin/wp/vendor/wp-cli/wp-cli/php/wp-cli.php:23 1.2518 8162048 5. WP_CLI\Bootstrap\LaunchRunner->process() phar://C:/laragon/usr/bin/wp/vendor/wp-cli/wp-cli/php/bootstrap.php:74 1.2519 8162088 6. WP_CLI\Runner->start() phar://C:/laragon/usr/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Bootstrap/LaunchRunner.php:23 1.2646 8162992 7. WP_CLI\Runner->load_wordpress() phar://C:/laragon/usr/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php:1111 1.3066 8180096 8. eval('/** ... ... ... ') phar://C:/laragon/usr/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php:1150 Plugin 'woocommerce' activated. Success: Activated 1 of 1 plugins.
-
This was the code added after define to MySQL DB Password:
/** MySQL database password */ define('DB_PASSWORD', ''); define('WP_SITEURL', $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST']); define('WP_HOME', $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST']);
Now removing above laragon define for site URL and moving them after
DB_COLLATE
with check forWP_CLI
resolves my problem/** The Database Collate type. Don't change this if in doubt. */ define('DB_COLLATE', ''); /** Sets up WordPress URL. */ if ( ! defined( 'WP_CLI' ) ) { define( 'WP_SITEURL', $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'] ); define( 'WP_HOME', $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'] ); }
What I have done here is that, I have checked if
WP_CLI
has not been defined or not. Another cool stuff I suggest is please add those lines afterDB_COLLATE
and not afterDB_PASSWORD
because tillDB_COLLATE
those configs are for Database and placing Advanced URL options configurations in the middle of Database configs in not highly appreciated
-
@shivapoudel : You must be a WordPress guru!
You are right. I will fix it in the next version of Laragon. Thanks!
-
Is there any possibilities I could contribute this kind of changes in laragon in GitHub or somewhere else?
-
When will this be shipped
-
@shivapoudel : I fixed it and will release Laragon soon.
-
@shivapoudel : I've released Laragon 4.0.4 which fixed the issue.
Many thanks for your information!
-
@leokhoa You can mark solved for this thread
-
I created WordPress installation using QuickApp. Also, I'm using Apache with SSL enabled.
The problem is that both "WordPress Address (URL)" and "Site Address (URL)" are greyed out after installation so I had to manually remove following code from wp-config.php:
if ( ! defined( 'WP_CLI' ) ) { define( 'WP_SITEURL', $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'] ); define( 'WP_HOME', $_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'] ); }
Both fields became editable so I was able to switch the site to https. But the problem is that front end doesn't redirect to https anymore like my older sites.
Is there a simple way to fix this for future installations?
-
@matija I'm having a similar problem. I am using laragon with ssl. I change the database values directly to use https. This leaves the wordpress settings general page to gray out these values with http. So it looks as if the wp_config.php is overriding my database values. I don't uncerstand but it seems like there is a bug somewhere here. Like maybe $_SERVER['REQUEST_SCHEME']should return https.