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/PropertyStorage/Backend | |
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/PropertyStorage/Backend')
-rw-r--r-- | vendor/sabre/dav/lib/DAV/PropertyStorage/Backend/BackendInterface.php | 27 | ||||
-rw-r--r-- | vendor/sabre/dav/lib/DAV/PropertyStorage/Backend/PDO.php | 100 |
2 files changed, 53 insertions, 74 deletions
diff --git a/vendor/sabre/dav/lib/DAV/PropertyStorage/Backend/BackendInterface.php b/vendor/sabre/dav/lib/DAV/PropertyStorage/Backend/BackendInterface.php index b15d7fef9..4bdc44775 100644 --- a/vendor/sabre/dav/lib/DAV/PropertyStorage/Backend/BackendInterface.php +++ b/vendor/sabre/dav/lib/DAV/PropertyStorage/Backend/BackendInterface.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\PropertyStorage\Backend; use Sabre\DAV\PropFind; @@ -15,8 +17,8 @@ use Sabre\DAV\PropPatch; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -interface BackendInterface { - +interface BackendInterface +{ /** * Fetches properties for a path. * @@ -30,14 +32,13 @@ interface BackendInterface { * However, you can also support the 'allprops' property here. In that * case, you should check for $propFind->isAllProps(). * - * @param string $path + * @param string $path * @param PropFind $propFind - * @return void */ - function propFind($path, PropFind $propFind); + public function propFind($path, PropFind $propFind); /** - * Updates properties for a path + * Updates properties for a path. * * This method received a PropPatch object, which contains all the * information about the update. @@ -45,11 +46,10 @@ interface BackendInterface { * Usually you would want to call 'handleRemaining' on this object, to get; * a list of all properties that need to be stored. * - * @param string $path + * @param string $path * @param PropPatch $propPatch - * @return void */ - function propPatch($path, PropPatch $propPatch); + public function propPatch($path, PropPatch $propPatch); /** * This method is called after a node is deleted. @@ -60,12 +60,11 @@ interface BackendInterface { * tree. * * @param string $path - * @return void */ - function delete($path); + public function delete($path); /** - * This method is called after a successful MOVE + * This method is called after a successful MOVE. * * This should be used to migrate all properties from one path to another. * Note that entire collections may be moved, so ensure that all properties @@ -73,8 +72,6 @@ interface BackendInterface { * * @param string $source * @param string $destination - * @return void */ - function move($source, $destination); - + public function move($source, $destination); } diff --git a/vendor/sabre/dav/lib/DAV/PropertyStorage/Backend/PDO.php b/vendor/sabre/dav/lib/DAV/PropertyStorage/Backend/PDO.php index 6f3f1feaf..e640f420e 100644 --- a/vendor/sabre/dav/lib/DAV/PropertyStorage/Backend/PDO.php +++ b/vendor/sabre/dav/lib/DAV/PropertyStorage/Backend/PDO.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAV\PropertyStorage\Backend; use Sabre\DAV\PropFind; @@ -18,8 +20,8 @@ use Sabre\DAV\Xml\Property\Complex; * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class PDO implements BackendInterface { - +class PDO implements BackendInterface +{ /** * Value is stored as string. */ @@ -36,28 +38,27 @@ class PDO implements BackendInterface { const VT_OBJECT = 3; /** - * PDO + * PDO. * * @var \PDO */ protected $pdo; /** - * PDO table name we'll be using + * PDO table name we'll be using. * * @var string */ public $tableName = 'propertystorage'; /** - * Creates the PDO property storage engine + * Creates the PDO property storage engine. * * @param \PDO $pdo */ - function __construct(\PDO $pdo) { - + public function __construct(\PDO $pdo) + { $this->pdo = $pdo; - } /** @@ -73,42 +74,40 @@ class PDO implements BackendInterface { * However, you can also support the 'allprops' property here. In that * case, you should check for $propFind->isAllProps(). * - * @param string $path + * @param string $path * @param PropFind $propFind - * @return void */ - function propFind($path, PropFind $propFind) { - - if (!$propFind->isAllProps() && count($propFind->get404Properties()) === 0) { + public function propFind($path, PropFind $propFind) + { + if (!$propFind->isAllProps() && 0 === count($propFind->get404Properties())) { return; } - $query = 'SELECT name, value, valuetype FROM ' . $this->tableName . ' WHERE path = ?'; + $query = 'SELECT name, value, valuetype FROM '.$this->tableName.' WHERE path = ?'; $stmt = $this->pdo->prepare($query); $stmt->execute([$path]); while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) { - if (gettype($row['value']) === 'resource') { + if ('resource' === gettype($row['value'])) { $row['value'] = stream_get_contents($row['value']); } switch ($row['valuetype']) { - case null : - case self::VT_STRING : + case null: + case self::VT_STRING: $propFind->set($row['name'], $row['value']); break; - case self::VT_XML : + case self::VT_XML: $propFind->set($row['name'], new Complex($row['value'])); break; - case self::VT_OBJECT : + case self::VT_OBJECT: $propFind->set($row['name'], unserialize($row['value'])); break; } } - } /** - * Updates properties for a path + * Updates properties for a path. * * This method received a PropPatch object, which contains all the * information about the update. @@ -116,38 +115,30 @@ class PDO implements BackendInterface { * Usually you would want to call 'handleRemaining' on this object, to get; * a list of all properties that need to be stored. * - * @param string $path + * @param string $path * @param PropPatch $propPatch - * @return void */ - function propPatch($path, PropPatch $propPatch) { - - $propPatch->handleRemaining(function($properties) use ($path) { - - - if ($this->pdo->getAttribute(\PDO::ATTR_DRIVER_NAME) === 'pgsql') { - + public function propPatch($path, PropPatch $propPatch) + { + $propPatch->handleRemaining(function ($properties) use ($path) { + if ('pgsql' === $this->pdo->getAttribute(\PDO::ATTR_DRIVER_NAME)) { $updateSql = <<<SQL INSERT INTO {$this->tableName} (path, name, valuetype, value) VALUES (:path, :name, :valuetype, :value) ON CONFLICT (path, name) DO UPDATE SET valuetype = :valuetype, value = :value SQL; - - } else { $updateSql = <<<SQL REPLACE INTO {$this->tableName} (path, name, valuetype, value) VALUES (:path, :name, :valuetype, :value) SQL; - } $updateStmt = $this->pdo->prepare($updateSql); - $deleteStmt = $this->pdo->prepare("DELETE FROM " . $this->tableName . " WHERE path = ? AND name = ?"); + $deleteStmt = $this->pdo->prepare('DELETE FROM '.$this->tableName.' WHERE path = ? AND name = ?'); foreach ($properties as $name => $value) { - if (!is_null($value)) { if (is_scalar($value)) { $valueType = self::VT_STRING; @@ -165,17 +156,13 @@ SQL; $updateStmt->bindParam('value', $value, \PDO::PARAM_LOB); $updateStmt->execute(); - } else { $deleteStmt->execute([$path, $name]); } - } return true; - }); - } /** @@ -187,26 +174,24 @@ SQL; * tree. * * @param string $path - * @return void */ - function delete($path) { - - $stmt = $this->pdo->prepare("DELETE FROM " . $this->tableName . " WHERE path = ? OR path LIKE ? ESCAPE '='"); + public function delete($path) + { + $stmt = $this->pdo->prepare('DELETE FROM '.$this->tableName." WHERE path = ? OR path LIKE ? ESCAPE '='"); $childPath = strtr( $path, [ '=' => '==', '%' => '=%', - '_' => '=_' + '_' => '=_', ] - ) . '/%'; + ).'/%'; $stmt->execute([$path, $childPath]); - } /** - * This method is called after a successful MOVE + * This method is called after a successful MOVE. * * This should be used to migrate all properties from one path to another. * Note that entire collections may be moved, so ensure that all properties @@ -214,33 +199,30 @@ SQL; * * @param string $source * @param string $destination - * @return void */ - function move($source, $destination) { - + public function move($source, $destination) + { // I don't know a way to write this all in a single sql query that's // also compatible across db engines, so we're letting PHP do all the // updates. Much slower, but it should still be pretty fast in most // cases. - $select = $this->pdo->prepare('SELECT id, path FROM ' . $this->tableName . ' WHERE path = ? OR path LIKE ?'); - $select->execute([$source, $source . '/%']); + $select = $this->pdo->prepare('SELECT id, path FROM '.$this->tableName.' WHERE path = ? OR path LIKE ?'); + $select->execute([$source, $source.'/%']); - $update = $this->pdo->prepare('UPDATE ' . $this->tableName . ' SET path = ? WHERE id = ?'); + $update = $this->pdo->prepare('UPDATE '.$this->tableName.' SET path = ? WHERE id = ?'); while ($row = $select->fetch(\PDO::FETCH_ASSOC)) { - // Sanity check. SQL may select too many records, such as records // with different cases. - if ($row['path'] !== $source && strpos($row['path'], $source . '/') !== 0) continue; + if ($row['path'] !== $source && 0 !== strpos($row['path'], $source.'/')) { + continue; + } $trailingPart = substr($row['path'], strlen($source) + 1); $newPath = $destination; if ($trailingPart) { - $newPath .= '/' . $trailingPart; + $newPath .= '/'.$trailingPart; } $update->execute([$newPath, $row['id']]); - } - } - } |