• MODX Syntax Checker#

  • Everett Reply #1, 5 months ago

    Reply
    I wanted to ask for some help testing this out:

    http://modx.com/extras/package/syntaxchecker

    It's my first Revo package, designed to highlight any problems with your MODX tags and their syntax.


  • lettis Reply #2, 4 months, 3 weeks ago

    Reply
    I got this error on saving a resource while using syntax checker (saving was not possible):

    ERROR @ /connectors/resource/index.php) [SyntaxChecker] Event:OnBeforeDocFormSave
    <br />
    <b>Strict Standards</b>:  strftime() [<a href='function.strftime'>function.strftime</a>]: It is not safe to rely on the system's timezone settings. Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 
    ...
    


    Do you have any idea what could be wrong?


  • Everett Reply #3, 4 months, 3 weeks ago

    Reply
    Your system timezone is incorrectly set inside your php.ini, so the datestamps sent to the log are throwing that error because it uses PHP's date() function. Fix the issue with your timezone by altering your php.ini file. I can suppress the errors in a future version, but that doesn't make them go away.


  • lettis Reply #4, 4 months, 3 weeks ago

    Reply
    Thanks for your reply. What do you mean by system timezone is incorrectly set. What do I have to set to make it work properly? The "Default timezone" is exactly my timezone. Which value do I have to change?


  • Everett Reply #5, 4 months, 3 weeks ago

    Reply
    This is a really common error that pops up any time a PHP script uses the date() function. Triple-check your server's php.ini setting. It doesn't really have anything to do with the Syntax Checker plugin, but rather with your environment. Here are a couple links:

    http://us2.php.net/manual/en/datetime.configuration.php
    http://stackoverflow.com/questions/4533252/php-system-timezone-setting-error

    Remember that in most cases you'll have to restart apache after changing the php.ini. Where is this site hosted?


  • lettis Reply #6, 4 months, 2 weeks ago

    Reply
    OK, I added in the htaccess:
    setenv PZ 'our local timezone'
    but saving is still not possible resulting in the same message of the error-log-file.

    Btw: Our server-support-team mentioned that the new time-zone-setting might lead to problems because other tools maybe work with the so far used universal time.


  • Everett Reply #7, 4 months, 2 weeks ago

    Reply
    How you adjust this depends entirely on your server and how PHP is configured. You can configure PHP to use any timezone you want, so I personally don't buy your support team's alibi there. To test this, just make a simple php file that uses the date() function and see if it throws errors. This type of discussion comes up all the time and it tends to highlight system admins who may not have a good understanding of PHP. That may sound harsh, but if I had a nickel...


  • opengeek Reply #8, 4 months, 2 weeks ago

    Reply
    Since PHP 5.2, it is required that the date.timezone value is set in the configuration, otherwise the PHP errors you are seeing will be triggered OR every PHP application you use will have to be modified to call date_default_timezone_set() before anything else happens.

    In MODX 2.2, this is now done, but if you do not have a proper value, you will be set to UTC time. If your MySQL server also is set to use UTC, you will be fine, but in most cases, MySQL will get the proper timezone of the server itself and use it. If your PHP is using UTC and MySQL something else, the times will not match properly and all sorts of unexpected behavior can ensue in MODX.


  • lettis Reply #9, 4 months, 1 week ago

    Reply
    We no updated MODx to 2.2.0-pl2 and set the time-zone in the system settings.

    On saving a document we now get this error in the log:

     [] (ERROR @ /connectors/resource/index.php) [SyntaxChecker] Event:OnBeforeDocFormSave
    [] (ERROR @ /connectors/resource/index.php) [OnBeforeDocFormSave]Array
    (
        [0] => htmlent
    )


    Do you have any idea what could be the reason for this?


  • MokoJumbie Reply #10, 2 months, 1 week ago

    Reply
    I like where this is going. Great idea for a plug-in.

    I just started testing it and wanted to pass along this error I'm getting:

    Error:
    tv.sponsor_logo tag is missing question mark to separate it from its parameters. tv.sponsor_logo's h property must be quoted with backticks (`), NOT apostrophes!

    ...for the following placeholder in a getResources tpl:

    [[+tv.sponsor_logo:phpthumbof=`w=140&h=140`]]


    The Syntax checker doesn't understand that it's possible to be in a different parsing context within the backticks of an output filter. Maybe for now it'd be enough to just ignore the contents of output filter parameters, but it would be nice if those could eventually be parsed as well.