From 8c5f84b614c231844f2bef2297f6d9fcafe612ce Mon Sep 17 00:00:00 2001 From: eileen Date: Mon, 25 Nov 2019 17:30:20 +1300 Subject: [PATCH] [REF] Remove checks on var This variable is hard-coded to a double quote so checks to see if it is a single quote will never be true. I've checked this pretty thoroughly & I think the removed IFs are dead code --- CRM/Core/Report/Excel.php | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/CRM/Core/Report/Excel.php b/CRM/Core/Report/Excel.php index 4d9ca60f32..d7b0500e10 100644 --- a/CRM/Core/Report/Excel.php +++ b/CRM/Core/Report/Excel.php @@ -50,12 +50,7 @@ class CRM_Core_Report_Excel { $schema_insert = ''; foreach ($header as $field) { - if ($enclosed == '') { - $schema_insert .= stripslashes($field); - } - else { - $schema_insert .= $enclosed . str_replace($enclosed, $escaped . $enclosed, stripslashes($field)) . $enclosed; - } + $schema_insert .= $enclosed . str_replace($enclosed, $escaped . $enclosed, stripslashes($field)) . $enclosed; $schema_insert .= $seperator; } // end while @@ -85,28 +80,23 @@ class CRM_Core_Report_Excel { // loic1 : always enclose fields //$value = ereg_replace("\015(\012)?", "\012", $value); $value = preg_replace("/\015(\012)?/", "\012", $value); - if ($enclosed == '') { - $schema_insert .= $value; - } - else { - if ((substr($value, 0, 1) == CRM_Core_DAO::VALUE_SEPARATOR) && - (substr($value, -1, 1) == CRM_Core_DAO::VALUE_SEPARATOR) - ) { + if ((substr($value, 0, 1) == CRM_Core_DAO::VALUE_SEPARATOR) && + (substr($value, -1, 1) == CRM_Core_DAO::VALUE_SEPARATOR) + ) { - $strArray = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value); + $strArray = explode(CRM_Core_DAO::VALUE_SEPARATOR, $value); - foreach ($strArray as $key => $val) { - if (trim($val) == '') { - unset($strArray[$key]); - } + foreach ($strArray as $key => $val) { + if (trim($val) == '') { + unset($strArray[$key]); } - - $str = implode($seperator, $strArray); - $value = &$str; } - $schema_insert .= $enclosed . str_replace($enclosed, $escaped . $enclosed, $value) . $enclosed; + $str = implode($seperator, $strArray); + $value = &$str; } + + $schema_insert .= $enclosed . str_replace($enclosed, $escaped . $enclosed, $value) . $enclosed; } else { $schema_insert .= ''; -- 2.25.1