bin/regen.sh - Run DatabaseInitializer (first boot) before GenerateData
authorTim Otten <totten@civicrm.org>
Sat, 28 May 2016 02:19:57 +0000 (19:19 -0700)
committerTim Otten <totten@civicrm.org>
Sat, 28 May 2016 02:19:57 +0000 (19:19 -0700)
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
bin/setup.lib.sh

index 3090f14da9d025da93ad91e4f6ab80cb5e4a9634..f975c2e88aa67d8c582a3de2e854b96d61c973c3 100755 (executable)
@@ -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 )
 
index d98f2f52e27b1bcb1a9baf6719fb2720f8f16225..e385acfa709b4839f9a846f2746418da6fb6e800 100644 (file)
@@ -55,3 +55,20 @@ function has_commands() {
   done
   return 0
 }
+
+## Execute some PHP within CMS context
+## usage: cms_eval '<php-code>'
+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
+}