-
-
Notifications
You must be signed in to change notification settings - Fork 83
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
CRM-20148 Fix WP-CLI installer #110
Conversation
It's not happy with the variable name `$crmPath`, but it shouldn't be touched since it's a global used elsewhere in CiviCRM. It also doesn't like silencing errors on running the `wp plugin activate civicrm` command.
@agh1 Thanks for working on this. I'll do the testing, to confirm the workflow. I install WP,wp-cli and the civicrm wp-cli script. I tell wp-cli to include the civicrm script and run the install? I ask as the bundled version won't work until the plugin is activated. |
There are two scenarios to work through. Both start with WP and WP-CLI installed. In the first, download CiviCRM manually, extract it into the plugins directory, and activate the CiviCRM plugin, but don't run the installer. Then try the first command above. WP-CLI should have the CiviCRM commands because the plugin is enabled. In the second, CiviCRM should not be in your site at all. Somewhere else on your machine you'll need the CiviCRM zip file (specified with The problem was that the command looked for the folder with To make the first use case work (installing a site that's already in place), I basically removed the check of whether the CiviCRM folder exists. For the second use case (unzip and install), I made the command not assume that the plugin path is where the script is. |
Thanks, I am so used to using the 'yml' config files I didn't see the 'require' command line switch. Apache 2.4, php 5.6.30 MySQL 5.7 running on a mac. I am having trouble with the script. The extract works But then nothing. CiviCRM is in the proper place If I run again: The plugin is neither activated nor installed. If I add Not sure why it's failing for me. Can you share details of your setup? |
Strange. I just tried it somewhere new just in case. Here's the complete procedure I used: Starting with a working Wordpress site on Ubuntu 16.04 with PHP 7 and MariaDB 5.5, I used I was using the same database and credentials as the WordPress site. There were no The response was
Going into WordPress, the site is working like normal. |
wp-cli/civicrm.php
Outdated
# create files dirs | ||
$upload_dir = wp_upload_dir(); | ||
$settings_dir = $upload_dir['basedir'] . DIRECTORY_SEPARATOR . 'civicrm' . DIRECTORY_SEPARATOR; | ||
civicrm_setup( "$settings_dir" ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This creates a directory structure of wp-content/uploads/civicrm/civicrm/
I would change to:
$userFilesDir = $upload_dir['basedir'] . DIRECTORY_SEPARATOR;
civicrm_setup( "$userFilesDir" );
We also get a wp-content/uploads/civicrm/files/ directory structure that does not happen in a normal install. While that will work, we should track that down to make the install consistent.
@agh1 Thanks for the feedback. I tested again both on an Ubuntu 16.04 server and locally on a LAMP stack on a Mac. If the site is http://installtest.dev the install works fine. If the site is https://installtest.dev the install fails. In addition line 380 I would change to:
We also get a wp-content/uploads/civicrm/files/ directory structure that does not happen in a normal install. While that will work, we should track that down to make the install consistent. |
wp-cli/civicrm.php
Outdated
} | ||
$params = array( | ||
'crmRoot' => $crmPath . '/', | ||
'templateCompileDir' => "{$settings_dir}files/civicrm/templates_c", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'templateCompileDir' => "{$settings_dir}templates_c",
Appears to be proper setting for 4.7
@agh1 can you look at the changes suggested and if you agree add to your branch? |
At long last I just incorporated the changes @kcristiano suggested, and I tested it with the following two scenarios, both starting with a just-installed WordPress site and no CiviCRM: Install from activated plugin
Install from zipfile and
|
Thanks @agh1 I'll run a test as soon as I can and would like to see this in the May release |
Retested and works perfectly. |
If @agh1 and @kcristiano like it, then that'll work for me. ;) |
The entity and action were also being parsed as an invalid parameter. This was fixed by shifting the args array after parsing them. An unassigned $format variable was being referenced inside of the default case for the switch statement if the --in option was neither args nor json. This was fixed by assigning $format to the output of getOption rather than switching on getOption directly. The parameter matching regex had spaces added to it in pull request civicrm#110 that caused arguments of the format foo=bar to not be matched correctly, so no parameters were actually being passed to the underlying api method. The spaces were removed from the regex and the parsing worked. Two other regex matches had spaces added to them by pull request civicrm#110 that I have not touched, but they seem suspect.
This pull request looks insane because of the style changes that I ran first because my editor was blowing up with PHP_CodeSniffer errors:
wp-cli/civicrm.php
was in neither CiviCRM/Drupal style nor WordPress style. This puts it in WordPress style.The real business in here comes in 5612d6f, with a couple additional things in 72202de, so it would probably be easier to browse through those.
The result works with the following two commands:
wp civicrm install --dbhost=localhost --dbname=XXXX --dbpass=XXXX --dbuser=XXXX --site_url=example.com
when CiviCRM is extracted in place and already activated in WordPress, andwp 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
when CiviCRM is not present but the WP-CLI file is at/somewhere/else/wp-cli/civicrm.php
.However, I have only run this on plain vanilla WordPress installs.
It would be nice to have @kcristiano's feedback to make sure it's consistent with setups I'm not aware of and with work he's doing to improve the installation process in WordPress.