From 27458805bf8e70d594ed9fe8fcd0462a2c11e011 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Fri, 27 May 2016 19:19:57 -0700 Subject: [PATCH] bin/regen.sh - Run DatabaseInitializer (first boot) before GenerateData The DatabaseInitializer is called during first boot (`CRM_Core_Config::singleton()`) and runs `system.flush session=1 triggers=1` which (among other things) enumerates modules (including CMS modules). In standalone boot protocol, that means it runs before `CRM_Utils_System::loadBootstrap()` (which means that CMS modules cannot be enumerated yet). A simple work-around is to always boot the CMS first (before `CRM_Core_Config::singleton()` or `DatabaseInitializer` runs). --- bin/regen.sh | 9 +++++---- bin/setup.lib.sh | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/bin/regen.sh b/bin/regen.sh index 3090f14da9..f975c2e88a 100755 --- a/bin/regen.sh +++ b/bin/regen.sh @@ -41,12 +41,13 @@ $MYSQLCMD < civicrm_data.mysql $MYSQLCMD < civicrm_sample.mysql echo "DROP TABLE IF EXISTS zipcodes" | $MYSQLCMD $MYSQLCMD < zipcodes.mysql -env CIVICRM_UF=UnitTests php GenerateData.php -# run the cli script to build the menu and the triggers -cd $CIVISOURCEDIR -"$PHP5PATH"php bin/cli.php -e System -a flush --triggers 1 --session 1 +## For first boot on fresh DB, boot CMS before CRM. +cms_eval 'civicrm_initialize();' + +php GenerateData.php +## Prune local data $MYSQLCMD -e "DROP TABLE zipcodes; DROP TABLE IF EXISTS civicrm_install_canary; UPDATE civicrm_domain SET config_backend = NULL; DELETE FROM civicrm_extension; DELETE FROM civicrm_cache; DELETE FROM civicrm_setting;" TABLENAMES=$( echo "show tables like 'civicrm_%'" | $MYSQLCMD | grep ^civicrm_ | xargs ) diff --git a/bin/setup.lib.sh b/bin/setup.lib.sh index d98f2f52e2..e385acfa70 100644 --- a/bin/setup.lib.sh +++ b/bin/setup.lib.sh @@ -55,3 +55,20 @@ function has_commands() { done return 0 } + +## Execute some PHP within CMS context +## usage: cms_eval '' +function cms_eval() { + case "$GENCODE_CMS" in + Drupal*) + drush ev "$1" + ;; + WordPress*) + wp eval "$1" + ;; + *) + echo "Cannot boot (GENCODE_CMS=$GENCODE_CMS)" > /dev/stderr + exit 1 + ;; + esac +} -- 2.25.1