Skip to content

Commit

Permalink
5.58.0 Civi update
Browse files Browse the repository at this point in the history
This grabs updates made to 5.58 between going into rc & putting out the .0 release

They can mostly be seen on
https://gerrit.wikimedia.org/r/c/wikimedia/fundraising/crm/+/886940/1/drupal/sites/all/modules/civicrm/release-notes/5.58.0.md

and relate to minor regression fixes & updating dompdf
Change-Id: I36b4b27a17f2a69f88a75cfb4e49c6c2fc65b99a

Change-Id: Ifa395f8424af31e288494e35613d48a95daaedaa
  • Loading branch information
eileenmcnaughton committed Feb 6, 2023
1 parent efce9da commit 541f4ed
Show file tree
Hide file tree
Showing 117 changed files with 1,720 additions and 1,386 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ public function buildQuickForm() {
$this->addElement('checkbox', 'doGeocodeAddress', ts('Geocode addresses during import?'));
}

$this->addElement('text', 'fieldSeparator', ts('Import Field Separator'), ['size' => 2]);

if (Civi::settings()->get('address_standardization_provider') === 'USPS') {
$this->addElement('checkbox', 'disableUSPS', ts('Disable USPS address validation during import?'));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ public static function getSoftContributionList($contact_id, ?int $membershipID =
];

$contributionSofts = ContributionSoft::get()
->addSelect('*', 'contribution_id.receive_date', 'contribution_id.contact_id', 'contribution_id.contact_id.display_name', 'soft_credit_type_id:label', 'contribution_id.contribution_status_id:label', 'contribution_id.financial_type_id:label', 'pcp_id.title')
->addSelect('*', 'contribution_id.receive_date', 'contribution_id.contact_id', 'contribution_id.contact_id.display_name', 'soft_credit_type_id:label', 'contribution_id.contribution_status_id:label', 'contribution_id.financial_type_id:label', 'pcp_id.title', 'row_count')
->addWhere('contact_id', '=', $contact_id)
->addWhere('contribution_id.is_test', '=', $isTest);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@ public function setDefaultValues() {
$defaults["custom_post_id_multiple[$key]"] = $value;
}
}

$this->assign('profilePostMultiple', CRM_Utils_Array::value('custom_post', $defaults));
$this->assign('profilePostMultiple', $defaults['custom_post'] ?? NULL);

// CRM-17745: Make max additional participants configurable
if (empty($defaults['max_additional_participants'])) {
Expand Down Expand Up @@ -149,7 +148,7 @@ public function setDefaultValues() {
$defaults["additional_custom_post_id_multiple[$key]"] = $value;
}
}
$this->assign('profilePostMultipleAdd', CRM_Utils_Array::value('additional_custom_post', $defaults, []));
$this->assign('profilePostMultipleAdd', $defaults['additional_custom_post'] ?? []);
}
else {
// Avoid PHP notices in the template
Expand All @@ -161,10 +160,10 @@ public function setDefaultValues() {
}

// provide defaults for required fields if empty (and as a 'hint' for approval message field)
$defaults['registration_link_text'] = CRM_Utils_Array::value('registration_link_text', $defaults, ts('Register Now'));
$defaults['confirm_title'] = CRM_Utils_Array::value('confirm_title', $defaults, ts('Confirm Your Registration Information'));
$defaults['thankyou_title'] = CRM_Utils_Array::value('thankyou_title', $defaults, ts('Thank You for Registering'));
$defaults['approval_req_text'] = CRM_Utils_Array::value('approval_req_text', $defaults, ts('Participation in this event requires approval. Submit your registration request here. Once approved, you will receive an email with a link to a web page where you can complete the registration process.'));
$defaults['registration_link_text'] = $defaults['registration_link_text'] ?? ts('Register Now');
$defaults['confirm_title'] = $defaults['confirm_title'] ?? ts('Confirm Your Registration Information');
$defaults['thankyou_title'] = $defaults['thankyou_title'] ?? ts('Thank You for Registering');
$defaults['approval_req_text'] = $defaults['approval_req_text'] ?? ts('Participation in this event requires approval. Submit your registration request here. Once approved, you will receive an email with a link to a web page where you can complete the registration process.');

return $defaults;
}
Expand Down Expand Up @@ -442,10 +441,13 @@ public function addRules() {
public static function formRule($values, $files, $form) {
if (!empty($values['is_online_registration'])) {

if (!$values['confirm_title']) {
if (($values['registration_link_text'] ?? '') === '') {
$errorMsg['registration_link_text'] = ts('Please enter Registration Link Text');
}
if (($values['confirm_title'] ?? '') === '') {
$errorMsg['confirm_title'] = ts('Please enter a Title for the registration Confirmation Page');
}
if (!$values['thankyou_title']) {
if (($values['thankyou_title'] ?? '') === '') {
$errorMsg['thankyou_title'] = ts('Please enter a Title for the registration Thank-you Page');
}
if ($values['is_email_confirm']) {
Expand Down
6 changes: 2 additions & 4 deletions drupal/sites/all/modules/civicrm/CRM/Import/DataSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ public function getDataSourceMetadata(): array {
}

/**
* Get the table name for the datajob.
* Get the table name for the import job.
*
* @return string|null
*
Expand Down Expand Up @@ -416,8 +416,6 @@ abstract public function buildQuickForm(&$form);

/**
* Initialize the datasource, based on the submitted values stored in the user job.
*
* @throws \CRM_Core_Exception
*/
public function initialize(): void {

Expand Down Expand Up @@ -462,7 +460,7 @@ protected function updateUserJobMetadata(string $key, array $data): void {
* If the dataSource is being updated to another variant of the same
* class (eg. the csv upload was set to no column headers and they
* have resubmitted WITH skipColumnHeader (first row is a header) then
* the dataSource is still CSV and the params for the new intance
* the dataSource is still CSV and the params for the new instance
* are passed in. When changing from csv to SQL (for example) newParams is
* empty.
*
Expand Down
18 changes: 16 additions & 2 deletions drupal/sites/all/modules/civicrm/CRM/Import/DataSource/CSV.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function getInfo(): array {
* It should add all fields necessary to get the data
* uploaded to the temporary table in the DB.
*
* @param CRM_Core_Form $form
* @param CRM_Contact_Import_Form_DataSource|\CRM_Import_Form_DataSourceConfig $form
*
* @throws \CRM_Core_Exception
*/
Expand All @@ -56,14 +56,15 @@ public function buildQuickForm(&$form) {
$uploadSize = round(($uploadFileSize / (1024 * 1024)), 2);
$form->assign('uploadSize', $uploadSize);
$form->add('File', 'uploadFile', ts('Import Data File'), NULL, TRUE);
$form->addElement('text', 'fieldSeparator', ts('Import Field Separator'), ['size' => 2]);
$form->setMaxFileSize($uploadFileSize);
$form->addRule('uploadFile', ts('File size should be less than %1 MBytes (%2 bytes)', [
1 => $uploadSize,
2 => $uploadFileSize,
]), 'maxfilesize', $uploadFileSize);
$form->addRule('uploadFile', ts('Input file must be in CSV format'), 'utf8File');
$form->addRule('uploadFile', ts('A valid file must be uploaded.'), 'uploadedfile');

$form->setDataSourceDefaults($this->getDefaultValues());
$form->addElement('checkbox', 'skipColumnHeader', ts('First row contains column headers'));
}

Expand Down Expand Up @@ -260,4 +261,17 @@ public static function trimNonBreakingSpaces(string $string): string {
return preg_replace("/^(\u{a0})+|(\u{a0})+$/", '', $string);
}

/**
* Get default values for csv dataSource fields.
*
* @return array
*/
public function getDefaultValues(): array {
return [
'fieldSeparator' => CRM_Core_Config::singleton()->fieldSeparator,
'skipColumnHeader' => 1,
];

}

}
24 changes: 21 additions & 3 deletions drupal/sites/all/modules/civicrm/CRM/Import/Form/DataSource.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,10 @@ public function buildQuickForm() {
}

public function setDefaultValues() {
return [
return array_merge($this->dataSourceDefaults, [
'dataSource' => $this->getDefaultDataSource(),
'onDuplicate' => CRM_Import_Parser::DUPLICATE_SKIP,
'fieldSeparator' => CRM_Core_Config::singleton()->fieldSeparator,
];
]);

}

Expand Down Expand Up @@ -191,4 +190,23 @@ private function instantiateDataSource(): void {
$this->getDataSourceObject()->initialize();
}

/**
* Default values for datasource fields.
*
* @var array
*/
protected $dataSourceDefaults = [];

/**
* Set dataSource default values.
*
* @param array $dataSourceDefaults
*
* @return self
*/
public function setDataSourceDefaults(array $dataSourceDefaults): self {
$this->dataSourceDefaults = $dataSourceDefaults;
return $this;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,25 @@
*/
class CRM_Import_Form_DataSourceConfig extends CRM_Import_Forms {

/**
* Default values for datasource fields.
*
* @var array
*/
protected $dataSourceDefaults = [];

/**
* Set dataSource default values.
*
* @param array $dataSourceDefaults
*
* @return CRM_Import_Form_DataSourceConfig
*/
public function setDataSourceDefaults(array $dataSourceDefaults): CRM_Import_Form_DataSourceConfig {
$this->dataSourceDefaults = $dataSourceDefaults;
return $this;
}

/**
* Set variables up before form is built.
*
Expand Down Expand Up @@ -57,6 +76,9 @@ public function setDefaultValues() {
$defaults[$fieldName] = $this->getSubmittedValue($fieldName);
}
}
else {
$defaults = array_merge($this->dataSourceDefaults, $defaults);
}
return $defaults;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
require_once 'Mail/mime.php';

/**
* Class CRM_Mailing_Event_BAO_Resubscribe
* Class CRM_Mailing_Event_BAO_MailingEventResubscribe
*/
class CRM_Mailing_Event_BAO_Resubscribe {
class CRM_Mailing_Event_BAO_MailingEventResubscribe {

/**
* Resubscribe a contact to the groups, he/she was unsubscribed from.
Expand Down
4 changes: 2 additions & 2 deletions drupal/sites/all/modules/civicrm/CRM/Mailing/Page/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ public function run() {
}
}
elseif ($this->_type == 'resubscribe') {
$groups = CRM_Mailing_Event_BAO_Resubscribe::resub_to_mailing($job_id, $queue_id, $hash);
$groups = CRM_Mailing_Event_BAO_MailingEventResubscribe::resub_to_mailing($job_id, $queue_id, $hash);
if (count($groups)) {
CRM_Mailing_Event_BAO_Resubscribe::send_resub_response($queue_id, $groups, $job_id);
CRM_Mailing_Event_BAO_MailingEventResubscribe::send_resub_response($queue_id, $groups, $job_id);
}
else {
// should we indicate an error, or just ignore?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public function upgrade_5_58_alpha1($rev): void {

public static function addOptionGroupDescriptions($ctx): bool {
CRM_Upgrade_Incremental_Base::alterColumn($ctx, 'civicrm_option_group', 'description', "TEXT COMMENT 'Option group description.'", TRUE);
$schema = new CRM_Logging_Schema();
$schema->fixSchemaDifferences();
$values = [
[
'group' => 'gender',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,19 @@ class CRM_Upgrade_Incremental_php_FiveFiftySeven extends CRM_Upgrade_Incremental

public function setPreUpgradeMessage(&$preUpgradeMessage, $rev, $currentVer = NULL) {
if ($rev === '5.57.alpha1') {
$docUrl = 'https://civicrm.org/redirect/activities-5.57';
$docAnchor = 'target="_blank" href="' . htmlentities($docUrl) . '"';

// The query on is_current_revision is slow if there's a lot of activities. So limit when it gets run.
$activityCount = CRM_Core_DAO::singleValueQuery('SELECT MAX(id) FROM civicrm_activity');
if ($activityCount < self::ACTIVITY_THRESHOLD && CRM_Core_DAO::singleValueQuery('SELECT COUNT(id) FROM civicrm_activity WHERE is_current_revision = 0')) {
$preUpgradeMessage .= '<p>' . ts('Your database contains CiviCase activity revisions which are deprecated and will begin to appear as duplicates in SearchKit/api4/etc.<ul><li>For further instructions see this <a %1>Lab Snippet</a>.</li></ul>', [1 => 'target="_blank" href="https://lab.civicrm.org/-/snippets/85"']) . '</p>';
$preUpgradeMessage .= '<p>' . ts('Your database contains CiviCase activity revisions which are deprecated and will begin to appear as duplicates in SearchKit/api4/etc.<ul><li>For further instructions see this <a %1>Lab Snippet</a>.</li></ul>', [1 => $docAnchor]) . '</p>';
}
// Similarly the original_id ON DELETE drop+recreate is slow, so if we
// don't add the task farther down below, then tell people what to do at
// their convenience.
elseif ($activityCount >= self::ACTIVITY_THRESHOLD) {
$preUpgradeMessage .= '<p>' . ts('Your database contains too many activities to efficiently run a query needed to check for deprecated case activity revisions and to fix a bad foreign key constraint and it may take hours to run. You can run these queries manually at your convenience:<ul><li>SELECT COUNT(id) FROM `civicrm_activity` WHERE `is_current_revision` = 0;</li><li>ALTER TABLE `civicrm_activity` DROP FOREIGN KEY `FK_civicrm_activity_original_id`;</li><li>ALTER TABLE `civicrm_activity` ADD CONSTRAINT `FK_civicrm_activity_original_id` FOREIGN KEY (`original_id`) REFERENCES `civicrm_activity` (`id`) ON DELETE SET NULL;</li><li>For more information see this <a %1>Lab Snippet</a>.</li></ul>', [1 => 'target="_blank" href="https://lab.civicrm.org/-/snippets/85"']) . '</p>';
$preUpgradeMessage .= '<p>' . ts('The activity table <strong>will not update automatically</strong> because it contains too many records. You will need to apply a <strong>manual update</strong>. Please read about <a %1>how to clean data from the defunct "Embedded Activity Revisions" setting</a>.', [1 => $docAnchor]) . '</p>';
}
}
}
Expand All @@ -58,8 +61,8 @@ public function upgrade_5_57_alpha1($rev): void {
}

public static function fixDeleteCascade($ctx): bool {
// CRM_Core_BAO_SchemaHandler::safeRemoveFK('civicrm_activity', 'FK_civicrm_activity_original_id');
// CRM_Core_DAO::executeQuery('ALTER TABLE `civicrm_activity` ADD CONSTRAINT `FK_civicrm_activity_original_id` FOREIGN KEY (`original_id`) REFERENCES `civicrm_activity` (`id`) ON DELETE SET NULL');
CRM_Core_BAO_SchemaHandler::safeRemoveFK('civicrm_activity', 'FK_civicrm_activity_original_id');
CRM_Core_DAO::executeQuery('ALTER TABLE `civicrm_activity` ADD CONSTRAINT `FK_civicrm_activity_original_id` FOREIGN KEY (`original_id`) REFERENCES `civicrm_activity` (`id`) ON DELETE SET NULL');
return TRUE;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,41 @@ public function checkSmartGroupCustomFieldCriteria() {
return $messages;
}

/**
* The column 'civicrm_activity.original_id' should not have 'ON DELETE CASCADE'.
* It is OK to have 'ON DELETE SET NULL' or to have no constraint.
*
* @return CRM_Utils_Check_Message[]
*/
public function checkOldAcitvityCascade(): array {
$messages = [];

$sql = "SELECT CONSTRAINT_NAME, DELETE_RULE
FROM information_schema.referential_constraints
WHERE CONSTRAINT_SCHEMA=database() AND TABLE_NAME='civicrm_activity' AND CONSTRAINT_NAME='FK_civicrm_activity_original_id'
";
$cascades = CRM_Core_DAO::executeQuery($sql, [], FALSE, NULL, FALSE, FALSE)
->fetchMap('CONSTRAINT_NAME', 'DELETE_RULE');
$cascade = $cascades['FK_civicrm_activity_original_id'] ?? NULL;
if ($cascade === 'CASCADE') {
$docUrl = 'https://civicrm.org/redirect/activities-5.57';
$messages[] = new CRM_Utils_Check_Message(
__FUNCTION__,
ts(
'<p>The table <code>%1</code> includes an incorrect constraint. <a %2>Learn how to fix this.</a>', [
1 => 'civicrm_activity',
2 => 'target="_blank" href="' . htmlentities($docUrl) . '"',
]
),
ts('Schema Error'),
\Psr\Log\LogLevel::WARNING,
'fa-server'
);
}

return $messages;
}

/**
* @return CRM_Utils_Check_Message[]
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,54 @@ class CRM_Utils_Check_Component_Timestamps extends CRM_Utils_Check_Component {

const DOCTOR_WHEN = 'https://github.com/civicrm/org.civicrm.doctorwhen';

/**
* Check that MySQL actually supports timezone operations.
*
* @return CRM_Utils_Check_Message[]
*/
public function checkTimezoneAPIs() {
$messages = [];

try {
$convertedTimeNY = CRM_Core_DAO::singleValueQuery('SELECT CONVERT_TZ("2001-02-03 04:05:00", "GMT", "America/New_York")');
}
catch (\Exception $e) {
$convertedTimeNY = NULL;
}
$expectedTimeNY = '2001-02-02 23:05:00';

$oldTz = CRM_Core_DAO::singleValueQuery('SELECT @@time_zone');
try {
CRM_Core_DAO::singleValueQuery('SET @@time_zone = "Europe/Berlin"');
$convertedTimeDE = CRM_Core_DAO::singleValueQuery('SELECT FROM_UNIXTIME(981176700)');
}
catch (\Exception $e) {
$convertedTimeDE = NULL;
}
finally {
CRM_Core_DAO::singleValueQuery('SET @@time_zone = %1', [1 => [$oldTz, 'String']]);
}
$expectedTimeDE = '2001-02-03 06:05:00';

if ($convertedTimeNY !== $expectedTimeNY || $convertedTimeDE !== $expectedTimeDE) {
$messages[] = new CRM_Utils_Check_Message(
__FUNCTION__,
ts('The MySQL database does not fully support timezones. Please ask the database administrator to <a %1>load timezone data</a>.', [
// If we had a manual page, it would make sense to link to that. Such a page might
// (a) point out that the process is similar for MySQL 5.x/8.x and MariaDB,
// and (b) talk more about potential impacts (re: current code; extensions; future changes).
// We don't have that page. But this link gives the general gist.
1 => 'target="_blank" href="https://dev.mysql.com/doc/refman/8.0/en/mysql-tzinfo-to-sql.html"',
]),
ts('MySQL Timezone Problem'),
\Psr\Log\LogLevel::WARNING,
'fa-clock-o'
);
}

return $messages;
}

/**
* Check that various columns are TIMESTAMP and not DATETIME. (CRM-9683, etal)
*
Expand Down
1 change: 1 addition & 0 deletions drupal/sites/all/modules/civicrm/Civi/API/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public static function create(string $entity, string $action, array $params) {
if ($daoName && !$daoName::isComponentEnabled()) {
throw new \Civi\API\Exception\NotImplementedException("$entity API is not available because " . $daoName::COMPONENT . " component is disabled");
}
// Extra arguments used e.g. by dynamic entities like Multi-Record custom groups & the ECK extension
$args = (array) CoreUtil::getInfoItem($entity, 'class_args');
$apiRequest = call_user_func_array($callable, $args);
foreach ($params as $name => $param) {
Expand Down
Loading

0 comments on commit 541f4ed

Please sign in to comment.