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

syntax error, unexpected 'if' (T_IF) in phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1309) : eval()'d code on line 184 #5808

Open
Danrancan opened this issue Jun 25, 2023 · 2 comments

Comments

@Danrancan
Copy link

Danrancan commented Jun 25, 2023

Bug Report

Describe the current, buggy behavior
When running any command from wp cli, I get the following error:

PHP Parse error:  syntax error, unexpected 'if' (T_IF) in phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1309) : eval()'d code on line 184

I am running wordpress cli on a Ubuntu based LEMP server. My wordpress folder is located at /var/www/example.com.
All of my wordpress files and folders are owned by www-data:www-data except for wp-config.php which is owned by root:root. All of my folders have drwxr-xr-x permissions, and all of my files have -rw-r--r-- permissions, except my wp-config.php file which has -rw-r--r-- permissions.
My wp cli file is located in /usr/local/bin/wp and it is owned by www-data:www-data.

When i run any command including the examples below:

sudo -u www-data wp info
sudo -u www-data wp help cron
wp info
wp help cron

I get the following error:

PHP Parse error:  syntax error, unexpected 'if' (T_IF) in phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(1309) : eval()'d code on line 184

Describe how other contributors can replicate this bug

  • You can replicate this by just running any wp cli command in your wordpress directory on Ubuntu 20.04 server

Describe what you expect as the correct outcome

I expect the command to work.

Let us know what environment you are running this on
Ubuntu 20.04 Server on a Raspberry Pi 4 LEMP server.
PHP v7.4
Nginx v1.25.1 Mainline
MariaDB/Mysql Ver 15.1

OS:	Linux 5.4.0-1088-raspi #99-Ubuntu SMP PREEMPT Thu Jun 8 06:16:53 UTC 2023 aarch64
Shell:	/usr/sbin/nologin
PHP binary:	/usr/bin/php7.4
PHP version:	7.4.3-4ubuntu2.18
php.ini used:	/etc/php/7.4/cli/php.ini
MySQL binary:	/usr/bin/mysql
MySQL version:	mysql  Ver 15.1 Distrib 10.10.5-MariaDB, for debian-linux-gnu (aarch64) using readline 5.2
SQL modes:
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:	/var/www/example.com
WP-CLI packages dir:
WP-CLI cache dir:	/var/www/.wp-cli/cache
WP-CLI global config:
WP-CLI project config:
WP-CLI version:	2.8.1
@danielbachhuber
Copy link
Member

Thanks for the report, @Danrancan

My hunch is that you have a syntax error in your wp-config.php file. Can you share its contents, with any secrets redacted?

@Danrancan
Copy link
Author

Danrancan commented Aug 19, 2023

Sorry this took so long @danielbachhuber. Here you go!

<?php

/**
 * 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', '******' );
/** MySQL database username */
define( 'DB_USER', '******' );
/** MySQL database password */
define( 'DB_PASSWORD', '***********' );
/** MySQL hostname */
//define( 'DB_HOST', '******' );
// Force connection via UNIX Socket instead of TCPIP for added performance and security
define( 'DB_HOST', 'localhost:/run/mysqld/mysqld.sock' );
/** 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_';
//
//////////////////////////////////////////////////////////////////////////
// Add any custom values between this line and the "stop editing" line. //
//////////////////////////////////////////////////////////////////////////
//
// DEFAULTS //
//
// Set the Default Theme for Wordpress
define( 'WP_DEFAULT_THEME', 'twentytwenty' );
//
// Set up WP_HOME, WP_SITEURL, and HTTP_HOST to fix errors in WP CLI.
// These lines bellow will get these 3 variables assigned correctly and
// the WP-CLI warnings will disappear...
// ref: https://stackoverflow.com/questions/54805881/wp-cli-avoid-undefined-index-http-host-when-using-http-host-in-wp-config-php
//if ( defined( 'WP_CLI' ) && WP_CLI ) {
//  $_SERVER['HTTP_HOST'] = $_SERVER['SERVER_NAME'] = 'www.example.com';
//}
//
// Set up Wordpress default home & site url Paths
define( 'WP_HOME', 'https://www.example.com' );
define( 'WP_SITEURL', 'https://www.example.com' );
//
// SECURITY //
//
// https://wordpress.org/documentation/article/hardening-wordpress/
// Note that wp-config.php can be stored ONE directory level above the WordPress (where wp-includes resides)
// installation. Also, make sure that only you (and the web server) can read this file
// (it generally means a 400 or 440 permission).
// Dissallow file editing
// The WordPress Dashboard by default allows administrators to edit PHP files, such as
// plugin and theme files. This is often the first tool an attacker will use if able to
// login, since it allows code execution. WordPress has a constant to disable editing
// from Dashboard. Placing this line in wp-config.php is equivalent to removing the
// edit_themes’, ‘edit_plugins’ and ‘edit_files’ capabilities of all users.
// Disable File editing = true, Enable File Editing = false */
define('DISALLOW_FILE_EDIT', true);
//
// Require SSL for Admin and logins
define( 'FORCE_SSL_ADMIN', true );
//
// Disable Debugging
// 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 at
// https://wordpress.org/support/article/debugging-in-wordpress/
// Disable debugging = false, Enable Debugging = true */
//define( 'WP_DEBUG', false );
//
// DEBUGGING //
//
// Enable WP_DEBUG mode (Remember to disable WP_DEBUG=false in the above security section)
//define( 'WP_DEBUG', true );
//define('WP_ALLOW_REPAIR', true);
//
// Enable Debug logging to the /wp-content/debug.log file
//define( 'WP_DEBUG_LOG', true );
//
// Change Debug log file path
//define( 'WP_DEBUG_LOG', '/var/log/wordpress/example.com.error.log' );
//
// Disable display of errors and warnings
//define( 'WP_DEBUG_DISPLAY', false );
//@ini_set( 'display_errors', 0 );
//
// Use dev versions of core JS and CSS files (only needed if you are modifying these core files or trying to debug a wp plugin or javascript): default is true
//define( 'SCRIPT_DEBUG', true );
//
// CACHING //
//
// Allow flyingpress to cache pages
//define('WP_CACHE', true); // Added by FlyingPress
//
// Allow Nginx Helper Plugin to purge cache without ngx_cache_purge module
//define('RT_WP_NGINX_HELPER_CACHE_PATH', '/var/www/fastcgi_cache/example.com');
define('RT_WP_NGINX_HELPER_CACHE_PATH', '/var/www/cache/fastcgi_cache/example.com');
//
// PLUGINS //
//
// PLUGIN - Error Log Monitor
// Enable error logging for error log monitor plugin
// Dont forget to comment out "WP_DEBUG=false" in the // SECURITY settings when enabling this plugin
// Don't forget to uncomment "WP_DEBUG=false" in the // SECURITY settings when disabling this plugin
define( 'WP_DEBUG', true );
@ini_set('log_errors', 'On');
@ini_set('error_log', '/var/log/wordpress/example.com.error_log_monitor.php.error.log');
//
// Don't show errors to site visitors.
@ini_set('display_errors', 'Off');
if ( !defined('WP_DEBUG_DISPLAY') ) {
	define('WP_DEBUG_DISPLAY', false);
}
//
// PLUGIN - WP-Offload-Media
// This code will connect wordpress to your AWS S3 Storage for
// offloading Video Files to Amazon.
define( 'AS3CF_SETTINGS', serialize( array(
    'provider' => 'aws',
    'access-key-id' => '****************',
    'secret-access-key' => '****************************',
) ) );
//
// OTHER //
//
// Automatic Databse Optimizing (use this temporarily, when wordpress is corrupt)
//define( 'WP_ALLOW_REPAIR', true );
//
// Set the environment type (local, development, staging, production)
define( 'WP_ENVIRONMENT_TYPE', 'production' );
//
// Enable php execution time other than 0
set_time_limit(7200);
//
// Fix To WordPress Asking For FTP Credentials during update - Force Direct Filesystem Method
// https://gigapress.net/wordpress-asking-for-ftp-credentials/
define('FS_METHOD','direct');
//
// Change the autosave interval in Wordpress
//define( 'AUTOSAVE_INTERVAL', 210 ); // = every five minutes
//
// Increase max ram usage in Wordpress (only necessary for example2.com=64M, & example3.com=256M)
//define('WP_MEMORY_LIMIT', '64M');
//
// Deactivate Wordpress Cron in favor of real cron jobs
define( 'DISABLE_WP_CRON', true );
//
//////////////////////////////////////////////////////////////////////////////////////////////
/////////////////// 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';

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

No branches or pull requests

2 participants