aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/dav/lib/DAV/Locks/Backend
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2019-11-10 12:49:51 +0000
committerMario <mario@mariovavti.com>2019-11-10 14:10:03 +0100
commit580c3f4ffe9608d2beb56d418c68b3b112420e76 (patch)
tree82335d01179ac361d3f547a4b8e8c598d302e9f3 /vendor/sabre/dav/lib/DAV/Locks/Backend
parentd22766f458a8539a40a57f3946459a9be1f21cd6 (diff)
downloadvolse-hubzilla-580c3f4ffe9608d2beb56d418c68b3b112420e76.tar.gz
volse-hubzilla-580c3f4ffe9608d2beb56d418c68b3b112420e76.tar.bz2
volse-hubzilla-580c3f4ffe9608d2beb56d418c68b3b112420e76.zip
another bulk of composer updates
(cherry picked from commit 6685381fd8db507493c3d7c1793f8c05c681bbce)
Diffstat (limited to 'vendor/sabre/dav/lib/DAV/Locks/Backend')
-rw-r--r--vendor/sabre/dav/lib/DAV/Locks/Backend/AbstractBackend.php6
-rw-r--r--vendor/sabre/dav/lib/DAV/Locks/Backend/BackendInterface.php28
-rw-r--r--vendor/sabre/dav/lib/DAV/Locks/Backend/File.php87
-rw-r--r--vendor/sabre/dav/lib/DAV/Locks/Backend/PDO.php80
4 files changed, 102 insertions, 99 deletions
diff --git a/vendor/sabre/dav/lib/DAV/Locks/Backend/AbstractBackend.php b/vendor/sabre/dav/lib/DAV/Locks/Backend/AbstractBackend.php
index 044316cdb..a1bf48699 100644
--- a/vendor/sabre/dav/lib/DAV/Locks/Backend/AbstractBackend.php
+++ b/vendor/sabre/dav/lib/DAV/Locks/Backend/AbstractBackend.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\DAV\Locks\Backend;
/**
@@ -13,6 +15,6 @@ namespace Sabre\DAV\Locks\Backend;
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-abstract class AbstractBackend implements BackendInterface {
-
+abstract class AbstractBackend implements BackendInterface
+{
}
diff --git a/vendor/sabre/dav/lib/DAV/Locks/Backend/BackendInterface.php b/vendor/sabre/dav/lib/DAV/Locks/Backend/BackendInterface.php
index a2d2fe89c..9a6919f50 100644
--- a/vendor/sabre/dav/lib/DAV/Locks/Backend/BackendInterface.php
+++ b/vendor/sabre/dav/lib/DAV/Locks/Backend/BackendInterface.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\DAV\Locks\Backend;
use Sabre\DAV\Locks;
@@ -12,10 +14,10 @@ use Sabre\DAV\Locks;
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-interface BackendInterface {
-
+interface BackendInterface
+{
/**
- * Returns a list of Sabre\DAV\Locks\LockInfo objects
+ * 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.
@@ -24,27 +26,29 @@ interface BackendInterface {
* any locks in the subtree of the uri for locks.
*
* @param string $uri
- * @param bool $returnChildLocks
+ * @param bool $returnChildLocks
+ *
* @return array
*/
- function getLocks($uri, $returnChildLocks);
+ public function getLocks($uri, $returnChildLocks);
/**
- * Locks a uri
+ * Locks a uri.
*
- * @param string $uri
+ * @param string $uri
* @param Locks\LockInfo $lockInfo
+ *
* @return bool
*/
- function lock($uri, Locks\LockInfo $lockInfo);
+ public function lock($uri, Locks\LockInfo $lockInfo);
/**
- * Removes a lock from a uri
+ * Removes a lock from a uri.
*
- * @param string $uri
+ * @param string $uri
* @param Locks\LockInfo $lockInfo
+ *
* @return bool
*/
- function unlock($uri, Locks\LockInfo $lockInfo);
-
+ public function unlock($uri, Locks\LockInfo $lockInfo);
}
diff --git a/vendor/sabre/dav/lib/DAV/Locks/Backend/File.php b/vendor/sabre/dav/lib/DAV/Locks/Backend/File.php
index 849539bee..5957f35dd 100644
--- a/vendor/sabre/dav/lib/DAV/Locks/Backend/File.php
+++ b/vendor/sabre/dav/lib/DAV/Locks/Backend/File.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\DAV\Locks\Backend;
use Sabre\DAV\Locks\LockInfo;
@@ -17,28 +19,27 @@ use Sabre\DAV\Locks\LockInfo;
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-class File extends AbstractBackend {
-
+class File extends AbstractBackend
+{
/**
- * The storage file
+ * The storage file.
*
* @var string
*/
private $locksFile;
/**
- * Constructor
+ * Constructor.
*
* @param string $locksFile path to file
*/
- function __construct($locksFile) {
-
+ public function __construct($locksFile)
+ {
$this->locksFile = $locksFile;
-
}
/**
- * Returns a list of Sabre\DAV\Locks\LockInfo objects
+ * 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.
@@ -47,47 +48,47 @@ class File extends AbstractBackend {
* any locks in the subtree of the uri for locks.
*
* @param string $uri
- * @param bool $returnChildLocks
+ * @param bool $returnChildLocks
+ *
* @return array
*/
- function getLocks($uri, $returnChildLocks) {
-
+ public function getLocks($uri, $returnChildLocks)
+ {
$newLocks = [];
$locks = $this->getData();
foreach ($locks as $lock) {
-
if ($lock->uri === $uri ||
//deep locks on parents
- ($lock->depth != 0 && strpos($uri, $lock->uri . '/') === 0) ||
+ (0 != $lock->depth && 0 === strpos($uri, $lock->uri.'/')) ||
// locks on children
- ($returnChildLocks && (strpos($lock->uri, $uri . '/') === 0))) {
-
+ ($returnChildLocks && (0 === strpos($lock->uri, $uri.'/')))) {
$newLocks[] = $lock;
-
}
-
}
// Checking if we can remove any of these locks
foreach ($newLocks as $k => $lock) {
- if (time() > $lock->timeout + $lock->created) unset($newLocks[$k]);
+ if (time() > $lock->timeout + $lock->created) {
+ unset($newLocks[$k]);
+ }
}
- return $newLocks;
+ return $newLocks;
}
/**
- * Locks a uri
+ * Locks a uri.
*
- * @param string $uri
+ * @param string $uri
* @param LockInfo $lockInfo
+ *
* @return bool
*/
- function lock($uri, LockInfo $lockInfo) {
-
+ public function lock($uri, LockInfo $lockInfo)
+ {
// We're making the lock timeout 30 minutes
$lockInfo->timeout = 1800;
$lockInfo->created = time();
@@ -105,32 +106,31 @@ class File extends AbstractBackend {
}
$locks[] = $lockInfo;
$this->putData($locks);
- return true;
+ return true;
}
/**
- * Removes a lock from a uri
+ * Removes a lock from a uri.
*
- * @param string $uri
+ * @param string $uri
* @param LockInfo $lockInfo
+ *
* @return bool
*/
- function unlock($uri, LockInfo $lockInfo) {
-
+ public function unlock($uri, LockInfo $lockInfo)
+ {
$locks = $this->getData();
foreach ($locks as $k => $lock) {
-
if ($lock->token == $lockInfo->token) {
-
unset($locks[$k]);
$this->putData($locks);
- return true;
+ return true;
}
}
- return false;
+ return false;
}
/**
@@ -138,9 +138,11 @@ class File extends AbstractBackend {
*
* @return array
*/
- protected function getData() {
-
- if (!file_exists($this->locksFile)) return [];
+ protected function getData()
+ {
+ if (!file_exists($this->locksFile)) {
+ return [];
+ }
// opening up the file, and creating a shared lock
$handle = fopen($this->locksFile, 'r');
@@ -155,19 +157,20 @@ class File extends AbstractBackend {
// Unserializing and checking if the resource file contains data for this file
$data = unserialize($data);
- if (!$data) return [];
- return $data;
+ if (!$data) {
+ return [];
+ }
+ return $data;
}
/**
- * Saves the lockdata
+ * Saves the lockdata.
*
* @param array $newData
- * @return void
*/
- protected function putData(array $newData) {
-
+ protected function putData(array $newData)
+ {
// opening up the file, and creating an exclusive lock
$handle = fopen($this->locksFile, 'a+');
flock($handle, LOCK_EX);
@@ -179,7 +182,5 @@ class File extends AbstractBackend {
fwrite($handle, serialize($newData));
flock($handle, LOCK_UN);
fclose($handle);
-
}
-
}
diff --git a/vendor/sabre/dav/lib/DAV/Locks/Backend/PDO.php b/vendor/sabre/dav/lib/DAV/Locks/Backend/PDO.php
index 510f266f7..36a12d1ab 100644
--- a/vendor/sabre/dav/lib/DAV/Locks/Backend/PDO.php
+++ b/vendor/sabre/dav/lib/DAV/Locks/Backend/PDO.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\DAV\Locks\Backend;
use Sabre\DAV\Locks\LockInfo;
@@ -14,8 +16,8 @@ use Sabre\DAV\Locks\LockInfo;
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-class PDO extends AbstractBackend {
-
+class PDO extends AbstractBackend
+{
/**
* The PDO tablename this backend uses.
*
@@ -24,25 +26,24 @@ class PDO extends AbstractBackend {
public $tableName = 'locks';
/**
- * The PDO connection object
+ * The PDO connection object.
*
* @var pdo
*/
protected $pdo;
/**
- * Constructor
+ * Constructor.
*
* @param \PDO $pdo
*/
- function __construct(\PDO $pdo) {
-
+ public function __construct(\PDO $pdo)
+ {
$this->pdo = $pdo;
-
}
/**
- * Returns a list of Sabre\DAV\Locks\LockInfo objects
+ * 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.
@@ -51,16 +52,17 @@ class PDO extends AbstractBackend {
* any locks in the subtree of the uri for locks.
*
* @param string $uri
- * @param bool $returnChildLocks
+ * @param bool $returnChildLocks
+ *
* @return array
*/
- function getLocks($uri, $returnChildLocks) {
-
+ public function getLocks($uri, $returnChildLocks)
+ {
// NOTE: the following 10 lines or so could be easily replaced by
// pure sql. MySQL's non-standard string concatenation prevents us
// from doing this though.
- $query = 'SELECT owner, token, timeout, created, scope, depth, uri FROM ' . $this->tableName . ' WHERE (created > (? - timeout)) AND ((uri = ?)';
- $params = [time(),$uri];
+ $query = 'SELECT owner, token, timeout, created, scope, depth, uri FROM '.$this->tableName.' WHERE (created > (? - timeout)) AND ((uri = ?)';
+ $params = [time(), $uri];
// We need to check locks for every part in the uri.
$uriParts = explode('/', $uri);
@@ -71,20 +73,18 @@ class PDO extends AbstractBackend {
$currentPath = '';
foreach ($uriParts as $part) {
-
- if ($currentPath) $currentPath .= '/';
+ if ($currentPath) {
+ $currentPath .= '/';
+ }
$currentPath .= $part;
$query .= ' OR (depth!=0 AND uri = ?)';
$params[] = $currentPath;
-
}
if ($returnChildLocks) {
-
$query .= ' OR (uri LIKE ?)';
- $params[] = $uri . '/%';
-
+ $params[] = $uri.'/%';
}
$query .= ')';
@@ -94,7 +94,6 @@ class PDO extends AbstractBackend {
$lockList = [];
foreach ($result as $row) {
-
$lockInfo = new LockInfo();
$lockInfo->owner = $row['owner'];
$lockInfo->token = $row['token'];
@@ -104,22 +103,21 @@ class PDO extends AbstractBackend {
$lockInfo->depth = $row['depth'];
$lockInfo->uri = $row['uri'];
$lockList[] = $lockInfo;
-
}
return $lockList;
-
}
/**
- * Locks a uri
+ * Locks a uri.
*
- * @param string $uri
+ * @param string $uri
* @param LockInfo $lockInfo
+ *
* @return bool
*/
- function lock($uri, LockInfo $lockInfo) {
-
+ public function lock($uri, LockInfo $lockInfo)
+ {
// We're making the lock timeout 30 minutes
$lockInfo->timeout = 30 * 60;
$lockInfo->created = time();
@@ -128,11 +126,13 @@ class PDO extends AbstractBackend {
$locks = $this->getLocks($uri, false);
$exists = false;
foreach ($locks as $lock) {
- if ($lock->token == $lockInfo->token) $exists = true;
+ if ($lock->token == $lockInfo->token) {
+ $exists = true;
+ }
}
if ($exists) {
- $stmt = $this->pdo->prepare('UPDATE ' . $this->tableName . ' SET owner = ?, timeout = ?, scope = ?, depth = ?, uri = ?, created = ? WHERE token = ?');
+ $stmt = $this->pdo->prepare('UPDATE '.$this->tableName.' SET owner = ?, timeout = ?, scope = ?, depth = ?, uri = ?, created = ? WHERE token = ?');
$stmt->execute([
$lockInfo->owner,
$lockInfo->timeout,
@@ -140,10 +140,10 @@ class PDO extends AbstractBackend {
$lockInfo->depth,
$uri,
$lockInfo->created,
- $lockInfo->token
+ $lockInfo->token,
]);
} else {
- $stmt = $this->pdo->prepare('INSERT INTO ' . $this->tableName . ' (owner,timeout,scope,depth,uri,created,token) VALUES (?,?,?,?,?,?,?)');
+ $stmt = $this->pdo->prepare('INSERT INTO '.$this->tableName.' (owner,timeout,scope,depth,uri,created,token) VALUES (?,?,?,?,?,?,?)');
$stmt->execute([
$lockInfo->owner,
$lockInfo->timeout,
@@ -151,30 +151,26 @@ class PDO extends AbstractBackend {
$lockInfo->depth,
$uri,
$lockInfo->created,
- $lockInfo->token
+ $lockInfo->token,
]);
}
return true;
-
}
-
-
/**
- * Removes a lock from a uri
+ * Removes a lock from a uri.
*
- * @param string $uri
+ * @param string $uri
* @param LockInfo $lockInfo
+ *
* @return bool
*/
- function unlock($uri, LockInfo $lockInfo) {
-
- $stmt = $this->pdo->prepare('DELETE FROM ' . $this->tableName . ' WHERE uri = ? AND token = ?');
+ public function unlock($uri, LockInfo $lockInfo)
+ {
+ $stmt = $this->pdo->prepare('DELETE FROM '.$this->tableName.' WHERE uri = ? AND token = ?');
$stmt->execute([$uri, $lockInfo->token]);
- return $stmt->rowCount() === 1;
-
+ return 1 === $stmt->rowCount();
}
-
}