Not logged in. · Lost password · Register
Forum: Support Bug reports and troubleshooting RSS
No "calendar extension" support patch
Avatar
puck #1
Member since May 2008 · 13 posts · Location: Warsaw, Poland
Group memberships: Members
Show profile · Link to this post
Subject: No "calendar extension" support patch
I didn`t find this in the docs, but the PHP is required to be compiled with the calendar extension. You may not see this at the begining, but some calendar functions are used when moving posts and leaving "moved note". On a production server, when trying to do that action you end up with a blank page and an error message in the logs: PHP Fatal error:  Call to undefined function unixtojd()
Since calendar extension isn`t the default in PHP, some may want to run UNB without it. Here`s the path:

unb_lib/main.inc.php, lines around #390:
    days = 14;
    if (rc('moved_thread_note_timeout')) $days = intval(rc('moved_thread_note_timeout'));
    // The moved note should be visible that amount of time from TODAY on, not the last 
    // post date, as it is calculated in IThread.IsMovedExpired() which is used to remove
    // expired threads in UnbListThreads().
// $days += unixtojd() - unixtojd($thread->GetLastPostDate());
    $days += (time() / 86400 + 2440587.5) - ($thread->GetLastPostDate()/86400 + 2440587.5);
I`m not sure if the calculations are right, found them in comments in PHP manual.  Hope it helps someone.

Maybe use some strtotime calculations instead of the unixtojd function? Dunno the pros and cons, but it seems that it would drop the extension requirement...
Avatar
Yves (Administrator) #2
User title: UNB developer & webmaster
Member since Jan 2004 · 3814 posts · Location: Erlangen, Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Good point. I had to look up all uses of that function to find it myself. Frankly I wouldn't believe that I use this function... And now that I read that code, I'm not 100% sure what it does. But it looks as if it could easily be replaced by some simpler maths, like

$days = time() + $days * 86400;

(No guarantee that it works. This is only a guess. Testing this feature always takes more than a day...)
♪ ...nanananah, all in all we’re just brilliant thieves, nanananah... ♪♬
Avatar
Yves (Administrator) #3
User title: UNB developer & webmaster
Member since Jan 2004 · 3814 posts · Location: Erlangen, Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Alright, my guess was entirely wrong. After digging some more in the code, I am now testing this code for another 2 days:

$days += round((time() - $thread->GetLastPostDate()) / 86400);

The only thing that this line does is adding the days between now and LastPostDate to $days, so that the "thread moved" notification timeout (specified in days) counts from now on, instead of LastPostDate. I'm not sure why I took the Julian date function in this case, as calculating with seconds (UNIX timestamps) is fairly easy as well, at least to get the number of days.

My new code is equivalent to your proposal, as it can be mathematically transformed from it.
♪ ...nanananah, all in all we’re just brilliant thieves, nanananah... ♪♬
Avatar
puck #4
Member since May 2008 · 13 posts · Location: Warsaw, Poland
Group memberships: Members
Show profile · Link to this post
Yeah, you`re right. I just replaced unixtojd with an alternative statement, and didn`t do the simple math on it. :-)
Avatar
Yves (Administrator) #5
User title: UNB developer & webmaster
Member since Jan 2004 · 3814 posts · Location: Erlangen, Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Alright, that works. It will be included in the next release.
♪ ...nanananah, all in all we’re just brilliant thieves, nanananah... ♪♬
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Go to forum
This board is powered by the Unclassified NewsBoard software, 20110527-dev, © 2003-2011 by Yves Goergen
Page created in 199.9 ms (106.4 ms) · 62 database queries in 140.7 ms
Current time: 2012-02-07, 20:31:51 (UTC +01:00)