diff options
author | Mario <mario@mariovavti.com> | 2019-11-10 12:49:51 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2019-11-10 14:10:03 +0100 |
commit | 580c3f4ffe9608d2beb56d418c68b3b112420e76 (patch) | |
tree | 82335d01179ac361d3f547a4b8e8c598d302e9f3 /vendor/sabre/dav/lib/DAV/Locks/Backend/PDO.php | |
parent | d22766f458a8539a40a57f3946459a9be1f21cd6 (diff) | |
download | volse-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/PDO.php')
-rw-r--r-- | vendor/sabre/dav/lib/DAV/Locks/Backend/PDO.php | 80 |
1 files changed, 38 insertions, 42 deletions
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(); } - } |