phpgroupware-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpgroupware-cvs] phpgwapi/inc class.vfs_dav.inc.php, 1.6 class.http_da


From: Caeies
Subject: [Phpgroupware-cvs] phpgwapi/inc class.vfs_dav.inc.php, 1.6 class.http_dav_client.inc.php, 1.10
Date: Sun, 3 Apr 2005 20:49:00 +0200

Update of phpgwapi/inc

Modified Files:
     Branch: MAIN
            class.vfs_dav.inc.php lines: +31 -9
            class.http_dav_client.inc.php lines: +58 -25

Log Message:
Solve caching problems for copy, adding debuging clarity, solve other potential 
problems, still work in progress

====================================================
Index: phpgwapi/inc/class.vfs_dav.inc.php
diff -u phpgwapi/inc/class.vfs_dav.inc.php:1.5 
phpgwapi/inc/class.vfs_dav.inc.php:1.6
--- phpgwapi/inc/class.vfs_dav.inc.php:1.5      Sun Feb 20 14:13:16 2005
+++ phpgwapi/inc/class.vfs_dav.inc.php  Sun Apr  3 18:49:19 2005
@@ -780,13 +780,14 @@
                                $token =  
$this->override_locks[$p->real_full_path];
                                
$status=$this->dav_client->put($this->dav_path($p->real_full_path),$data['content'],$token);
 $this->debug('Put complete,  status: '.$status);
-                               if($status!=201 && $status!=204)
+                               if(intval($status) != 201 && intval($status) != 
204)
                                {
+$this->debug('The file was not created !');
                                        return False;
                                }
                                else
                                {
-
+$this->debug('The file was created !');
                                        /*
                                           If 'string' doesn't exist, touch () 
creates both the file and the database entry
                                           If 'string' does exist, touch () 
sets the modification time and modified by
@@ -794,7 +795,8 @@
                                        $this->touch (array(
                                                        'string'        => 
$p->fake_full_path,
                                                        'relatives'     => 
array ($p->mask)
-                                               )
+                                               ),
+                                               true
                                        );

                                        $this->correct_attributes (array(
@@ -811,7 +813,7 @@
                /*
                * See vfs_shared
                */
-               function touch ($data)
+               function touch ($data,$_inwrite=false)
                {
                        $default_values = array(
                                                'relatives'     => array 
(RELATIVE_CURRENT)
@@ -859,6 +861,11 @@
                                                'operation'     => PHPGW_ACL_ADD
                                        ))
                                ) return False;
+                               if ( $_inwrite )
+                               {
+                                       _debug_array($data);
+                                       die('should be already created ! Please 
Fill a bug report !!');
+                               }
                                $result = $this->write (array(
                                                      'string'  => 
$data['string'],
                                                      'relatives'       => 
array ($data['relatives'][0]),
@@ -890,7 +897,8 @@
                        $data = array_merge ($this->default_values ($data, 
$default_values), $data);

                        $account_id = 
$GLOBALS['phpgw_info']['user']['account_id'];
-
+$this->debug('cp : data :');
+$this->debug($data);
                        $f = $this->path_parts (array(
                                        'string'        => $data['from'],
                                        'relatives'     => array 
($data['relatives'][0])
@@ -910,6 +918,7 @@
                                ))
                        )
                        {
+$this->debug('cp : from forbidden by ACL !');
                                return False;
                        }

@@ -933,6 +942,7 @@
                                                     ))
                            )
                        {
+$this->debug('cp to forbidden by ACL');
                                return False;
                        }

@@ -966,14 +976,18 @@
                            }
                                else
                                {
-                                       
$status=$this->dav_client->copy($this->dav_path($f->real_full_path), 
$t->real_full_path,True, 'Infinity', $this->override_locks[$p->real_full_path]);
+                                       
$status=$this->dav_client->copy($this->dav_path($f->real_full_path), 
$t->real_full_path,True, 'Infinity', $this->override_locks[$t->real_full_path]);
                                    $result = $status == 204 || $status==201;
                                    if (!$result)
                                    {
+$this->debug('cp : Failed : '.$status);
                                        return False;
                                    }
                                 }
-
+$this->debug('cp : from');
+if(DEBUG) _debug_array($f);
+$this->debug('cp : to');
+if(DEBUG) _debug_array($t);
                                 //Copy should copy the app too it's a dead 
property .
                                $this->set_attributes(array(
                                        'string'        => $t->fake_full_path,
@@ -984,6 +998,7 @@
                                                        )
                                                )
                                        );
+$this->debug('cp : success '.$result);
                                return $result;

                        }
@@ -1591,7 +1606,14 @@
                        }

                        $xmlns = 'xmlns:dc="http://purl.org/dc/elements/1.1/";';
-                       
$this->dav_client->proppatch($this->dav_path($p->real_full_path), 
$dav_properties, $xmlns, $this->override_locks[$p->real_full_path]);
+                       if ( !$p->outside )
+                       {
+                               
$this->dav_client->proppatch($this->dav_path($p->real_full_path), 
$dav_properties, $xmlns, $this->override_locks[$p->real_full_path]);
+                       }
+                       else
+                       {
+                               //What are we doing in this case ???
+                       }
                        return True;
                }


====================================================
Index: phpgwapi/inc/class.http_dav_client.inc.php
diff -u phpgwapi/inc/class.http_dav_client.inc.php:1.9 
phpgwapi/inc/class.http_dav_client.inc.php:1.10
--- phpgwapi/inc/class.http_dav_client.inc.php:1.9      Sun Feb 20 16:45:37 2005
+++ phpgwapi/inc/class.http_dav_client.inc.php  Sun Apr  3 18:49:19 2005
@@ -423,7 +423,10 @@
                        $this->http_client->addHeader( 'user-agent', 
'Mozilla/5.0 (compatible; PHPGroupware dav_client/1; Linux)');
                        $this->propfind_restore_session();
 if(DEBUG_CACHEPROP)    unset($this->cached_propfind);
-                       return 
$this->http_client->Connect($dav_host,$dav_port,$ssl);
+                       $ret = 
$this->http_client->Connect($dav_host,$dav_port,$ssl);
+                       $this->server = $this->http_client->url['scheme'] . 
'://'.$this->dav_host;
+                       $this->server .= (empty($this->dav_port)) ? '' : 
':'.$this->dav_port;
+                       return $ret;
                }

                function set_debug($debug)
@@ -462,19 +465,19 @@
                        $request_id = $url.'//'.$scope.'//'.$sorted; //A unique 
id for this request (for caching)
                        if ($this->cached_props[$request_id])
                        {
-if (DEBUG_CACHE) echo'Cache hit : cache id:'.$request_id;
+if (DEBUG_CACHE) echo'Get properties: Cache hit : cache id:'.$request_id.'<br 
/>';
                                $props = 
$this->cached_props[$request_id]['data'];
                                return 
$this->cached_props[$request_id]['status'] != 401;
                        }
                        else if (! $sorted && 
$this->cached_props[$url.'//'.$scope.'//1'])
                        {
-if (DEBUG_CACHE) echo ' Cache hit : cache id: '.$request_id;
+if (DEBUG_CACHE) echo 'Get propetries: Cache hit : cache id: 
'.$request_id.'<br />';
                                $props = 
$this->cached_props[$url.'//'.$scope.'//1']['data'];
                                return 
$this->cached_props[$request_id]['status'] != 401;
                        }
 if (DEBUG_CACHE)
 {
-       echo ' <b>Cache miss </b>: cache id: '.$request_id;
+       echo ' <b> get_properties: Cache miss </b>: cache id: '.$request_id. 
'<br />';
 /*     echo " cache:<pre>";
        print_r($this->cached_props);
        echo '</pre>';*/
@@ -485,9 +488,11 @@
                        {
                                $this->cached_props[$request_id]['status'] = 
$ret;
                                //_debug_array('You are not supposed to see 
this message');
+                               //_debug_array('Ret : '.$ret.'<br />');
                                //The following condition should never occurs
-                               if($ret == 404 || $ret == 401 || ($ret = 
$this->propfind($url.SEP,$scope)) != 207)
+                               if($ret == 404 || $ret == 401 || ($ret = 
$this->propfind($url.'/',$scope)) != 207)
                                {
+                                       //_debug_array('Returning empty array 
:/ for '.$url);
                                        
$this->cached_props[$request_id]['status'] = $ret;
                                        $props = array();
                                        return $ret != 401;
@@ -600,8 +605,8 @@
                $uri = $this->encodeurl($uri);
 if (DEBUG_CACHE) echo '<b>cache cleared</b>';
                $this->cached_props = array();
-if (DEBUG_CACHEPROP) echo '<b>cache propfind ('.$uri.') setted</b>';
-               $this->cached_propfind[$uri] = 200;
+if (DEBUG_CACHEPROP) echo '<b>uncached propfind ('.$uri.')</b>';
+               unset($this->cached_propfind[$uri]);
                if (strlen($token))
                {
                        $this->http_client->addHeader('If', '<'.$uri.'>'.' 
(<'.$token.'>)');
@@ -626,14 +631,22 @@
                {
                        $srcUri = $this->encodeurl($srcUri);
                        $destUri = $this->encodeurl($destUri);
-if (DEBUG_CACHE) echo '<b>cache cleared</b>';
+if (DEBUG_CACHE) echo '<b>cp cache cleared</b>';
                        $this->cached_props = array();
+if ( DEBUG_CACHEPROP) echo '<b>cp propfind unseted</b><br />';
+                       $this->delete_uri_in_cache($destUri);
+
                        if (strlen($token))
                        {
                                $this->http_client->addHeader('If', 
'<'.$uri.'>'.' (<'.$token.'>)');
                        }
                        $result = $this->http_client->Copy( $srcUri, $destUri, 
$overwrite, $scope);
                        $this->http_client->removeHeader('If');
+                       if ( $result == 204 )
+                       {
+if ( DEBUG_CACHEPROP) echo '<b>cp propfind setted</b><br />';
+                               $this->cached_propfind[$destUri] = 207;
+                       }
                        return $result;
                }

@@ -654,10 +667,8 @@
 if (DEBUG_CACHE) echo '<b>cache cleared</b>';
                        $this->cached_props = array();
 if (DEBUG_CACHEPROP) _debug_array('cache prop cleared');
-                       unset($this->cached_propfind[$srcUri]);
-                       unset($this->cached_propfind[$srcUri.'/']);
-                       unset($this->cached_propfind[$destUri]);
-                       unset($this->cached_propfind[$destUri.'/']);
+                       $this->delete_uri_in_cache($srcUri);
+                       $this->delete_uri_in_cache($destUri);
                        if (strlen($token))
                        {
                                $this->http_client->addHeader('If', 
'<'.$uri.'>'.' (<'.$token.'>)');
@@ -681,8 +692,7 @@
 if (DEBUG_CACHE) echo '<b>cache cleared</b>';
                        $this->cached_props = array();
 if (DEBUG_CACHEPROP) _debug_array('cache prop cleared');
-                       unset($this->cached_propfind[$uri]);
-                       unset($this->cached_propfind[$uri.'/']);
+                       $this->delete_uri_in_cache($uri);
                        if (strlen($token))
                        {
                                $this->http_client->addHeader('If', 
'<'.$uri.'>'.' (<'.$token.'>)');
@@ -702,15 +712,19 @@
                function mkcol( $uri, $token='' )
                {
                        $uri = $this->encodeurl($uri);
-if (DEBUG_CACHE) echo '<b>cache cleared</b>';
+if (DEBUG_CACHE) echo '<b>mkcol : cache cleared</b><br />';
                        $this->cached_props = array();
-if (DEBUG_CACHEPROP) _debug_array('cache prop set');
-                       $this->cached_propfind[$uri.'/'] = 200;
+if (DEBUG_CACHEPROP) _debug_array('mkcol : cache prop setted <br />');
+                       $this->delete_uri_in_cache($uri);
                        if (strlen($token))
                        {
                                $this->http_client->addHeader('If', 
'<'.$uri.'>'.' (<'.$token.'>)');
                        }
                        $ret = $this->http_client->MkCol( $uri );
+                       if ( $ret == 201 )
+                       {
+                               $this->cached_propfind[$uri.'/'] = 207;
+                       }
                        $this->http_client->removeHeader('If');
                        return $ret;
                }
@@ -782,12 +796,17 @@
                function proppatch($uri, $attributes,  $namespaces='', 
$token='',$is_dir = False)
                {
                        $uri = $this->encodeurl($uri);
-if (DEBUG_CACHE) echo '<b>cache cleared</b>';
+if (DEBUG_CACHE) echo '<b>proppatch: cache cleared</b><br />';
+                       $this->cached_props = array();
+                       if ( isset($this->cached_propfind[$uri.'/']) )
+                       {
+                               $is_dir = true;
+                       }
                        if (strlen($token))
                        {
+                               //XXX if $uri is without an ending / and is a 
directory ... what to do ???
                                $this->http_client->addHeader('If', 
'<'.$uri.'>'.' (<'.$token.'>)');
                        }
-                       $this->cached_props = array();
                        //Begin evil nastiness
                        $davxml = '<?xml version="1.0" encoding="utf-8" ?>
 <D:propertyupdate xmlns:D="DAV:"';
@@ -811,13 +830,13 @@
 </D:propertyupdate>';

                        if (DEBUG_DAV_XML) {
-                               echo 
'<b>send</b><pre>'.htmlentities($davxml).'</pre>';
+                               echo '<b>proppatch: 
send</b><pre>'.htmlentities($davxml).'</pre>';
                        }
                        $this->http_client->requestBody = $davxml;
                        //Ok if we know that this is a dir add a / if needed
                        if ( $is_dir && !ereg('#./$#',$uri) )
                        {
-                               if( $this->http_client->sendCommand( 'PROPPATCH 
'.$uri.'/'.' HTTP/1.1' ) )
+                               if( $this->http_client->sendCommand( 'PROPPATCH 
'.$uri.'/ HTTP/1.1' ) )
                                {
                                        $this->http_client->processReply();
                                }
@@ -832,7 +851,7 @@
                                        {
                                                //In fact the file is a 
directory !
                                                $this->http_client->requestBody 
= $davxml;
-                                               if ( 
$this->http_client->sendCommand( 'PROPPATCH '.$uri.SEP.' HTTP/1.1' ) )
+                                               if ( 
$this->http_client->sendCommand( 'PROPPATCH '.$uri.'/ HTTP/1.1' ) )
                                                {
                                                        
$this->http_client->processReply();
                                                }
@@ -840,7 +859,7 @@
                                }
                        }
                        if (DEBUG_DAV_XML) {
-                               echo 
'<b>Recieve</b><pre>'.htmlentities($this->http_client->getBody()).'</pre>';
+                               echo '<b>proppatch: 
Recieve</b><pre>'.htmlentities($this->http_client->getBody()).'</pre>';
                        }
                        $this->http_client->removeHeader('If');
                        return $this->http_client->reply;
@@ -1106,6 +1125,20 @@
                                $this->cached_propfind = array();
                        }
                }
-
+
+               /**
+               * @function delete_uri_in_cache
+               * @discusion Internal function for some cache deletion
+               */
+               function delete_uri_in_cache($uri)
+               {
+                       unset($this->cached_propfind[$uri]);
+                       unset($this->cached_propfind[$uri.'/']);
+                       unset($this->cached_propfind[$this->server.$uri]);
+                       unset($this->cached_propfind[$rhis->server.$uri.'/']);
+                       $suri = substr($uri,strlen($this->server));
+                       unset($this->cached_propfind[$suri]);
+                       unset($this->cached_propfind[$suri.'/']);
+               }
        }







reply via email to

[Prev in Thread] Current Thread [Next in Thread]