Created
October 23, 2020 10:23
-
-
Save codebymikey/e6fbb62537d93114feddcd4022ff13cb to your computer and use it in GitHub Desktop.
CiviCRM temporary patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 10e59978672d9b779ae7ada18130837717397b29 Mon Sep 17 00:00:00 2001 | |
From: demeritcowboy <[email protected]> | |
Date: Sat, 26 Sep 2020 10:25:12 -0400 | |
Subject: [PATCH] avoid crash from recursion on exceptions | |
Source: https://github.com/civicrm/civicrm-core/pull/18610 | |
--- | |
CRM/Core/Error.php | 13 ++++--- | |
diff --git a/CRM/Core/Error.php b/CRM/Core/Error.php | |
index aced775beed..ec287600277 100644 | |
--- a/CRM/Core/Error.php | |
+++ b/CRM/Core/Error.php | |
@@ -529,11 +529,14 @@ public static function debug_var($variable_name, $variable, $print = TRUE, $log | |
$out = "\$$variable_name = $out"; | |
} | |
else { | |
- // use var_dump | |
- ob_start(); | |
- var_dump($variable); | |
- $dump = ob_get_contents(); | |
- ob_end_clean(); | |
+ // Use Symfony var-dumper to avoid circular references that exhaust | |
+ // memory when using var_dump(). | |
+ // Use its CliDumper since if we use the simpler `dump()` then it | |
+ // comes out as some overly decorated html which is hard to read. | |
+ $dump = (new \Symfony\Component\VarDumper\Dumper\CliDumper('php://output')) | |
+ ->dump( | |
+ (new \Symfony\Component\VarDumper\Cloner\VarCloner())->cloneVar($variable), | |
+ TRUE); | |
$out = "\n\$$variable_name = $dump"; | |
} | |
// reset if it is an array |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment