CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Upgrading CiviCRM (Moderator: Deepak Srivastava) »
  • Upgrading and managing custom_php code
Pages: [1]

Author Topic: Upgrading and managing custom_php code  (Read 1196 times)

sonicthoughts

  • Ask me questions
  • ****
  • Posts: 498
  • Karma: 10
Upgrading and managing custom_php code
June 28, 2009, 06:19:51 pm
Greetings:
We are running 2.2.3 and would like to upgrade to the latest release.  In order to manage our custom code, we have it in a seperate directory (wonderful feature!)

When we upgrade, however, some of the core files in the template or custom_php directory may have changed.  What is the best process for tracking if any of those files have changed in a later release?

I figured that looking at fisheye or crucible would help, but I've never used those tools before and I can't see how to list changes in a 2.x.x release.  I'm sure I could write a script to compare between two versions, but I was wondering if there is a best practice to 1) identify if any of the custom files have changed in the update and 2) automate the patching if required (i realize that's a stretch.)

I'm sure that this would be helpful for others who have custom code.

Thanks,

S.

ken

  • I live on this forum
  • *****
  • Posts: 916
  • Karma: 53
    • City Bible Forum
  • CiviCRM version: 4.6.3
  • CMS version: Drupal 7.36
  • MySQL version: 5.5.41
  • PHP version: 5.3.10
Re: Upgrading and managing custom_php code
June 28, 2009, 09:49:42 pm
Here's what I do for my local custom code ...

  • On my web-server I have a directory called .../local with sub-directories .../local/php and .../local/templates. The CiviCRM Custom Files and Custom Templates URLs point here.
  • I mirror this structure on my development machine. All development and testing is done on this machine.
  • When I change the custom code or templates, I compress these 2 directories into a tar.gz file (not zip as the tar command overwrites while zip baulks at that) and install on my web-server.
  • For each release of CiviCRM I have separate copies of the custom files. I create patch files that show me the differences between the custom code and the release code (see script below).
  • When I plan to do an upgrade to a new release of CiviCRM, I create a new copy of my custom changes for the new release. When I run my script, I often get extra differences, because even if my custom code hasn't changed, the release code has.
  • I change my custom files to account for the changes in the release code. I know I'm done when I run the script and the only differences are those due to my changes.
  • Often, my custom change turns out not to be necessary in the new release, because the CiviCRM team are so good at patching and fixing their software!
  • I have test scenarios for all my custom changes, and I make sure these all work in the new release.

Ken

(This is my script for showing differences between my custom code and the release code.)

Code: [Select]
#!/bin/bash
#
# This script creates patch files showing the difference between the
# files in the custom directory and the CiviCRM release directory
#
# To create a script for a new release, copy this script to a new
# file, and edit VERSION and RELEASE
#

VERSION= # Version number of CiviCRM, eg 2.2.0
RELEASE= # Location of release code on development machine, eg, /var/www/xxx/administrator/components/com_civicrm/civicrm
CUSTOM=  # Location of custom code on development machine, eg /data/Work/IT/CiviCRM/Custom

cd $CUSTOM/$VERSION/php
find CRM -type f -exec diff -urs "$RELEASE/{}" "$CUSTOM/$VERSION/php/{}" \; > $CUSTOM/$VERSION.php.patch
cd $CUSTOM/$VERSION/templates
find CRM -type f -exec diff -urs "$RELEASE/templates/{}" "$CUSTOM/$VERSION/templates/{}" \; > $CUSTOM/$VERSION.template.patch
« Last Edit: June 28, 2009, 10:03:08 pm by ken »

sonicthoughts

  • Ask me questions
  • ****
  • Posts: 498
  • Karma: 10
Re: Upgrading and managing custom_php code
June 29, 2009, 08:15:22 am
Thanks Ken - very helpful. you should post on the wiki!

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Upgrading CiviCRM (Moderator: Deepak Srivastava) »
  • Upgrading and managing custom_php code

This forum was archived on 2017-11-26.