(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??!!!
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."
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.