Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-20148

WP-CLI installer won't run if it can be run

    Details

    • Versioning Impact:
      Patch (backwards-compatible bug fixes)
    • Documentation Required?:
      User and Admin Doc
    • Funding Source:
      Contributed Code
    • Verified?:
      No

      Description

      WP-CLI has an option to install CiviCRM, but as far as I can tell, it is impossible to run it successfully. To oversimplify, the command needs the CiviCRM plugin to be active, but the command will fail if the CiviCRM plugin is present.

      The problem

      The way the installer is meant to run is by specifying a zip file with CiviCRM. The command extracts the file into place and then runs the install script. However, the first step is to check if the plugin directory is present; if so, the script stops. In order to run `wp civicrm install` or any CiviCRM WP-CLI command, the plugin needs to be present or you need to be manually requiring the `wp-cli/civicrm.php` file.

      I tried putting wp-cli/civicrm.php somewhere else and using `--require=/path/to/wp-cli/civicrm.php`, but the way the script runs, it assumes that the install path is the path to the plugin containing the file. There's a catch-22: line 314 gets the plugin directory containing the script, while line 321 says that if that directory exists, we should quit because CiviCRM is already installed. I tried fiddling with the `destination` argument, but there was trouble unzipping the file.

      Proposed solution

      There are really two ways one might want to use this command:

      • CiviCRM is extracted and the plugin is enabled; you just want to run the install script
      • You have a zip file and want to extract and install CiviCRM. While CiviCRM isn't present, you've stashed the wp-cli/civicrm.php script somewhere so you can require it as part of the command.

      I've made changes so that both situations work. The commands I've tested are (in the first case):

      wp civicrm install --dbhost=localhost --dbname=XXXX --dbpass=XXXX --dbuser=XXXX --site_url=example.com
      

      and (in the second case):

      wp civicrm install --dbhost=localhost --dbname=XXXX --dbpass=XXXX --dbuser=XXXX --site_url=example.com --zipfile=/path/to/civicrm-4.7.16-wordpress.zip --require=/somewhere/else/wp-cli/civicrm.php
      

        Attachments

          Activity

            People

            • Assignee:
              timotten Tim Otten
              Reporter:
              andrewhunt Andrew Hunt
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: