<div dir="ltr">Hi, <div><br></div><div><span style="font-size:13px">getPicklistValues is slow because is has to check for each picklist value whether the login users has access to it or not.</span><br></div><div><span style="font-size:13px"><br></span></div><div><span style="font-size:13px">Probably there is a way to cache that info. Since only changes when you update the picklist values. </span></div><div><span style="font-size:13px"><br></span></div><div><span style="font-size:13px">Cheers,</span></div><div><span style="font-size:13px">Conrado</span></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Oct 6, 2015 at 10:36 AM, lajeesh k <span dir="ltr"><<a href="mailto:lajeeshk@gmail.com" target="_blank">lajeeshk@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div>applied to_html changes, still detail view taking 20 seconds to load page. summery view loading quickly<br><br></div>I have used xdebud and webgrind for profiling. I am a newbie in profiling<br></div>while checking vtranslate function inside Vtiger_Field_Model->getPicklistValues is one of the reason for this slownes<br></div>I have attached webgrind screenshot, it might help someone to identify the bottleneck <br><div><br><div><br><div><div><br></div></div></div></div></div><div class="gmail_extra"><br clear="all"><div><div><br>Regards,<br>Lajeesh<br></div></div><div><div class="h5">
<br><div class="gmail_quote">On Mon, Oct 5, 2015 at 10:25 PM, lajeesh k <span dir="ltr"><<a href="mailto:lajeeshk@gmail.com" target="_blank">lajeeshk@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div>seems these suggestions from Alan is not included in vtiger 6.3.<br></div>when i used xdebug profiling, this to_html function is called 226985 times. calling this function increases as number of records increases<br></div>I couldn't understand how to apply these changes by Alan and Sivakumar.if Anyone can provide these modified file for vtiger 6.3, then it will be really helpfull<br><div><br></div><div class="gmail_extra"><br clear="all"><div><div><br>Regards,<br>Lajeesh<br></div></div>
<br><div class="gmail_quote"><div><div>On Tue, Jul 22, 2014 at 6:23 PM, SivaKumar J <span dir="ltr"><<a href="mailto:sivakumar.j@vtiger.com" target="_blank">sivakumar.j@vtiger.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div><div dir="ltr">Hi Alan,<br><br>Thank you very much for your contribution on to_html() function calls to improve performance.<br>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.<br>
<br>at line 366<br><div><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><span><i>if($_REQUEST['module']
 != 'Settings' && $_REQUEST['file'] != 'ListView' && 
$_REQUEST['module'] != 'Portal' && $_REQUEST['module'] != 
"Reports")// && $_REQUEST['module'] != 'Emails')</i><br>
</span><span><i>        $ajax_action = $_REQUEST['module'].'Ajax';</i><br></span></blockquote>The above check is to identify whether the current request is AJAX or not. If so, we are setting that as <i>$_REQUEST['module'].'Ajax'. </i>But, there are not AJAX file in Vtiger6 in that structure. So, we don't need this.<br>

<br></div><div>at line 371<br></div><div><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><span><i>if($action
 != 'CustomView' && $action != 'Export' && $action != 
$ajax_action && $action != 'LeadConvertToEntities' && 
$action != 'CreatePDF' && $action != 'ConvertAsFAQ' && 
$_REQUEST['module'] != 'Dashboard' && $action != 'CreateSOPDF' 
&& $action != 'SendPDFMail' && 
(!isset($_REQUEST['submode'])) )</i><br>
</span><i>    {</i><br><i>        $doconvert = true;</i><br><i>    }</i></blockquote><div>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 <b>modules/Vtiger/actions/ExportData.php</b>
 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.<br>
<br><br></div><div>After doing all these modification, finally my code is like this.<br><br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><i>/**</i><br>

<i> * Function to decide whether to_html should convert values or not for a request</i><br><i> * @global type $doconvert</i><br><i> * @global type $inUTF8</i><br><i> * @global type $default_charset</i><br><i> */</i><br><i>function decide_to_html(){</i><br>

<i>    global $doconvert,$inUTF8,$default_charset; </i><br><i>     $action = $_REQUEST['action']; </i><br><span><i>              </i><br><i>    $inUTF8 = (strtoupper($default_charset) == 'UTF-8'); </i><br><br></span><i>    $doconvert = true; </i><br>

<i>  <br></i></blockquote><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><div>   // Need to remove decode_html() which we are doing while exporting records from list/Detail view on  ExportData.php line 243<br>

</div></blockquote><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><div><i>  if($action == 'ExportData'){</i><br><i>        $doconvert = false; </i><br>

<i>    }</i><br><i>}</i><br></div>// Execute this function when this file got included<br><div><div><i>decide_to_html();</i><span><br><br><i>/** Function to convert the given string to html</i><br><i>  * @param $string -- string:: Type string</i><br>

<i>  * @param $ecnode -- boolean:: Type boolean</i><br></span><i>  * @returns $string -- string:: Type string</i><br><i>  */</i><br><i>function to_html($string, $encode=true) {</i><span><br><i>    // For optimization - default_charset can be either upper / lower case.</i><br>

</span><i>    global $doconvert,$inUTF8,$default_charset,$htmlCache;</i><br><i>    </i><br><i>    if(is_string($string)) {</i><span><br><i>        // In vtiger5 ajax request are treated specially and the data is encoded</i><br></span><i>        if ($doconvert == true) {</i><br>

<i>            if(isset($htmlCache[$string])){</i><br><i>                $string = $htmlCache[$string];</i><br><i>            }else{</i><br><i>                if($inUTF8)</i><span><br><i>                    $string = htmlentities($string, ENT_QUOTES, $default_charset);</i><br>

</span><i>                else</i><span><br><i>                    $string = 
preg_replace(array('/</', '/>/', '/"/'), array('&lt;', 
'&gt;', '&quot;'), $string);</i><br>
<i>                </i><br></span><i>                $htmlCache[$string] = $string;</i><br><i>            }</i><br><i>        }</i><br><i>    }</i><br><i>    return $string;</i><br><i>}</i></div></div></blockquote></div><div><br>

</div><div>Please let me know if I missed any thing in here.<br></div><div>Thank you<br></div><div><br></div></div><br><br></div><div class="gmail_extra"><div><div><br><br><div class="gmail_quote">On Fri, Jul 18, 2014 at 6:34 PM, Alan Bell <span dir="ltr"><<a href="mailto:alan.bell@libertus.co.uk" target="_blank">alan.bell@libertus.co.uk</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">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.<br>

<br>
global $htmlcache;//store the stripped HTML as we go along, a lot of the time we are processing the same strings<br>
function to_html($string, $encode=true)<br>
{<br>
        global $doconvert;<br>
        global $default_charset;<br>
        global $htmlcache;<br>
        if($doconvert){<br>
                if(isset($htmlcache[$string]))<u></u>{<br>
                    return $htmlcache[$string];<br>
                }else{<br>
                    $clean= htmlentities($string, ENT_QUOTES, $default_charset);//we don't care if it is a string or not, faster not to care<br>
                    $htmlcache[$string]=$clean;<br>
                    return $clean;<br>
                }<br>
        }else{<br>
                return $string;<br>
        }<br>
<br>
<br>
}<br>
<br>
______________________________<u></u>_________________<br>
<a href="http://www.vtiger.com/" target="_blank">http://www.vtiger.com/</a><br>
</blockquote></div><br><br clear="all"><br></div></div><span><font color="#888888">-- <br>Regards,<br>Siva<br>Vtiger<br>
</font></span></div>
<br></div></div>_______________________________________________<br>
<a href="http://www.vtiger.com/" rel="noreferrer" target="_blank">http://www.vtiger.com/</a><br></blockquote></div><br></div></div>
</blockquote></div><br></div></div></div>
<br>_______________________________________________<br>
<a href="http://www.vtiger.com/" rel="noreferrer" target="_blank">http://www.vtiger.com/</a><br></blockquote></div><br></div>