We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 18409
    • 54 Posts
    (Apologies, I seem to be posting quite a lot of questions, but there is little documention on writing snippets so not sure what else to do, and I can’t find anything in the forum search about this)

    I have a basic calendar php script that runs fine outside of modx.

    When I try to run it as a snippet however, it runs for ages, and then gives a fatal php error about max execution time being exceeded.

    Originally I had HTML code mixed in with the php code, which I found out you can’t do, and so the basic "enter entry" form now displays.
    (Using snippet call of [[calendar? &page=`addentry`]])

    However, if I try to display the calendar, which is much more complex code, it just times out.

    I commented out the whole "display" php file of code except a test "echo" command which worked OK.

    As soon as uncommented the next line which is:
    $year=date("Y");

    It started timing out again, and there are no errors in the modx logs. The apache logs only show the fatal php error which isn’t any use to me.

    This is really frustrating, it seems that any slight problem in the snippet code, rather than returning an error simply times out. Also, it isn’t a php error as such because the code runs fine out of modx so I don’t have a clue what I am looking for to fix this.

    Anyone any ideas??!!!
      • 7923
      • 4,213 Posts
      I don’t believe that it’s the date() call.. Can you show the exact code that you are trying to run, snip it down as much as possible..


        "He can have a lollipop any time he wants to. That's what it means to be a programmer."
        • 18409
        • 54 Posts
        It was the date call. I tried a very basic snippet:
        <?php
        echo date("Y");
        ?>
        which also failed.

        After much trial and error, I put the timezone into the php.ini file and everything was instantly fine.

        I would consider this to be a bug with Modx of some sort, because the script worked fine out of modx.

        System is win XP (this is a test/development system), php 5.2, mysql 5, modx 0.95.

        I haven’t yet tried this on a production lamp system.

          • 22303 MODX Staff
          • 10,725 Posts
          Please see the first section regarding changes in PHP datetime support at http://www.php.net/UPDATE_5_2.txt -- I’ll look into a way to use date_default_timezone_set() to try and alleviate the problem when encountering these misconfigurations of PHP, at least when running MODx.

          If you wouldn’t mind, a bug report to track this issue would be great...