[Pkg-owncloud-commits] [php-sabredav] 04/64: Deleted long-deprecated classes.

David Prévot taffit at moszumanska.debian.org
Thu Dec 11 15:13:21 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to tag 2.2.0alpha1
in repository php-sabredav.

commit 38aedf60e6afef3d20c01a21310a59b1b214bfdf
Author: Evert Pot <me at evertpot.com>
Date:   Thu Oct 23 22:52:06 2014 -0400

    Deleted long-deprecated classes.
---
 ChangeLog.md                                |   7 +
 lib/CalDAV/CalendarRootNode.php             |  16 ---
 lib/CalDAV/UserCalendars.php                |  19 ---
 lib/DAV/Exception/FileNotFound.php          |  19 ---
 lib/DAV/Locks/Backend/FS.php                | 194 ----------------------------
 lib/DAV/PartialUpdate/IFile.php             |  39 ------
 lib/DAV/Property/Href.php                   |   3 +-
 lib/DAV/Property/HrefList.php               |   3 +-
 lib/DAV/TemporaryFileFilterPlugin.php       |   6 +-
 lib/DAV/URLUtil.php                         |  22 ----
 lib/DAVACL/Principal.php                    |   5 +-
 lib/DAVACL/Property/Principal.php           |   4 +-
 tests/Sabre/DAV/Locks/Backend/FSTest.php    |  35 -----
 tests/Sabre/DAV/PartialUpdate/FileMock.php  |  54 +++++++-
 tests/Sabre/DAV/TemporaryFileFilterTest.php |   2 +-
 15 files changed, 68 insertions(+), 360 deletions(-)

diff --git a/ChangeLog.md b/ChangeLog.md
index d1c4d3b..05b6931 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -7,6 +7,13 @@ ChangeLog
 * Removed: all `$tableName` arguments from every PDO backend. This was already
   deprecated, but has now been fully removed. All of these have been replaced
   with public properties.
+* Deleted several classes that were already deprecated much earlier:
+  * `Sabre\CalDAV\CalendarRootNode`
+  * `Sabre\CalDAV\UserCalendars`
+  * `Sabre\DAV\Exception\FileNotFound`
+  * `Sabre\DAV\Locks\Backend\FS`
+  * `Sabre\DAV\PartialUpdate\IFile`
+  * `Sabre\DAV\URLUtil`
 
 2.1.0-alpha2 (2014-10-23)
 -------------------------
diff --git a/lib/CalDAV/CalendarRootNode.php b/lib/CalDAV/CalendarRootNode.php
deleted file mode 100644
index 7d4f9db..0000000
--- a/lib/CalDAV/CalendarRootNode.php
+++ /dev/null
@@ -1,16 +0,0 @@
-<?php
-
-namespace Sabre\CalDAV;
-
-/**
- * Deprecated! This class has been renamed to CalendarRoot.
- *
- * This stub class will be removed in a future version of sabredav!
- *
- * @deprecated
- * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/).
- * @author Evert Pot (http://evertpot.com/)
- * @license http://sabre.io/license/ Modified BSD License
- */
-class CalendarRootNode extends CalendarRoot {
-}
diff --git a/lib/CalDAV/UserCalendars.php b/lib/CalDAV/UserCalendars.php
deleted file mode 100644
index d6a5e72..0000000
--- a/lib/CalDAV/UserCalendars.php
+++ /dev/null
@@ -1,19 +0,0 @@
-<?php
-
-namespace Sabre\CalDAV;
-
-/**
- * This class is deprecated!
- *
- * It has been renamed to Sabre\CalDAV\CalendarHome.
- *
- * This stub class will be removed in a future version of sabredav.
- *
- * @deprecated
- * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/).
- * @author Evert Pot (http://evertpot.com/)
- * @license http://sabre.io/license/ Modified BSD License
- */
-class UserCalendars extends CalendarHome {
-
-}
diff --git a/lib/DAV/Exception/FileNotFound.php b/lib/DAV/Exception/FileNotFound.php
deleted file mode 100644
index aa4844c..0000000
--- a/lib/DAV/Exception/FileNotFound.php
+++ /dev/null
@@ -1,19 +0,0 @@
-<?php
-
-namespace Sabre\DAV\Exception;
-
-/**
- * FileNotFound
- *
- * Deprecated: Warning, this class is deprecated and will be removed in a
- * future version of SabreDAV. Please use Sabre\DAV\Exception\NotFound instead.
- *
- * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/).
- * @author Evert Pot (http://evertpot.com/)
- * @deprecated Use Sabre\DAV\Exception\NotFound instead
- * @license http://sabre.io/license/ Modified BSD License
- */
-class FileNotFound extends NotFound {
-
-}
-
diff --git a/lib/DAV/Locks/Backend/FS.php b/lib/DAV/Locks/Backend/FS.php
deleted file mode 100644
index 512f2ca..0000000
--- a/lib/DAV/Locks/Backend/FS.php
+++ /dev/null
@@ -1,194 +0,0 @@
-<?php
-
-namespace Sabre\DAV\Locks\Backend;
-
-use Sabre\DAV\Locks\LockInfo;
-
-/**
- * This Lock Backend stores all its data in the filesystem in separate file per
- * node.
- *
- * This Lock Manager is now deprecated. It has a bug that allows parent
- * collections to be deletes when children deeper in the tree are locked.
- *
- * This also means that using this backend means you will not pass the Neon
- * Litmus test.
- *
- * You are recommended to use either the PDO or the File backend instead.
- *
- * @deprecated
- * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/).
- * @author Evert Pot (http://evertpot.com/)
- * @license http://sabre.io/license/ Modified BSD License
- */
-class FS extends AbstractBackend {
-
-    /**
-     * The default data directory
-     *
-     * @var string
-     */
-    private $dataDir;
-
-    function __construct($dataDir) {
-
-        $this->dataDir = $dataDir;
-
-    }
-
-    protected function getFileNameForUri($uri) {
-
-        return $this->dataDir . '/sabredav_' . md5($uri) . '.locks';
-
-    }
-
-
-    /**
-     * Returns a list of Sabre\DAV\Locks\LockInfo objects
-     *
-     * This method should return all the locks for a particular uri, including
-     * locks that might be set on a parent uri.
-     *
-     * If returnChildLocks is set to true, this method should also look for
-     * any locks in the subtree of the uri for locks.
-     *
-     * @param string $uri
-     * @param bool $returnChildLocks
-     * @return array
-     */
-    function getLocks($uri, $returnChildLocks) {
-
-        $lockList = [];
-        $currentPath = '';
-
-        foreach(explode('/',$uri) as $uriPart) {
-
-            // weird algorithm that can probably be improved, but we're traversing the path top down
-            if ($currentPath) $currentPath.='/';
-            $currentPath.=$uriPart;
-
-            $uriLocks = $this->getData($currentPath);
-
-            foreach($uriLocks as $uriLock) {
-
-                // Unless we're on the leaf of the uri-tree we should ignore locks with depth 0
-                if($uri==$currentPath || $uriLock->depth!=0) {
-                    $uriLock->uri = $currentPath;
-                    $lockList[] = $uriLock;
-                }
-
-            }
-
-        }
-
-        // Checking if we can remove any of these locks
-        foreach($lockList as $k=>$lock) {
-            if (time() > $lock->timeout + $lock->created) unset($lockList[$k]);
-        }
-        return $lockList;
-
-    }
-
-    /**
-     * Locks a uri
-     *
-     * @param string $uri
-     * @param LockInfo $lockInfo
-     * @return bool
-     */
-    function lock($uri, LockInfo $lockInfo) {
-
-        // We're making the lock timeout 30 minutes
-        $lockInfo->timeout = 1800;
-        $lockInfo->created = time();
-
-        $locks = $this->getLocks($uri,false);
-        foreach($locks as $k=>$lock) {
-            if ($lock->token == $lockInfo->token) unset($locks[$k]);
-        }
-        $locks[] = $lockInfo;
-        $this->putData($uri,$locks);
-        return true;
-
-    }
-
-    /**
-     * Removes a lock from a uri
-     *
-     * @param string $uri
-     * @param LockInfo $lockInfo
-     * @return bool
-     */
-    function unlock($uri, LockInfo $lockInfo) {
-
-        $locks = $this->getLocks($uri,false);
-        foreach($locks as $k=>$lock) {
-
-            if ($lock->token == $lockInfo->token) {
-
-                unset($locks[$k]);
-                $this->putData($uri,$locks);
-                return true;
-
-            }
-        }
-        return false;
-
-    }
-
-    /**
-     * Returns the stored data for a uri
-     *
-     * @param string $uri
-     * @return array
-     */
-    protected function getData($uri) {
-
-        $path = $this->getFilenameForUri($uri);
-        if (!file_exists($path)) return [];
-
-        // opening up the file, and creating a shared lock
-        $handle = fopen($path,'r');
-        flock($handle,LOCK_SH);
-        $data = '';
-
-        // Reading data until the eof
-        while(!feof($handle)) {
-            $data.=fread($handle,8192);
-        }
-
-        // We're all good
-        flock($handle,LOCK_UN);
-        fclose($handle);
-
-        // Unserializing and checking if the resource file contains data for this file
-        $data = unserialize($data);
-        if (!$data) return [];
-        return $data;
-
-    }
-
-    /**
-     * Updates the lock information
-     *
-     * @param string $uri
-     * @param array $newData
-     * @return void
-     */
-    protected function putData($uri,array $newData) {
-
-        $path = $this->getFileNameForUri($uri);
-
-        // opening up the file, and creating a shared lock
-        $handle = fopen($path,'a+');
-        flock($handle,LOCK_EX);
-        ftruncate($handle,0);
-        rewind($handle);
-
-        fwrite($handle,serialize($newData));
-        flock($handle,LOCK_UN);
-        fclose($handle);
-
-    }
-
-}
diff --git a/lib/DAV/PartialUpdate/IFile.php b/lib/DAV/PartialUpdate/IFile.php
deleted file mode 100644
index 9cfb473..0000000
--- a/lib/DAV/PartialUpdate/IFile.php
+++ /dev/null
@@ -1,39 +0,0 @@
-<?php
-
-namespace Sabre\DAV\PartialUpdate;
-
-use Sabre\DAV;
-
-/**
- * This interface is deprecated. Use IPatchSupport instead.
- *
- * @copyright Copyright (C) 2007-2014 fruux GmbH (https://fruux.com/).
- * @author Jean-Tiare LE BIGOT (http://www.jtlebi.fr/)
- * @license http://sabre.io/license/ Modified BSD License
- * @deprecated
- */
-interface IFile extends DAV\IFile {
-
-    /**
-     * Updates the data at a given offset
-     *
-     * The data argument is a readable stream resource.
-     * The offset argument is an integer describing the offset. Contrary to
-     * what's sent in the request, the offset here is a 0-based index.
-     *
-     * After a successful put operation, you may choose to return an ETag. The
-     * etag must always be surrounded by double-quotes. These quotes must
-     * appear in the actual string you're returning.
-     *
-     * Clients may use the ETag from a PUT request to later on make sure that
-     * when they update the file, the contents haven't changed in the mean
-     * time.
-     *
-     * @param resource $data
-     * @param integer $offset
-     * @return string|null
-     */
-    function putRange($data, $offset);
-
-}
-
diff --git a/lib/DAV/Property/Href.php b/lib/DAV/Property/Href.php
index 042ccec..b1b4c48 100644
--- a/lib/DAV/Property/Href.php
+++ b/lib/DAV/Property/Href.php
@@ -3,6 +3,7 @@
 namespace Sabre\DAV\Property;
 
 use Sabre\DAV;
+use Sabre\HTTP\URLUtil;
 
 /**
  * Href property
@@ -69,7 +70,7 @@ class Href extends DAV\Property implements IHref {
         $elem = $dom->ownerDocument->createElement($prefix . ':href');
 
         if ($this->autoPrefix) {
-            $value = $server->getBaseUri() . DAV\URLUtil::encodePath($this->href);
+            $value = $server->getBaseUri() . URLUtil::encodePath($this->href);
         } else {
             $value = $this->href;
         }
diff --git a/lib/DAV/Property/HrefList.php b/lib/DAV/Property/HrefList.php
index 6b87019..a35d292 100644
--- a/lib/DAV/Property/HrefList.php
+++ b/lib/DAV/Property/HrefList.php
@@ -3,6 +3,7 @@
 namespace Sabre\DAV\Property;
 
 use Sabre\DAV;
+use Sabre\HTTP\URLUtil;
 
 /**
  * HrefList property
@@ -70,7 +71,7 @@ class HrefList extends DAV\Property {
 
             $elem = $dom->ownerDocument->createElement($prefix . ':href');
             if ($this->autoPrefix) {
-                $value = $server->getBaseUri() . DAV\URLUtil::encodePath($href);
+                $value = $server->getBaseUri() . URLUtil::encodePath($href);
             } else {
                 $value = $href;
             }
diff --git a/lib/DAV/TemporaryFileFilterPlugin.php b/lib/DAV/TemporaryFileFilterPlugin.php
index e5a4716..1af54d9 100644
--- a/lib/DAV/TemporaryFileFilterPlugin.php
+++ b/lib/DAV/TemporaryFileFilterPlugin.php
@@ -2,9 +2,9 @@
 
 namespace Sabre\DAV;
 
-use
-    Sabre\HTTP\RequestInterface,
-    Sabre\HTTP\ResponseInterface;
+use Sabre\HTTP\RequestInterface;
+use Sabre\HTTP\ResponseInterface;
+use Sabre\HTTP\URLUtil;
 
 /**
  * Temporary File Filter Plugin
diff --git a/lib/DAV/URLUtil.php b/lib/DAV/URLUtil.php
deleted file mode 100644
index 6c00b5e..0000000
--- a/lib/DAV/URLUtil.php
+++ /dev/null
@@ -1,22 +0,0 @@
-<?php
-
-namespace Sabre\DAV;
-
-use Sabre\HTTP;
-
-/**
- * URLUtil
- *
- * This file moved to the HTTP package and is now deprecated. Use
- * Sabre\HTTP\URLUtil instead.
- *
- * This file will be removed in a future version.
- *
- * @copyright Copyright (C) 2007-2014 fruux GmbH. All rights reserved.
- * @author Evert Pot (http://evertpot.com/)
- * @deprecated Use Sabre\HTTP\URLUtil instead!
- * @license http://sabre.io/license/ Modified BSD License
- */
-class URLUtil extends HTTP\URLUtil {
-
-}
diff --git a/lib/DAVACL/Principal.php b/lib/DAVACL/Principal.php
index 05854fe..eaeb874 100644
--- a/lib/DAVACL/Principal.php
+++ b/lib/DAVACL/Principal.php
@@ -2,9 +2,8 @@
 
 namespace Sabre\DAVACL;
 
-use
-    Sabre\DAV,
-    Sabre\HTTP\URLUtil;
+use Sabre\DAV;
+use Sabre\HTTP\URLUtil;
 
 /**
  * Principal class
diff --git a/lib/DAVACL/Property/Principal.php b/lib/DAVACL/Property/Principal.php
index bca11ac..ad81eac 100644
--- a/lib/DAVACL/Property/Principal.php
+++ b/lib/DAVACL/Property/Principal.php
@@ -1,7 +1,9 @@
 <?php
 
 namespace Sabre\DAVACL\Property;
+
 use Sabre\DAV;
+use Sabre\HTTP\URLUtil;
 
 /**
  * Principal property
@@ -120,7 +122,7 @@ class Principal extends DAV\Property implements DAV\Property\IHref {
                 break;
             case self::HREF :
                 $href = $node->ownerDocument->createElement($prefix . ':href');
-                $href->nodeValue = $server->getBaseUri() . DAV\URLUtil::encodePath($this->href);
+                $href->nodeValue = $server->getBaseUri() . URLUtil::encodePath($this->href);
                 $node->appendChild($href);
                 break;
 
diff --git a/tests/Sabre/DAV/Locks/Backend/FSTest.php b/tests/Sabre/DAV/Locks/Backend/FSTest.php
deleted file mode 100644
index a670c08..0000000
--- a/tests/Sabre/DAV/Locks/Backend/FSTest.php
+++ /dev/null
@@ -1,35 +0,0 @@
-<?php
-
-namespace Sabre\DAV\Locks\Backend;
-
-require_once 'Sabre/TestUtil.php';
-
-class FSTest extends AbstractTest {
-
-    function getBackend() {
-
-        \Sabre\TestUtil::clearTempDir();
-        mkdir(SABRE_TEMPDIR . '/locks');
-        $backend = new FS(SABRE_TEMPDIR . '/locks/');
-        return $backend;
-
-    }
-
-    function tearDown() {
-
-        \Sabre\TestUtil::clearTempDir();
-
-    }
-
-    function testGetLocksChildren() {
-
-        // We're skipping this test. This doesn't work, and it will
-        // never. The class is deprecated anyway.
-        //
-        // We need to assert something though, so phpunit won't fail in strict
-        // mode.
-        $this->assertTrue(true);
-
-    }
-
-}
diff --git a/tests/Sabre/DAV/PartialUpdate/FileMock.php b/tests/Sabre/DAV/PartialUpdate/FileMock.php
index e8cdc16..d6cc406 100644
--- a/tests/Sabre/DAV/PartialUpdate/FileMock.php
+++ b/tests/Sabre/DAV/PartialUpdate/FileMock.php
@@ -3,7 +3,7 @@
 namespace Sabre\DAV\PartialUpdate;
 use Sabre\DAV;
 
-class FileMock implements IFile {
+class FileMock implements IPatchSupport {
 
     protected $data = '';
 
@@ -16,14 +16,56 @@ class FileMock implements IFile {
 
     }
 
-    function putRange($str,$start) {
-
-        if (is_resource($str)) {
-            $str = stream_get_contents($str);
+    /**
+     * Updates the file based on a range specification.
+     *
+     * The first argument is the data, which is either a readable stream
+     * resource or a string.
+     *
+     * The second argument is the type of update we're doing.
+     * This is either:
+     * * 1. append
+     * * 2. update based on a start byte
+     * * 3. update based on an end byte
+     *;
+     * The third argument is the start or end byte.
+     *
+     * After a successful put operation, you may choose to return an ETag. The
+     * etag must always be surrounded by double-quotes. These quotes must
+     * appear in the actual string you're returning.
+     *
+     * Clients may use the ETag from a PUT request to later on make sure that
+     * when they update the file, the contents haven't changed in the mean
+     * time.
+     *
+     * @param resource|string $data
+     * @param int $rangeType
+     * @param int $offset
+     * @return string|null
+     */
+    function patch($data, $rangeType, $offset = null) {
+
+        if (is_resource($data)) {
+            $data = stream_get_contents($data);
         }
-        $this->data = substr($this->data, 0, $start) . $str . substr($this->data, $start + strlen($str));
 
+        switch($rangeType) {
+
+            case 1 :
+                $this->data.=$data;
+                break;
+            case 3 :
+                // Turn the offset into an offset-offset.
+                $offset = strlen($this->data) - $offset;
+                // No break is intentional
+            case 2 :
+                $this->data =
+                    substr($this->data, 0, $offset) .
+                    $data .
+                    substr($this->data, $offset + strlen($data));
+                break;
 
+        }
 
     }
 
diff --git a/tests/Sabre/DAV/TemporaryFileFilterTest.php b/tests/Sabre/DAV/TemporaryFileFilterTest.php
index 40d915a..29300d7 100644
--- a/tests/Sabre/DAV/TemporaryFileFilterTest.php
+++ b/tests/Sabre/DAV/TemporaryFileFilterTest.php
@@ -132,7 +132,7 @@ class TemporaryFileFilterTest extends AbstractServer {
     function testLockNonExistant() {
 
         mkdir(SABRE_TEMPDIR . '/locksdir');
-        $locksBackend = new Locks\Backend\FS(SABRE_TEMPDIR . '/locksdir');
+        $locksBackend = new Locks\Backend\File(SABRE_TEMPDIR . '/locks');
         $locksPlugin = new Locks\Plugin($locksBackend);
         $this->server->addPlugin($locksPlugin);
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/php-sabredav.git



More information about the Pkg-owncloud-commits mailing list