Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

CommentTime changes willy-nilly, posts rendering out of order

First and foremost, thank you to everyone who has contributed to Vanilla. I've been using it for over a year and a half to run the forums for my fake trivia website,, and I really couldn't be more pleased with it. If you're interested, the forums are at

All that being said, I've been having some problems as of late, which I have been unable to resolve. Without any pattern that I can identify, posts are displaying out of order and the time at which they were posted will jump around between page loads. Load the front page of the forums once, and it will say "Last Active 13 minutes ago", reload the page and it'll say "Last Active 23 hours ago". You can see the problem for yourself if you open up the front page and reload a few times.

I've checked a the possible problems I could think of but to no avail:

* Date times are being written and served up by the MySQL DB correctly
* The server knows what time it is
* I don't think it's a problem with the post IDs (I've currently got 32796 posts on my forum) bumping up against some sort of limit, but I'm not sure of that.

I'm wracking my brain trying to get this fixed, but I have had no luck thus far. Any and all help would be very greatly appreciated.


  • Options
    I watched this for a bit, but couldn't figure out any pattern. Incase someone else might need it, here are the server's timestamps and the corresponding comment times:08·Nov·2007·12:31:12·GMT = 3 hours ago 08·Nov·2007·12:34:13·GMT = 2 hours ago 08·Nov·2007·12:35:49·GMT = 3 hours ago 08·Nov·2007·12:36:34·GMT = 3 hours ago 08·Nov·2007·12:39:53·GMT = 2 hours ago 08·Nov·2007·12:43:41·GMT = 2 hours ago 08·Nov·2007·12:44:41·GMT = 2 hours ago 08·Nov·2007·12:49:55·GMT = 2 hours ago 08·Nov·2007·12:53:28·GMT = 2 hours ago 08·Nov·2007·12:55:02·GMT = 2 hours ago 08·Nov·2007·12:58:28·GMT = first comment-3 hours ago, second comment-2 hours ago 08·Nov·2007·12:58:28·GMT = first comment-3 hours ago, second comment-2 hours ago 08·Nov·2007·13:07:12·GMT = first comment-3 hours ago, second comment-2 hours ago

    Are you aware that 32,767 is an actual data type limit? Vanilla should allow IDs larger than that though.

    One thing I would try is add one line to library/framework/Framework.Functions.php like this:// Convert a datetime to a timestamp function UnixTimestamp($DateTime) { return strtotime($DateTime);
  • Options
    edited November 2007
    Thanks, Wallphone. I tried changing the function to
    // Convert a datetime to a timestamp function UnixTimestamp($DateTime) { if (preg_match('/^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/', $DateTime, $Matches)) { $Year = $Matches[1]; $Month = $Matches[2]; $Day = $Matches[3]; $Hour = $Matches[4]; $Minute = $Matches[5]; $Second = $Matches[6]; return mktime($Hour, $Minute, $Second, $Month, $Day, $Year); } elseif (preg_match('/^(\d{4})-(\d{2})-(\d{2})$/', $DateTime, $Matches)) { $Year = $Matches[1]; $Month = $Matches[2]; $Day = $Matches[3]; return mktime(0, 0, 0, $Month, $Day, $Year); } else { return strtotime($DateTime); } }

    But it gave me the following error
    Warning: strtotime() [function.strtotime]: Called with an empty time parameter. in /home/gullible/public_html/factcheck/library/Framework/Framework.Functions.php on line 771
  • Options
    edited November 2007
    Hello wallphone
    I was trying to help Kyle, but as I do not know unix, vanilla or PHP I may be more of a hinderance. However I am a programmer. I suggested he now change this to:

    function UnixTimestamp($DateTime)
    if (preg_match('/^(d{4})-(d{2})-(d{2}) (d{2}):(d{2}):(d{2})$/', $DateTime, $Matches))
    $Year = $Matches[1];
    $Month = $Matches[2];
    $Day = $Matches[3];
    $Hour = $Matches[4];
    $Minute = $Matches[5];
    $Second = $Matches[6];
    return mktime($Hour, $Minute, $Second, $Month, $Day, $Year);
    } elseif (preg_match('/^(d{4})-(d{2})-(d{2})$/', $DateTime, $Matches))
    $Year = $Matches[1];
    $Month = $Matches[2];
    $Day = $Matches[3];
    return mktime(0, 0, 0, $Month, $Day, $Year);

    } else

    return strtotime($DateTime);
    catch ( Exception $e )
    echo 'Caught exception. Used current unix timestamp instead of passed invalid datetime: ' . $DateTime;
    return time();

    If he throws an exception Is there anyway to get a stack trace to see where this is coming from.

    eg catch (Exception e) { echo e.stacktrace ; } <== this is the .Net way of doing it, but the names have been changed to protect the guilty
  • Options
    Paul--Exceptions aren't really used in Vanilla, the closest thing would be the ErrorManager and NoticeCollector objects in the framework. You could use a print_r($e) to read all the properties in an thrown exception.

    Kyle--Try strtotime as the first line inside the function--not in the IFs... It should always be passed a value, so I'm not quite sure why it would be throwing that message... You could also try echoing the $TimeStamp to see the raw MySql times that are being passed. According to the documentation on, You may have to append GMT to the timestamp on PHP versions prior to 5, such as strtotime($TimeStamp . ' GMT');
  • Options
    The 'ifs' will not affect it as the regexes will drop through. You are right though, we need to see the time stamp.

    In terms of the stack trace is there any way you can call "SystemStackTrace" so it will return

    SystemTrackTrace called from MySubRoutine line 23
    MySubroutine called from OtherRoutine line 173
    OtherRoutine called from ResponseHandler line 27

    I guess this is a PHP question rather than Vanilla, but I didn't want to learn a complete language and environment for one problem. I've already written in over 50.
  • Options
    I wasn't aware of a stack trace function, but found it: debug_backtrace
  • Options
    Apologies for necroing this thread, but I'm having the exact same issues with our install of Vanilla 1.1.5a as Kyle's first post. Did you guys ever figure out what was going on? What information do you need to help diagnose the issue?
  • Options
    In case anyone else runs into this, it turns out this was an issue with another Apache process on the same server setting the $TZ environmental variable. I put putenv('TZ='); in conf/settings.php to manually clear the variable on each request, and it seems to have fixed it. For more detail, check the Server Fault thread I created on the subject.
  • Options
    Question: has the mktime() function been changed or has the above mentioned function (I mean UnixTimestamp()) been updated or changed in any way? We are getting lots of errors on our forum due to the mktime() function such as:
    It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting 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 'America/Los_Angeles' for 'PST/-8.0/no DST' instead in /nfs/c02/h04/mnt/25079/domains/ on line 925
    Im currently also unable to update the forum or anything. Any suggestions?
    We're currently running Vanilla 1.1.8
  • Options
    ToddTodd Chief Product Officer Vanilla Staff
    @Subjunk is the Vanilla 1 guy.
  • Options
    @Todd: Thanks for letting me know.

    @stinger: That error indicates your server has not been configured properly.
    Older versions of PHP didn't require you to set your timezone, so people could get away with it, but a recent update (if I remember correctly it was 5.2) made it required.
    The best way to fix this is to uncomment the "date.timezone" line in your server's php.ini file by removing the semicolon at the beginning of the line.

    As for your update problems, I'm currently in the process of developing the next release of Vanilla 1 which moves the project to its own website and fixes update checking. You have good timing since the update checking is working now, so if you want to receive future updates you can update to the latest code which is available for download here
  • Options
    Hey @SubJunk, thanks for your reply!

    Looks like our hosting (mediatemple) indeed updated to php 5.2. This causes a lot of strange errors and all of those were parsed to the screen.

    I was finally able to update a couple of files by simply adding a date_default_timezone_set() setting. A bit of a crude hack, but it seems to work. I've noticed a few other glitches but they aren't really important (e.g. the function split() is being used by the extension AutoLinks that we had installed, but apparently that is also depricated by php 5.2 - it's not very important though)

    Updating doesn't seem to work just yet for me at the moment: when I go to the settings tab, Updates & Reminders and click "check for updates now" it says "Vanilla 1.1.8 UNKNOWN". All the extensions keep checking for updates but never finish...

    Should I manually update? Just upload all the new files from that download?

    I'm quite anxious to do that as I have limited knowledge of coding and am afraid I might mess up the entire forum (some 60 people rely on me to keep it working more-or-less in good order...)

    Sorry for all the questions, just trying to keep our forum from crashing :)
  • Options
    @stinger: Yes, you will need to manually update with the file I posted in order for updating to work in the future. Update checking won't work again in 1.1.8 because the update URL and code have been changed, it will only work in the upcoming release and the pre-release that I posted above.

    If you haven't modified any core files on your forum, it is safe to just overwrite all your old ones with the new ones.
    As always it is a good idea to make a backup just in case :)

    Also, you're in luck with the AutoLinks extension. When you run an update check (after copying the new Vanilla files over your old ones) it will find an update for you, please let me know if it works :)
  • Options
    SubJunkSubJunk ✭✭
    edited November 2011
    @stinger: If you haven't done the update already, I have built a newer update for you which improves the update checker again. You can download it here
  • Options
    @SubJunk: hey thanks for all this man! Just downloaded the latest version. I'll try as soon as I have a bit of spare time, in case things go haywire. Should be ok as you wrote, but I'm still a bit anxious :) I do recall making some manual changes for the layout (css stuff) but that should be fairly ok??

    If I back up all the current files and it won't work properly, can I just overwrite the new files (manually) again with the old files? Will that bring back the forum as it is right now? (even though it is a little glitchy, it does still work for us).

    Thanks again dude
  • Options
    @stinger: If you made CSS changes to the main theme they will be overwritten (as they always would in an update, since those are core files), but if you created a new theme before editing it you'll be OK.
    Like you said, if the update doesn't work you can just overwrite the new files with the old ones and it will be back to how it was.
    You're very welcome :)
  • Options

    @SubJunk: thanks for all the advice and info, this helps a lot! To be honest I don't remember whether I made those changes to the core files or to a theme, it's too long ago... Will be a matter of time and to find out though :)

    One of our members offered another option: installing vanilla 2 alongside the current install (we have another database we could use) and then migrate all the content from the current database to the new one. Does the new database (for vanilla 2) have the same structure at all? Or will it be impossible to migrate from 1 to 2?

    I've been searching here on the community but have (yet) been unable to find any posts about this. Might be an even nicer solution since that way we'd be able to use all the new and shiny functions?

  • Options

    @stinger: Yes, you can change to Vanilla 2 if you want. There is a tool available for download somewhere (used to be on this website, might still be) that converts the Vanilla 1 database to Vanilla 2.
    I haven't had success with Vanilla 2 personally (hence why I am working on Vanilla 1 now instead) but I do recommend you try it for yourself and see which you like better :)

  • Options

    @SubJunk: hmm, ok! So now things are getting interesting... what kind of issues did you run into with Vanilla 2 then? Did you write about it here on the site (maybe this:

    Quite a job you've taken on to keep Vanilla 1 alive I take it? Pretty awesome that you are doing this. Will now definitely have to consider just sticking to the current working system!

  • Options

    @stinger: The issues I had with version 2 have probably been fixed now and I think Vanilla 2 is good and worth trying.

    I think Vanilla 1 is still a worthy alternative and it is best to try both to see which you prefer :)

    I run a lot of websites on Vanilla 1 and so I am basically developing features and improvements for myself, so it made sense to release those changes for other people too instead of just keeping them to myself, so yeah it is an undertaking but not too bad :)

Sign In or Register to comment.