[Vtigercrm-developers] Fwd: Fwd: Fwd: Fwd: Re: performance and profiling
Vic Cekvenich
vic.cvc at gmx.com
Mon Aug 18 02:17:45 GMT 2014
-------- Original Message --------
Subject: [Vtigercrm-developers] Fwd: Fwd: Fwd: Re: performance and profiling
Date: Sun, 17 Aug 2014 17:53:57 -0700
From: Vic Cekvenich <vic.cvc at gmx.com>
Reply-To: vtigercrm-developers at lists.vtigercrm.com
To: vtigercrm-developers at lists.vtigercrm.com
-------- Original Message --------
Subject: [Vtigercrm-developers] Fwd: Fwd: Re: performance and profiling
Date: Sun, 17 Aug 2014 17:41:50 -0700
From: Vic Cekvenich <vic.cvc at gmx.com>
Reply-To: vtigercrm-developers at lists.vtigercrm.com
To: vtigercrm-developers at lists.vtigercrm.com
-------- Original Message --------
Subject: [Vtigercrm-developers] Fwd: Re: performance and profiling
Date: Sun, 17 Aug 2014 15:02:21 -0700
From: Vic Cekvenich <vic.cvc at gmx.com>
Reply-To: vtigercrm-developers at lists.vtigercrm.com
To: vtigercrm-developers at lists.vtigercrm.com
-------- Original Message --------
Subject: Re: [Vtigercrm-developers] performance and profiling
Date: Tue, 22 Jul 2014 18:23:31 +0530
From: SivaKumar J <sivakumar.j at vtiger.com>
Reply-To: vtigercrm-developers at lists.vtigercrm.com
To: vtigercrm-developers at lists.vtigercrm.com
Hi Alan,
Thank you very much for your contribution on to_html() function calls to
improve performance.
After analyzing to_html() function, we got that some of those checks
what we are checking in that are not required any more in Vtiger6.
at line 366
/if($_REQUEST['module'] != 'Settings' && $_REQUEST['file'] !=
'ListView' && $_REQUEST['module'] != 'Portal' && $_REQUEST['module']
!= "Reports")// && $_REQUEST['module'] != 'Emails')/
/ $ajax_action = $_REQUEST['module'].'Ajax';/
The above check is to identify whether the current request is AJAX or
not. If so, we are setting that as /$_REQUEST['module'].'Ajax'. /But,
there are not AJAX file in Vtiger6 in that structure. So, we don't need
this.
at line 371
/if($action != 'CustomView' && $action != 'Export' && $action !=
$ajax_action && $action != 'LeadConvertToEntities' && $action !=
'CreatePDF' && $action != 'ConvertAsFAQ' && $_REQUEST['module'] !=
'Dashboard' && $action != 'CreateSOPDF' && $action != 'SendPDFMail'
&& (!isset($_REQUEST['submode'])) )/
/ {/
/ $doconvert = true;/
/ }/
In this check, except "Export" we don't have any actions like what we
are comparing, so no need of this comparision. Earlier there is an
action called Export for Exporting record in Vtiger5.4.0, but now we are
using ExportData.php for this action. While Exporting record, at
*modules/Vtiger/actions/ExportData.php* we are sanitizing all values
which will decode those values with decode_html() on line 243. So, there
is no use of encoding with to_html() for Export as well. We can remove
this also. Else, we need to add this here and remove decode_html() where
we are doing in sanitize values.
After doing all these modification, finally my code is like this.
//**/
/ * Function to decide whether to_html should convert values or not
for a request/
/ * @global type $doconvert/
/ * @global type $inUTF8/
/ * @global type $default_charset/
/ *//
/function decide_to_html(){/
/ global $doconvert,$inUTF8,$default_charset; /
/ $action = $_REQUEST['action']; /
//
/ $inUTF8 = (strtoupper($default_charset) == 'UTF-8'); /
/ $doconvert = true; /
/
/
// Need to remove decode_html() which we are doing while
exporting records from list/Detail view on ExportData.php line 243
/ if($action == 'ExportData'){/
/ $doconvert = false; /
/ }/
/}/
// Execute this function when this file got included
/decide_to_html();/
//** Function to convert the given string to html/
/ * @param $string -- string:: Type string/
/ * @param $ecnode -- boolean:: Type boolean/
/ * @returns $string -- string:: Type string/
/ *//
/function to_html($string, $encode=true) {/
/ // For optimization - default_charset can be either upper /
lower case./
/ global $doconvert,$inUTF8,$default_charset,$htmlCache;/
//
/ if(is_string($string)) {/
/ // In vtiger5 ajax request are treated specially and the
data is encoded/
/ if ($doconvert == true) {/
/ if(isset($htmlCache[$string])){/
/ $string = $htmlCache[$string];/
/ }else{/
/ if($inUTF8)/
/ $string = htmlentities($string, ENT_QUOTES,
$default_charset);/
/ else/
/ $string = preg_replace(array('/</', '/>/',
'/"/'), array('<', '>', '"'), $string);/
//
/ $htmlCache[$string] = $string;/
/ }/
/ }/
/ }/
/ return $string;/
/}/
Please let me know if I missed any thing in here.
Thank you
On Fri, Jul 18, 2014 at 6:34 PM, Alan Bell <alan.bell at libertus.co.uk
<mailto:alan.bell at libertus.co.uk>> wrote:
turns out that most of what to_html is processing is very
repetitive, if it just populates an array as it goes along and then
checks in that array it is a lot faster than doing htmlentities on
the string every time.
global $htmlcache;//store the stripped HTML as we go along, a lot of
the time we are processing the same strings
function to_html($string, $encode=true)
{
global $doconvert;
global $default_charset;
global $htmlcache;
if($doconvert){
if(isset($htmlcache[$string]))__{
return $htmlcache[$string];
}else{
$clean= htmlentities($string, ENT_QUOTES,
$default_charset);//we don't care if it is a string or not, faster
not to care
$htmlcache[$string]=$clean;
return $clean;
}
}else{
return $string;
}
}
_________________________________________________
http://www.vtiger.com/
--
Regards,
Siva
Vtiger
-------------- next part --------------
_______________________________________________
http://www.vtiger.com/
-------------- next part --------------
_______________________________________________
http://www.vtiger.com/
-------------- next part --------------
_______________________________________________
http://www.vtiger.com/
-------------- next part --------------
_______________________________________________
http://www.vtiger.com/
More information about the vtigercrm-developers
mailing list