Add in post composer file to add in civicrm custom comment and test if class_exists...
authorSeamus Lee <seamuslee001@gmail.com>
Tue, 13 Sep 2016 01:22:18 +0000 (11:22 +1000)
committerSeamus Lee <seamuslee001@gmail.com>
Tue, 13 Sep 2016 06:38:05 +0000 (16:38 +1000)
composer.json
tools/scripts/composer/pear-execption-fix.sh [new file with mode: 0755]

index a8e2393485747df8d975422cc42e03619f3cfd3d..6ae2d7695edd1a736667848452d39744e3573acd 100644 (file)
   "scripts": {
     "post-install-cmd": [
       "bash tools/scripts/composer/dompdf-cleanup.sh",
-      "bash tools/scripts/composer/tcpdf-cleanup.sh"
+      "bash tools/scripts/composer/tcpdf-cleanup.sh",
+      "bash tools/scripts/composer/pear-execption-fix.sh"
     ],
     "post-update-cmd": [
       "bash tools/scripts/composer/dompdf-cleanup.sh",
-      "bash tools/scripts/composer/tcpdf-cleanup.sh"
+      "bash tools/scripts/composer/tcpdf-cleanup.sh",
+      "bash tools/scripts/composer/pear-execption-fix.sh"
     ]
   }
 }
diff --git a/tools/scripts/composer/pear-execption-fix.sh b/tools/scripts/composer/pear-execption-fix.sh
new file mode 100755 (executable)
index 0000000..aa9fca9
--- /dev/null
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+## Cleanup the vendor tree. The main issue here is that civi Civi is
+## deployed as a module inside a CMS, so all its source-code gets published.
+## Some libraries distribute admin tools and sample files which should not
+## be published.
+##
+## This script should be idempotent -- if you rerun it several times, it
+## should always produce the same post-condition.
+
+## Replace a line in a file
+## This is a bit like 'sed -i', but dumber and more cross-platform.
+function simple_replace() {
+  php -r 'file_put_contents($argv[1], preg_replace($argv[2], $argv[3], file_get_contents($argv[1])));' "$@"
+}
+
+
+# add in class_exists test as per CRM-8921.
+simple_replace vendor/pear/pear_exception/PEAR/Exception.php '^\<\?php^' '<?php
+  // CRM-8921
+  if ( class_exists( "'"PEAR_Exception"'" ) ) {
+     return; 
+  }' /home/seamus/test.php