Skip to content

Commit

Permalink
check_drupal_cron: Add workaround for existing MySQL client config
Browse files Browse the repository at this point in the history
On older versions of Drush 8.x, `drush state-get system.cron_last` fails
because the MySQL client config file takes precedence over Drupal's
settings.php file.

Related issue: drush-ops/drush#2183
  • Loading branch information
jonasdemoor committed Mar 22, 2019
1 parent d9fab17 commit 3c004ef
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions check_drupal-cron
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ else
fi
fi

# Workaround for https://github.com/drush-ops/drush/issues/2183.
# On older Drush 8.x versions, .my.cnf has preference over settings.php,
# which causes `drush state-get system.cron_last` to fail.
if [[ -f "${HOME}/.my.cnf" ]]
then
DRUSH_HOME="/tmp"
else
DRUSH_HOME="${HOME}"
fi

while getopts u:r:c:w: o; do
case "$o" in
Expand All @@ -34,10 +43,10 @@ DRUPAL_VERSION=$(${DRUSH} --root=${root} --uri=${uri} status | grep 'Drupal vers
if [[ "$DRUPAL_VERSION" =~ ^[6-7] ]]
then
# drupal 6/7
LAST_CRON_RUN=$(${DRUSH} --root=${root} --uri=${uri} vget '^cron_last$'|cut -d: -f 2)
LAST_CRON_RUN=$(HOME=${DRUSH_HOME} ${DRUSH} --root=${root} --uri=${uri} vget '^cron_last$'|cut -d: -f 2)
else
# other drupal versions
LAST_CRON_RUN=$(${DRUSH} --root=${root} --uri=${uri} state-get system.cron_last)
LAST_CRON_RUN=$(HOME=${DRUSH_HOME} ${DRUSH} --root=${root} --uri=${uri} state-get system.cron_last)
fi

DELTA=$(($NOW - $LAST_CRON_RUN))
Expand Down

0 comments on commit 3c004ef

Please sign in to comment.