Skip to content

Instantly share code, notes, and snippets.

@demeritcowboy
demeritcowboy / drupal10civicrmdownload.sh
Last active February 2, 2023 16:24
Drupal 10 + CiviCRM download batch file
#!/bin/sh
# Edit these as appropriate
# This needs to be the numeric version corresponding to civi dev-master
CIVIVER=5.60.alpha1
ROOTDIR=/full/path/to/folder/above/where/you/want/to/put/stuff
# Uncomment if you don't normally have php 8.1 in your path
#export PATH=/full/path/to/bin/folder/containing/php8.1:$PATH
@demeritcowboy
demeritcowboy / drupal10civicrmcore.diff
Last active February 2, 2023 16:24
composer.json patch for civicrm-core for drupal 10
diff --git a/composer.json b/composer.json
index c227b14e87..e09f2332f5 100644
--- a/composer.json
+++ b/composer.json
@@ -52,20 +52,19 @@
"require": {
"php": "~7.3 || ~8",
"composer-runtime-api": "~2.0",
- "cache/integration-tests": "~0.17.0",
"dompdf/dompdf" : "~2.0.2",

Skills/Prerequisites

  • Know how to set environment variables.
  • Upgrading the first time to 5.47.3 did not sufficiently fix your event times and you want more control over what the upgrade does.
  • As always before upgrading you should make a backup of your current database.

Environment variable

The environment variable is called CIVICRM_TZ_REVERT. It takes a comma-separated list of options (no spaces).

@demeritcowboy
demeritcowboy / RecoveringUsingPre547Backup.md
Last active March 28, 2022 03:31
Recovering from 5.47.0-.2 using a pre-5.47 database backup

Skills/Prerequisites

  • Upgrading to 5.47.3 alone did not sufficiently fix your event times and there's too many to fix manually.
  • Most of the events you need to fix were made before you originally upgraded to 5.47.
  • Either MySQL command line or phpMyAdmin.
  • Access to a pre-5.47 database backup.

Steps

  1. Make a current database backup just in case.
@demeritcowboy
demeritcowboy / ReplaceMessageTemplates.php
Created September 23, 2021 22:28
Replace all the civi message templates with the on-disk version
<?php
/**
* IMPORTANT: Make a backup of the civicrm_msg_template table first.
* Run with `cv php:script ReplaceMessageTemplates.php`
*
* While there's a link on the message templates admin page to revert a workflow
* message template, what that does is replaces your current version with the
* default FROM THE DATABASE.
* That default is, in theory, the same as the latest version on disk in the
@demeritcowboy
demeritcowboy / RunRegenOnWindows.md
Last active June 3, 2021 21:40
Run bin/regen.sh on windows

Some things here might not be completely necessary or is not the typical way of doing it but is what worked for me.

  1. Do a regular install of drupal 7.
  2. Will need to use git-bash not git-cmd.
  3. Do an install of civicrm to get a working civicrm+drupal7 using the civicrm master tree from github plus civicrm-drupal and civicrm-packages. MAKE SURE YOU INSTALL CIVI IN A SEPARATE DATABASE, otherwise your drupal database will get wiped by this process.
  4. In the drupal root, composer require drush/drush:^8.0
  5. Update path so that it can find that drush.
  6. Optionally update path so that it can find node_modules/karma/bin/karma. It's optional because otherwise it will try to install it again but that also works. It doesn't get used here anyway.
  7. Create bin/setup.conf from bin/setup.conf.txt. Note that you need GENCODE_CMS=Drupal not lower-case drupal as it suggests.
  8. CIVISOURCEDIR means path to sites/all/modules/civicrm.
@demeritcowboy
demeritcowboy / Install civicrm on drupal 8 on windows.md
Last active November 13, 2019 02:56
Install civicrm on drupal 8 using roundearth on windows - Sept 2019 version

OBSOLETE

Variation of patch below has been merged into the roundearth plugin as of 2019-11-12, so shouldn't need this anymore.


Intro

There's a problem that seems to have been around since about June 2019 where archive_tar is no longer able to extract the civicrm download .tar.gz file on windows so the install fails. These steps will get it installed.

Steps

@demeritcowboy
demeritcowboy / Set up civi coder phpcodesniffer manually.md
Created July 14, 2019 18:37
Add civi coder phpcodesniffer manually

Add civi's fork repo to the global config. In the part where it says "repositories.civicrm-coder" the "civicrm-coder" part is arbitrary. It's just a name to give it.

composer config --global repositories.civicrm-coder git https://github.com/civicrm/coder.git

Then install it. Change the 8.x-2.x to whatever is desired. You can look in buildkit's config to see what it's currently using: https://github.com/civicrm/civicrm-buildkit/blob/master/composer.json. And yes you use "drupal/coder" not "civicrm/coder".

composer global require drupal/coder:dev-8.x-2.x-civi

Then follow the rest as in the https://github.com/civicrm/coder readme which is the same as the original Drupal one at https://git.drupalcode.org/project/coder

@demeritcowboy
demeritcowboy / ramdisk-civi-unit-tests.md
Last active January 3, 2020 05:52
Run civicrm unit tests in a ramdisk

Using a ramdisk for unit tests

Overview

Why do this? Tests run faster because database reloading between tests is fast.

Why not do this? If you need to keep flipping back and forth between your tests and your browser accessing your dev site or running xdebug/IDE against your dev site then this becomes awkward.

These instructions are for windows but it shouldn't be too hard to adjust for unix.

One-time setup

@demeritcowboy
demeritcowboy / serverside.php
Created May 15, 2019 16:59
SubmitOnce server-side test/POC
/**
* Implements hook_civicrm_validateForm().
*
* @param string $formName
* @param array $fields
* @param array $files
* @param CRM_Core_Form $form
* @param array $errors
*/
function serverside_civicrm_validateForm($formName, &$fields, &$files, &$form, &$errors) {