Class DateTime not found

383 views
Skip to first unread message

Hatem Ounis

unread,
Feb 25, 2010, 8:13:04 AM2/25/10
to SabreDAV Discussion
Hi,

i'm using the browser plugin to access to my SabreDAV server it lists
files creates a new folder and uploads files.

But when downloading files i get this error message:

( ! ) Fatal error: Class 'DateTime' not found in /lib/Sabre/DAV/
Server.php on line 308
Call Stack
# Time Function Location
1 0.0001 {main}( ) ../index.php:0
2 0.0029 Sabre_DAV_Server->exec( ) ../index.php:37
3 0.0029 Sabre_DAV_Server->invoke( ) ../Server.php:112
4 0.0033 call_user_func ( ) ../Server.php:697
5 0.0033 Sabre_DAV_Server->httpGet( ) ../Server.php:0

my server is a Red Hat i686 i386 GNU/Linux, PHP Version 5.1.6, Apache/
2.2.8 (Unix)

when i put the line 308 in Server.php as comment the download works
well.

Could you please tell me what that line is standing for ? and what
could happen when i comment it ?

Hatem Ounis

Mattijs

unread,
Feb 25, 2010, 8:18:58 AM2/25/10
to SabreDAV Discussion
Hi Hatem,

Line 308 refrences the DateTime class. This class was introduced in
PHP version 5.2. I see you are using PHP 5.1.6 which means the
DateTime class does not exist. This is what is causing the error I
think.

You could consider the upgrading the PHP installation to a version
higher than 5.2 to get this to work. Also see the PHP manual on
DateTime: http://nl3.php.net/manual/en/datetime.installation.php

I did not find any mention of minimum requirements for SabreDav on the
wiki other than PHP 5. Maybe we should change this?

cheers,
mattijs

Evert Pot

unread,
Feb 25, 2010, 8:48:42 AM2/25/10
to sabredav...@googlegroups.com

On 2010-02-25, at 10:18 PM, Mattijs wrote:
>
> I did not find any mention of minimum requirements for SabreDav on the
> wiki other than PHP 5. Maybe we should change this?

Added it here:
http://code.google.com/p/sabredav/wiki/Installation

Since you mention 'we', I'd be happy to enlist you as a contributor, just send me your gmail account.

@Hatem:

If you really can't upgrade, you could try to substitute the DateTime class with a PHP version. The class below you be an absolute minimal version of what I believe is needed.
I have no idea what else would break on PHP 5.1 though. PHP 5.2 has been around since early 2007

class DateTime {

public $time;

const RFC1123 = 'D, d M Y H:i:s O';

function __construct($time) {

$this->time = strtotime($time);

}

function format($format) {

return date($this->time, $format);

}

}


hatem ounis

unread,
Mar 4, 2010, 9:29:02 AM3/4/10
to sabredav...@googlegroups.com
Hi,

now it's the 'DateTimeZone' that gives the error:

( ! ) Fatal error: Class 'DateTimeZone' not found in lib/Sabre/DAV/Property/GetLastModified.php on line 54

Evert

unread,
Mar 5, 2010, 4:34:11 AM3/5/10
to SabreDAV Discussion
Forgot about that one. You really should just try to install the
extension.. It's not that difficult..

But if you must..

class DateTimeZone { }

will do it, I think.. Just remember that timezones might no longer be
entirely correct after that.

hatem ounis

unread,
Mar 5, 2010, 5:14:37 AM3/5/10
to sabredav...@googlegroups.com
Thanks for the hint.

But it's not about installing the extention, i must respect the versions because i'm not the owner of the project.

hatem ounis

unread,
Mar 8, 2010, 6:45:35 AM3/8/10
to sabredav...@googlegroups.com
class DateTimeZone { }

didn't solve the problem i have an error about 2 nd parameter of date() must be long but it's geting a string.

hatem ounis

unread,
Mar 8, 2010, 8:29:14 AM3/8/10
to sabredav...@googlegroups.com
it's ok i solved the problem:

in the class DateTime:

return date($this->time, $format);

must be:

return date($format , $this->time);

but the problem is that i still unable to mount the webdav folder as described here http://groups.google.com/group/sabredav-discuss/browse_thread/thread/fe977b59d3d0fcb6
Reply all
Reply to author
Forward
0 new messages