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).
$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 )
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
+}