Programatic Installation of Extension after Upgrading CiviCRM causes Error
Overview
We have a drupal profile we use to install drupal sites with CiviCRM and some common extensions. When running the profile, CiviCRM is upgraded to v5.19. After that, the extensions are installed, however, the first extension installation causes a database exception to be thrown. It doesn't matter what extension is installed, every time, the installation of the first extension will fail.
How it Works Currently
These steps have to be done programatically and in a single process to cause the failure:
- Upgrade CiviCRM to v5.19
- Install any extension to CiviCRM
- Exception is thrown.
How it should work
- Upgrade CiviCRM to v5.19
- Install any extension to CiviCRM
- CiviCRM is upgraded and all extensions are installed successfully.
Technical Analysis
- Upgrade
upgrade_5_19_alpha1()
creates a newfield on civicrm_status_pref
table. https://github.com/civicrm/civicrm-core/blob/master/CRM/Upgrade/Incremental/php/FiveNineteen.php#L69-L74 - At the end of the installation of the first extension, schema is synched by comparing the columns of every table in CiviCRM with its correspondig logging table, however, the columnStats cache in \Civi:$statics has already been be initialized, with
civicrm_status_pref
table missing the newis_active
column. - Schema is synched using cached values for columnStats. System erroneously detects
log_civicrm_status_pref
is missing theis_active
column and tries to create it again, causing the exception to be thrown.