wp-cli / maintenance-mode-command

Activates, deactivates or checks the status of the maintenance mode of a site.
MIT License
9 stars 5 forks source link

PHP Notice errors #10

Closed NasKar2 closed 3 years ago

NasKar2 commented 3 years ago

Bug Report

Is your bug report directly related to a specific command? Yes maintenance-mode

Describe the current, buggy behavior Fresh install of wordpress using the default twenty twenty theme no plugins When I run the command "wp --path="/usr/local/www/wordpress" maintenance-mode activate" from a wordpress jail with reverse proxy setup I get:

A clear and concise desc PHP Notice: Undefined index: HTTP_X_FORWARDED_PROTO in phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1197) : eval()'d code on line 3 PHP Notice: Constant AUTH_KEY already defined in phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1197) : eval()'d code on line 57 PHP Notice: Constant AUTH_SALT already defined in phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1197) : eval()'d code on line 61 ription of the behavior that produces a wrong result or error.

Remember to provide some context to make sure we're all on the same page when reasoning about this.

Describe how other contributors can replicate this bug In a FreeNAS 12.2 iocage jail I run the command "wp --path="/usr/local/www/wordpress" maintenance-mode activate"

PHP Notice: Undefined index: HTTP_X_FORWARDED_PROTO in phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1197) : eval()'d code on line 3 PHP Notice: Constant AUTH_KEY already defined in phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1197) : eval()'d code on line 57 PHP Notice: Constant AUTH_SALT already defined in phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1197) : eval()'d code on line 61 Enabling Maintenance mode... Success: Activated Maintenance mode.

Same error with deactivate

Describe what you would expect as the correct outcome No PHP Notice error messages

Let us know what environment you are running this on FreeNAS 12.2


OS: FreeBSD 12.2-RC3 FreeBSD 12.2-RC3 7c4ec6ff02c(HEAD) TRUENAS amd64
Shell:  /bin/csh
PHP binary: /usr/local/bin/php
PHP version:    7.4.12
php.ini used:   /usr/local/etc/php.ini
WP-CLI root dir:    phar://wp-cli.phar/vendor/wp-cli/wp-cli
WP-CLI vendor dir:  phar://wp-cli.phar/vendor
WP_CLI phar path:   /usr/local/www/wordpress
WP-CLI packages dir:    /root/.wp-cli/packages/
WP-CLI global config:   
WP-CLI project config:  
WP-CLI version: 2.4.0```

My wp-config.php

``<?php

// Using a reverse proxy.
define('FORCE_SSL_ADMIN', true);
if (strpos($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') !== false)
  $_SERVER['HTTPS']='on';

/**
 * The base configuration for WordPress
 *
 * The wp-config.php creation script uses this file during the
 * installation. You don't have to use the web site, you can
 * copy this file to "wp-config.php" and fill in the values.
 *
 * This file contains the following configurations:
 *
 * * MySQL settings
 * * Secret keys
 * * Database table prefix
 * * ABSPATH
 *
 * @link https://wordpress.org/support/article/editing-wp-config-php/
 *
 * @package WordPress
 */

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'wordpress' );

/** MySQL database username */
define( 'DB_USER', 'wordpress' );

/** MySQL database password */
define( 'DB_PASSWORD', '**********************' );

// Filesystem method.
define('FS_METHOD', 'direct');

/** MySQL hostname */
define( 'DB_HOST', 'localhost' );

/** Database Charset to use in creating database tables. */
define( 'DB_CHARSET', 'utf8' );

/** The Database Collate type. Don't change this if in doubt. */
define( 'DB_COLLATE', '' );

/**#@+
 * Authentication Unique Keys and Salts.
 *
 * Change these to different unique phrases!
 * You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
 * You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
 *
 * @since 2.6.0
 */
define( 'AUTH_KEY',         '****************************************************************' );
define( 'AUTH_KEY',         '****************************************************************' );
define( 'LOGGED_IN_KEY',    '****************************************************************' );
define( 'NONCE_KEY',        '****************************************************************' );
define( 'AUTH_SALT',        '****************************************************************' );
define( 'AUTH_SALT',        '****************************************************************' );
define( 'LOGGED_IN_SALT',   '****************************************************************' );
define( 'NONCE_SALT',       '****************************************************************' );

/**#@-*/

/**
 * WordPress Database Table prefix.
 *
 * You can have multiple installations in one database if you give each
 * a unique prefix. Only numbers, letters, and underscores please!
 */
$table_prefix = 'wp_';

/**
 * For developers: WordPress debugging mode.
 *
 * Change this to true to enable the display of notices during development.
 * It is strongly recommended that plugin and theme developers use WP_DEBUG
 * in their development environments.
 *
 * For information on other constants that can be used for debugging,
 * visit the documentation.
 *
 * @link https://wordpress.org/support/article/debugging-in-wordpress/
 */
define( 'WP_DEBUG', false );

if ( WP_DEBUG ) {
  @error_reporting( E_ALL );
  @ini_set( 'log_errors', true );
  @ini_set( 'log_errors_max_len', '0' );

  define( 'WP_DEBUG_LOG', true );
  define( 'WP_DEBUG_DISPLAY', false );
  define( 'CONCATENATE_SCRIPTS', false );
  define( 'SAVEQUERIES', true );
}

// WP Super Cache plugin support.
define('WP_CACHE', true);
define ('WPCACHEHOME', '/usr/local/www/wordpress/wp-content/plugins/wp-super-cache/');

// Redis plugin support.
define( 'WP_REDIS_SCHEME', 'unix' );
define( 'WP_REDIS_PATH', '/var/run/redis/redis.sock' );
define( 'WP_REDIS_CLIENT', 'phpredis' );

/* That's all, stop editing! Happy publishing. */

/** Absolute path to the WordPress directory. */
if ( ! defined( 'ABSPATH' ) ) {
    define( 'ABSPATH', __DIR__ . '/' );
}

/** Sets up WordPress vars and included files. */
require_once ABSPATH . 'wp-settings.php';``
NasKar2 commented 3 years ago

Changes to the wp-config.php fixed the errors.



if ( isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) && 'https' === $_SERVER['HTTP_X_FORWARDED_PROTO'] ) {
  $_SERVER['HTTPS']='on';
}

/**
 * The base configuration for WordPress
 *
 * The wp-config.php creation script uses this file during the
 * installation. You don't have to use the web site, you can
 * copy this file to "wp-config.php" and fill in the values.
 *
 * This file contains the following configurations:
 *
 * * MySQL settings
 * * Secret keys
 * * Database table prefix
 * * ABSPATH
 *
 * @link https://wordpress.org/support/article/editing-wp-config-php/
 *
 * @package WordPress
 */

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'wordpress' );

/** MySQL database username */
define( 'DB_USER', 'wordpress' );

/** MySQL database password */
define( 'DB_PASSWORD', '*****************************' );

// Filesystem method.
define('FS_METHOD', 'direct');

root@truenas[/mnt/v1/git/freenas-backup-wordpress]# cat /mnt/v1/apps/wordpress/files/wp-config.php
<?php

if ( isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) && 'https' === $_SERVER['HTTP_X_FORWARDED_PROTO'] ) {
  $_SERVER['HTTPS']='on';
}

/**
 * The base configuration for WordPress
 *
 * The wp-config.php creation script uses this file during the
 * installation. You don't have to use the web site, you can
 * copy this file to "wp-config.php" and fill in the values.
 *
 * This file contains the following configurations:
 *
 * * MySQL settings
 * * Secret keys
 * * Database table prefix
 * * ABSPATH
 *
 * @link https://wordpress.org/support/article/editing-wp-config-php/
 *
 * @package WordPress
 */

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'wordpress' );

/** MySQL database username */
define( 'DB_USER', 'wordpress' );

/** MySQL database password */
define( 'DB_PASSWORD', 'ooU@7H!*_61<%]GCu7' );

// Filesystem method.
define('FS_METHOD', 'direct');

/** MySQL hostname */
define( 'DB_HOST', 'localhost' );

/** Database Charset to use in creating database tables. */
define( 'DB_CHARSET', 'utf8' );

/** The Database Collate type. Don't change this if in doubt. */
define( 'DB_COLLATE', '' );

/**#@+
 * Authentication Unique Keys and Salts.
 *
 * Change these to different unique phrases!
 * You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
 * You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
 *
 * @since 2.6.0
 */
define( 'AUTH_KEY',         '****************************************************************' );
define( 'SECURE_AUTH_KEY',  '****************************************************************' );
define( 'LOGGED_IN_KEY',    '****************************************************************' );
define( 'NONCE_KEY',        '****************************************************************' );
define( 'AUTH_SALT',        '****************************************************************' );
define( 'SECURE_AUTH_SALT', '****************************************************************' );
define( 'LOGGED_IN_SALT',   '****************************************************************' );
define( 'NONCE_SALT',       '****************************************************************' );

/**#@-*/

/**
 * WordPress Database Table prefix.
 *
 * You can have multiple installations in one database if you give each
 * a unique prefix. Only numbers, letters, and underscores please!
 */
$table_prefix = 'wp_';

/**
 * For developers: WordPress debugging mode.
 *
 * Change this to true to enable the display of notices during development.
 * It is strongly recommended that plugin and theme developers use WP_DEBUG
 * in their development environments.
 *
 * For information on other constants that can be used for debugging,
 * visit the documentation.
 *
 * @link https://wordpress.org/support/article/debugging-in-wordpress/
 */
define( 'WP_DEBUG', false );

if ( WP_DEBUG ) {
  @error_reporting( E_ALL );
  @ini_set( 'log_errors', true );
  @ini_set( 'log_errors_max_len', '0' );

  define( 'WP_DEBUG_LOG', true );
  define( 'WP_DEBUG_DISPLAY', false );
  define( 'CONCATENATE_SCRIPTS', false );
  define( 'SAVEQUERIES', true );
}

// WP Super Cache plugin support.
define('WP_CACHE', true);
define ('WPCACHEHOME', '/usr/local/www/wordpress/wp-content/plugins/wp-super-cache/');

// Redis plugin support.
define( 'WP_REDIS_SCHEME', 'unix' );
define( 'WP_REDIS_PATH', '/var/run/redis/redis.sock' );
define( 'WP_REDIS_CLIENT', 'phpredis' );

/* That's all, stop editing! Happy publishing. */

/** Absolute path to the WordPress directory. */
if ( ! defined( 'ABSPATH' ) ) {
    define( 'ABSPATH', __DIR__ . '/' );
}

/** Sets up WordPress vars and included files. */
require_once ABSPATH . 'wp-settings.php';```