I have a network of over a hundred sites and I try to use wp-cli to make bulk changes to many of these. Particularly to their wp_x_options table via wp --url=site.url option update

However, wp commands fail with several of my files, severely limiting the usefulness of the tool, particularly when trying to run with a list of urls | xargs wp --url={} ... because after the first failure, the rest are skipped.

The error I get is always the same:

PHP Parse error: syntax error, unexpected end of file in ... /functions.php

This error does not happen when loading the pages normally via the browser. My functions.php files are perfectly OK. Some of them don't have a closing ?> tag but that can't be the problem since many of these (lacking closing ?>) run OK with wp-cli.

Any thoughts?

WP-CLI 0.18.0 Wordpress 4.0.1 PHP 5.5.9-1ubuntu4.4 (cli) php.ini has error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT display_errors = Off

As noted in https://github.com/wp-cli/wp-cli/issues/1754#issuecomment-91361340, I figured this one out. It turns out it wasn't wp-cli's fault at all.

My confusion arose from the fact that I'm running a web server with nginx and php fpm, which has it's own php.ini . wp commands run php (cli) directly on the host and so the config can be different. In this case my php cli didn't allow short_open_tag (

Solution

Just enabled

short_open_tag=On

in /etc/php5/cli/php.ini p.s. this is an aws ubuntu box

  • You would be better off to find the files in your system using short PHP tags and change them to not do that. Disabling short_open_tag everywhere is recommended for clarity. Short tags are bad practice due to portability, and additionally they don't adhere to the PHP basic coding standard PSR-1. – Otto Apr 9 '15 at 22:48
  • Thanks, I'm aware but it's not obvious how to do that in thousands of files reliably without having to supervise the whole process, which is not my role :) – Jorge Orpinel Apr 10 '15 at 23:14

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.