Skip to content

Instantly share code, notes, and snippets.

diff --git a/php-8.1-strftime.php b/php-8.1-strftime.php
index 178cd5ad2a..646d93f95b 100644
--- a/php-8.1-strftime.php
+++ b/php-8.1-strftime.php
@@ -102,5 +102,10 @@
$calendar = IntlGregorianCalendar::createInstance();
$calendar->setGregorianChange(PHP_INT_MIN);
+ // AW 2023-10-29 Temporary fix for compatibility with PHP 8.1.25
+ if ($locale == 'C') {
@MegaphoneJon
MegaphoneJon / gist:c49857d9f68cf6292c3820be8a914213
Created December 28, 2021 00:24
webform_civicrm 6.1.0 primary address fix
diff --git a/src/WebformCivicrmPostProcess.php b/src/WebformCivicrmPostProcess.php
--- a/src/WebformCivicrmPostProcess.php
+++ b/src/WebformCivicrmPostProcess.php
@@ -790,10 +790,6 @@
* @param int $c
*/
private function saveContactLocation($contact, $cid, $c) {
- // Check which location_type_id is to be set as is_primary=1;
- $is_primary_address_location_type = wf_crm_aval($contact, 'address:1:location_type_id');
- $is_primary_email_location_type = wf_crm_aval($contact, 'email:1:location_type_id');
--- disable_messages/disable_messages.module 2020-06-02 02:48:33.000000000 -0400
+++ /home/jon/temp/disable_messages.module 2021-12-15 19:22:02.935024440 -0500
@@ -108,7 +108,7 @@
$filter_paths = explode("\n", \Drupal::config('disable_messages.settings')->get('disable_messages_page_filter_paths'));
$current_url = Url::fromRoute('<current>');
$internal_path = disable_messages_remove_white_space($current_url->getInternalPath());
- $path = \Drupal::service('path.alias_manager')->getPathByAlias(($internal_path));
+ $path = \Drupal::service('path_alias.manager')->getPathByAlias(($internal_path));
$page_match = disable_messages_path_match($filter_paths, $path);
if ($path != $internal_path) {
--- a/vendor/civicrm/civicrm-core/CRM/Core/I18n/Schema.php 2023-03-01 16:30:27.347351588 -0500
+++ b/vendor/civicrm/civicrm-core/CRM/Core/I18n/Schema.php 2023-03-01 16:26:53.196516104 -0500
@@ -303,9 +303,15 @@
}
// rebuild views
+ $config = CRM_Core_Config::singleton();
+
foreach ($locales as $locale) {
foreach ($tables as $table) {
@MegaphoneJon
MegaphoneJon / gist:b1b344edeba594bbdd0acb0c31f47c6b
Last active January 29, 2023 19:44
Google Scripts code for integrating with CiviCRM (via Form Processor)
/**
* @OnlyCurrentDoc
*/
function onFormSubmit(event) {
// Set the values on these four lines for your Form Processor and site.
var url = <your REST endpoint URL, e.g. https://mysite.org/wp-json/civicrm/v3/rest>
var api_key = <your CiviCRM API key>;
var site_key = <your CiviCRM site key>;
var form_processor_machine_name = 'google_forms_member_profile';
@MegaphoneJon
MegaphoneJon / civicrm.settings.php
Created January 23, 2020 21:51
civicrm.settings.php for Drupal 8 on Pantheon
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 5 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2018 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
diff --git a/CRM/Export/Form/Select.php b/CRM/Export/Form/Select.php
index 182e4fdba8..2fa668f950 100644
--- a/CRM/Export/Form/Select.php
+++ b/CRM/Export/Form/Select.php
@@ -231,11 +231,23 @@ FROM {$this->_componentTable}
$this->assign('totalSelectedRecords', $rowCount);
}
+ // If you have a large export and transfer data via $this->get() or $this->set(),
+ // it can overwhelm session storage limits. Use a temporary space.
@MegaphoneJon
MegaphoneJon / failedtest.php
Created November 14, 2019 17:07
I tried and failed to write a CiviCRM ReportTemplate test that relied on custom fields.
+ /**
+ * Ensure that a LEFT JOIN to a 1-to-many table doesn't multiply the statistics (reporting#21).
+ */
+ public function testContributionDetailStatisticsMultiRecordCustomField() {
+ $customGroup = $this->CustomGroupMultipleCreateWithFields();
+ $contactID = $this->individualCreate();
+ $params = [
+ 'entity_id' => $contactID,
+ 'custom_' . $customGroup['custom_field_id'][0] => 'value 1',
+ ];
@MegaphoneJon
MegaphoneJon / profiling.php
Created September 3, 2019 15:20
CiviCRM speed profiling script
#!/usr/bin/php
<?php
// How long does it take to create 10 contacts?
eval(`cv php:boot`);
\CRM_Core_Config::singleton()->doNotResetCache = 1;
//place this before any script you want to calculate time
$time_start = microtime(true);
$startTime = date('H:i:s');
@MegaphoneJon
MegaphoneJon / smartgroupprofiling.php
Created September 3, 2019 15:19
CiviCRM Smart group profiling
#!/usr/bin/php
<?php
// Use this code to see how long it takes to generate all of your smart groups to find slow ones.
eval(`cv php:boot`);
//Force a refresh of the cache
$sql = 'UPDATE civicrm_group SET cache_date = NULL, refresh_date = NULL';
CRM_Core_DAO::executeQuery($sql);
// Get a list of smart group IDs.
$smartGroups = civicrm_api3('Group', 'get', [
'return' => ["id", "title"],