From f07bf72bcd5d7107c6f1aeeb042eb8b06cf8cee3 Mon Sep 17 00:00:00 2001 From: Scott Walkinshaw Date: Sat, 7 May 2016 00:09:06 -0400 Subject: [PATCH] Fix #581 - Use WP-CLI to run WP cron https://github.com/roots/trellis/pull/533 caused a regression in the cron job which runs `wp-cron.php`. Since `wp_home` and `wp_siteurl` were changed to use bash and PHP variables, the cron command wouldn't work. The solution is to avoid this and use WP-CLI's `cron` command for running due cron events. --- CHANGELOG.md | 1 + roles/wordpress-setup/tasks/main.yml | 2 +- roles/wp-cli/defaults/main.yml | 2 +- roles/wp-cli/tasks/main.yml | 1 + 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d19d317bd3..92d5a93e25 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ ### HEAD +* Fix #581 - Use WP-CLI to run WP cron ([#583](https://github.com/roots/trellis/pull/583)) * Require explicit redirects and drop www_redirect ([#622](https://github.com/roots/trellis/pull/622)) * Fix #612 - Bump nginx_fastcgi_buffer_size to `8k` ([#620](https://github.com/roots/trellis/pull/620)) * Setup permalink structure for multisite installs too ([#617](https://github.com/roots/trellis/pull/617)) diff --git a/roles/wordpress-setup/tasks/main.yml b/roles/wordpress-setup/tasks/main.yml index 2d4fcdff61..93a1aeca8c 100644 --- a/roles/wordpress-setup/tasks/main.yml +++ b/roles/wordpress-setup/tasks/main.yml @@ -30,7 +30,7 @@ name: "{{ item.key }} WordPress cron" minute: "*/15" user: "{{ web_user }}" - job: "curl -k -s {{ site_env.wp_siteurl }}/wp-cron.php > /dev/null 2>&1" + job: "cd {{ www_root }}/{{ item.key }}/{{ item.value.current_path | default('current') }} && wp cron event run --due-now" cron_file: "wordpress-{{ item.key | replace('.', '_') }}" with_dict: "{{ wordpress_sites }}" when: site_env.disable_wp_cron and not item.value.multisite.enabled | default(false) diff --git a/roles/wp-cli/defaults/main.yml b/roles/wp-cli/defaults/main.yml index 7fb8e2df3c..437472c40c 100644 --- a/roles/wp-cli/defaults/main.yml +++ b/roles/wp-cli/defaults/main.yml @@ -1,4 +1,4 @@ -wp_cli_version: 0.23.1 +wp_cli_version: 0.24.0 wp_cli_bin_path: /usr/bin/wp wp_cli_phar_url: "https://github.com/wp-cli/wp-cli/releases/download/v{{ wp_cli_version }}/wp-cli-{{ wp_cli_version }}.phar" wp_cli_completion_url: "https://raw.githubusercontent.com/wp-cli/wp-cli/v{{ wp_cli_version }}/utils/wp-completion.bash" diff --git a/roles/wp-cli/tasks/main.yml b/roles/wp-cli/tasks/main.yml index d4bfadd4f6..5827479283 100644 --- a/roles/wp-cli/tasks/main.yml +++ b/roles/wp-cli/tasks/main.yml @@ -3,6 +3,7 @@ get_url: url: "{{ wp_cli_phar_url }}" dest: "{{ wp_cli_bin_path }}" + force: true mode: 0755 - name: Retrieve WP-CLI tab completions