Forums / Setup & design / WebDAV works on one site but not the other

WebDAV works on one site but not the other

Author Message

Linh Vu

Tuesday 02 May 2006 8:18:46 am

I have two websites running on two identically set up servers (Debian Sarge, Apache2, PHP 4.3.10-sarge16 running as Apache2 module, ezPublish 3.6.5). The only difference is that one runs MySQL 4.1 and the other MySQL 5.0.19. The latter is the problematic one with WebDAV, but everything else works fine. Not sure if it's MySQL related but I'll mention it anyway.

DNS is setup properly and working. Both are of the type webdav.example.com, which is a CNAME of example.com

I followed the webdav guide from Documentation to set it up. I added this to settings/override/webdav.ini.append.php

[GeneralSettings]
EnableWebDAV=true

I added a mod_rewrite rule to the Apache2 Virtual Host config for each site:

RewriteEngine On
RewriteRule !\.(css|jar|js|html|htm|php)$ /webdav.php [L]

Then Apache2 is restarted and all cache is cleared. I use cadaver, Nautilus and Internet Explorer to test webdav. The first site works. The second doesn't. 'home' is my default siteaccess and this is the error I got with cadaver:

linh@mypc~$ cadaver http://webdav.example.com
dav:/> ls
Listing collection `/': succeeded.
Coll:   home                                  0  Apr 30 23:08
dav:/> cd home
Could not access /home/ (not WebDAV-enabled?):
404 Not Found
dav:/>

Enabling Logging only shows me that it was trying to access the above URI. The site that works would show me Content and Media when I cd into /home/ and everything works.

I also tried adding the EnableWebDAV=true part to settings/siteaccess/home/webdav.ini.append.php for the second site, but that doesn't help either. I think WebDAV must be working to a certain extent as I can make the initial connection but don't know why it doesn't work any further than that. Any idea? Thanks a lot in advance.

If I had more time, I would write less code.

Kristof Coomans

Tuesday 02 May 2006 9:49:54 am

Did you also take a look in the site-specific webdav.log?

Log messages of a WebDAV request always start in var/log/webdav.log but as soon as you enter a site ( like "/home" in your case ) the log continues in var/[yoursitesvardir]/log/webdav.log.

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Linh Vu

Tuesday 02 May 2006 4:55:39 pm

Hi Kristof,

Thanks for the suggestion. It only went as far as var/log/webdav.log and didn't create var/<siteaccess_dir>/log/webdav.log (which sort of makes sense since it can't find the siteaccess and returns a 404).

The error in var/log/webdav.log says:

2006-05-03 09:39:58 : PROPFIND was issued from client. [processClientRequest]
2006-05-03 09:39:58 : Depth: 1. [processClientRequest]
2006-05-03 09:39:58 : Root: Fethcing site list [CS:getCollectionContent]
2006-05-03 09:39:58 : Client requesed 7 properties. [outputCollectionContent]
2006-05-03 09:39:58 : XML was parsed [outputCollectionContent]
2006-05-03 09:39:58 : handle function was called with status: 11 [handle]
2006-05-03 09:40:00 : ========================================
2006-05-03 09:40:00 : Requested URI is: /home/ [webdav.php]
2006-05-03 09:40:00 : start path: /home/ [CS:currentSitePath]
2006-05-03 09:40:00 : indexdir: home/ [CS:currentSitePath]
2006-05-03 09:40:00 : no valid site was found.. [CS:currentSitePath]

This siteaccess home works fine with the normal HTTP index.php access. Here's my override/site.ini.append.php:

[SiteSettings]
DefaultAccess=home
SiteList[]=home
IndexPage=/content/view/full/2/
DefaultPage=/content/view/full/2

....

[SiteAccessSettings]
CheckValidity=false
AvailableSiteAccessList[]=home
AvailableSiteAccessList[]=admin
MatchOrder=uri
HostMatchMapItems[]

Just standard stuff, and the other site which has a very similar setup works fine.

If I had more time, I would write less code.

Kristof Coomans

Tuesday 02 May 2006 11:44:11 pm

I compared your log with a WebDAV log of mine and this line in yours:

indexdir: home/ [CS:currentSitePath]

is in my log:

indexdir: /home/[CS:currentSitePath]

I guess it has something to do with the leading slash that's missing.

The problem is somewhere in kernel/classes/webdav/ezwebdavcontentserver.php in the method currentSiteFromPath.

After

$indexDir = eZSys::indexDir();

place this code:

$this->appendLogEntry( 'eZSys::indexDir: ' .  $indexDir, 'CS:currentSitePath');

And what do you get in the webdav log now?

I got:

eZSys::indexDir:  [CS:currentSitePath]

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Linh Vu

Wednesday 03 May 2006 6:01:11 am

That's a great spot, Kristof, thanks! I just checked my sites and the working one has the leading slash, while the problematic one doesn't. This has something to do with the preg_match on REQUEST_URI in that method you pointed out, which essentially means that ezPublish thinks that the problematic site isn't in virtual host mode (it is). I'll do some tests now. Will post here when I get the results.

Edit: I got "/" for indexdir.

2006-05-03 23:36:15 : start path: /home/ [CS:currentSitePath]
2006-05-03 23:36:15 : eZSys::indexDir: / [CS:currentSitePath]
2006-05-03 23:36:15 : indexdir: home/ [CS:currentSitePath]

And I got it to work by commenting this part out in that method:

// Remove indexDir if used in non-virtualhost mode.
        //if ( preg_match( "#^" . preg_quote( $indexDir ) . "(.+)$#", $path, $matches ) )
        //{
         //   $path = $matches[1];
        //}

Somehow my REQUEST_URI matches that pattern on this server, and it strips the leading slash off indexdir. It might have something to do with me running a replace script to change 'ezurl' to 'ezroot' on the templates of this site, but I can't find any template that this webdav server uses yet. Will look closer.

Thanks again for the suggestion. :)

If I had more time, I would write less code.

Kristof Coomans

Thursday 04 May 2006 11:55:11 pm

Maybe we can trace the problem by inspecting eZSys a little bit more.

In lib/ezutils/classes/ezsys.php, look for the function indexDir.
Change it's last two lines to this:

eZDebug::writeDebug( 'eZSys::wwwDir(): ' . $instance->wwwDir() );
eZDebug::writeDebug( 'eZSys::indexFile: ' . $instance->indexFile( $withAccessList ) );
$indexDir = $instance->wwwDir() . $instance->indexFile( $withAccessList );
return $indexDir;

Now try to access the site with WebDAV again and tell me what you get in the debug log file.

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org