From 0b02a6d123b2014705998c94ddf3d460948d3eac Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 10 May 2016 17:26:44 -0700 Subject: initial sabre upgrade (needs lots of work - to wit: authentication, redo the browser interface, and rework event export/import) --- vendor/sabre/dav/bin/build.php | 60 +++- vendor/sabre/dav/bin/migrateto17.php | 54 ++-- vendor/sabre/dav/bin/migrateto20.php | 453 +++++++++++++++++++++++++++++++ vendor/sabre/dav/bin/migrateto21.php | 180 ++++++++++++ vendor/sabre/dav/bin/migrateto30.php | 171 ++++++++++++ vendor/sabre/dav/bin/naturalselection | 140 ++++++++++ vendor/sabre/dav/bin/naturalselection.py | 140 ---------- vendor/sabre/dav/bin/sabredav.php | 10 +- 8 files changed, 1026 insertions(+), 182 deletions(-) mode change 100644 => 100755 vendor/sabre/dav/bin/build.php create mode 100755 vendor/sabre/dav/bin/migrateto20.php create mode 100755 vendor/sabre/dav/bin/migrateto21.php create mode 100755 vendor/sabre/dav/bin/migrateto30.php create mode 100755 vendor/sabre/dav/bin/naturalselection delete mode 100755 vendor/sabre/dav/bin/naturalselection.py (limited to 'vendor/sabre/dav/bin') diff --git a/vendor/sabre/dav/bin/build.php b/vendor/sabre/dav/bin/build.php old mode 100644 new mode 100755 index 11cca1e61..82b1e7530 --- a/vendor/sabre/dav/bin/build.php +++ b/vendor/sabre/dav/bin/build.php @@ -1,3 +1,4 @@ +#!/usr/bin/env php [], - 'test' => [ + 'test' => [ 'composerupdate', ], - 'init' => [], + 'init' => [], 'composerupdate' => [], ]; @@ -35,9 +36,9 @@ if (!isset($tasks[$currentTask])) { $newTaskList = []; $oldTaskList = [$currentTask => true]; -while(count($oldTaskList)>0) { +while (count($oldTaskList) > 0) { - foreach($oldTaskList as $task=>$foo) { + foreach ($oldTaskList as $task => $foo) { if (!isset($tasks[$task])) { echo "Dependency not found: " . $task, "\n"; @@ -46,7 +47,7 @@ while(count($oldTaskList)>0) { $dependencies = $tasks[$task]; $fullFilled = true; - foreach($dependencies as $dependency) { + foreach ($dependencies as $dependency) { if (isset($newTaskList[$dependency])) { // Already in the fulfilled task list. continue; @@ -65,7 +66,7 @@ while(count($oldTaskList)>0) { } -foreach(array_keys($newTaskList) as $task) { +foreach (array_keys($newTaskList) as $task) { echo "task: " . $task, "\n"; call_user_func($task); @@ -100,7 +101,7 @@ function composerupdate() { global $baseDir; echo " Updating composer packages to latest version\n\n"; - system('cd ' . $baseDir . '; composer update --dev'); + system('cd ' . $baseDir . '; composer update'); } function test() { @@ -120,12 +121,51 @@ function test() { function buildzip() { global $baseDir, $version; - echo " Asking composer to download sabre/dav $version\n\n"; - system("composer create-project --no-dev sabre/dav build/SabreDAV $version", $code); - if ($code!==0) { + echo " Generating composer.json\n"; + + $input = json_decode(file_get_contents(__DIR__ . '/../composer.json'), true); + $newComposer = [ + "require" => $input['require'], + "config" => [ + "bin-dir" => "./bin", + ], + "prefer-stable" => true, + "minimum-stability" => "alpha", + ]; + unset( + $newComposer['require']['sabre/vobject'], + $newComposer['require']['sabre/http'], + $newComposer['require']['sabre/uri'], + $newComposer['require']['sabre/event'] + ); + $newComposer['require']['sabre/dav'] = $version; + mkdir('build/SabreDAV'); + file_put_contents('build/SabreDAV/composer.json', json_encode($newComposer, JSON_PRETTY_PRINT)); + + echo " Downloading dependencies\n"; + system("cd build/SabreDAV; composer install -n", $code); + if ($code !== 0) { echo "Composer reported error code $code\n"; die(1); } + + echo " Removing pointless files\n"; + unlink('build/SabreDAV/composer.json'); + unlink('build/SabreDAV/composer.lock'); + + echo " Moving important files to the root of the project\n"; + + $fileNames = [ + 'CHANGELOG.md', + 'LICENSE', + 'README.md', + 'examples', + ]; + foreach ($fileNames as $fileName) { + echo " $fileName\n"; + rename('build/SabreDAV/vendor/sabre/dav/' . $fileName, 'build/SabreDAV/' . $fileName); + } + // echo "\n"; diff --git a/vendor/sabre/dav/bin/migrateto17.php b/vendor/sabre/dav/bin/migrateto17.php index 66a9ee564..a1173c584 100755 --- a/vendor/sabre/dav/bin/migrateto17.php +++ b/vendor/sabre/dav/bin/migrateto17.php @@ -3,7 +3,7 @@ echo "SabreDAV migrate script for version 1.7\n"; -if ($argc<2) { +if ($argc < 2) { echo <<getAttribute(PDO::ATTR_DRIVER_NAME)) { + switch ($pdo->getAttribute(PDO::ATTR_DRIVER_NAME)) { case 'mysql' : @@ -150,7 +150,7 @@ $stmt = $pdo->prepare('UPDATE calendarobjects SET etag = ?, size = ?, componentt echo "Total records found: " . $result->rowCount() . "\n"; $done = 0; $total = $result->rowCount(); -while($row = $result->fetch()) { +while ($row = $result->fetch()) { try { $newData = getDenormalizedData($row['calendardata']); @@ -161,14 +161,14 @@ while($row = $result->fetch()) { echo "This record is ignored, you should inspect it to see if there's anything wrong.\n===\n"; continue; } - $stmt->execute(array( + $stmt->execute([ $newData['etag'], $newData['size'], $newData['componentType'], $newData['firstOccurence'], $newData['lastOccurence'], $row['id'], - )); + ]); $done++; if ($done % 500 === 0) { @@ -188,7 +188,7 @@ if (array_key_exists('transparent', $row)) { echo "Adding the 'transparent' field to the calendars table\n"; - switch($pdo->getAttribute(PDO::ATTR_DRIVER_NAME)) { + switch ($pdo->getAttribute(PDO::ATTR_DRIVER_NAME)) { case 'mysql' : $pdo->exec("ALTER TABLE calendars ADD transparent TINYINT(1) NOT NULL DEFAULT '0'"); @@ -229,8 +229,8 @@ function getDenormalizedData($calendarData) { $component = null; $firstOccurence = null; $lastOccurence = null; - foreach($vObject->getComponents() as $component) { - if ($component->name!=='VTIMEZONE') { + foreach ($vObject->getComponents() as $component) { + if ($component->name !== 'VTIMEZONE') { $componentType = $component->name; break; } @@ -256,13 +256,13 @@ function getDenormalizedData($calendarData) { $lastOccurence = $firstOccurence; } } else { - $it = new \Sabre\VObject\RecurrenceIterator($vObject, (string)$component->UID); + $it = new \Sabre\VObject\Recur\EventIterator($vObject, (string)$component->UID); $maxDate = new DateTime(\Sabre\CalDAV\Backend\PDO::MAX_DATE); if ($it->isInfinite()) { $lastOccurence = $maxDate->getTimeStamp(); } else { $end = $it->getDtEnd(); - while($it->valid() && $end < $maxDate) { + while ($it->valid() && $end < $maxDate) { $end = $it->getDtEnd(); $it->next(); @@ -273,12 +273,12 @@ function getDenormalizedData($calendarData) { } } - return array( - 'etag' => md5($calendarData), - 'size' => strlen($calendarData), - 'componentType' => $componentType, + return [ + 'etag' => md5($calendarData), + 'size' => strlen($calendarData), + 'componentType' => $componentType, 'firstOccurence' => $firstOccurence, 'lastOccurence' => $lastOccurence, - ); + ]; } diff --git a/vendor/sabre/dav/bin/migrateto20.php b/vendor/sabre/dav/bin/migrateto20.php new file mode 100755 index 000000000..77236804f --- /dev/null +++ b/vendor/sabre/dav/bin/migrateto20.php @@ -0,0 +1,453 @@ +#!/usr/bin/env php +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); +$pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); + +$driver = $pdo->getAttribute(PDO::ATTR_DRIVER_NAME); + +switch ($driver) { + + case 'mysql' : + echo "Detected MySQL.\n"; + break; + case 'sqlite' : + echo "Detected SQLite.\n"; + break; + default : + echo "Error: unsupported driver: " . $driver . "\n"; + die(-1); +} + +foreach (['calendar', 'addressbook'] as $itemType) { + + $tableName = $itemType . 's'; + $tableNameOld = $tableName . '_old'; + $changesTable = $itemType . 'changes'; + + echo "Upgrading '$tableName'\n"; + + // The only cross-db way to do this, is to just fetch a single record. + $row = $pdo->query("SELECT * FROM $tableName LIMIT 1")->fetch(); + + if (!$row) { + + echo "No records were found in the '$tableName' table.\n"; + echo "\n"; + echo "We're going to rename the old table to $tableNameOld (just in case).\n"; + echo "and re-create the new table.\n"; + + switch ($driver) { + + case 'mysql' : + $pdo->exec("RENAME TABLE $tableName TO $tableNameOld"); + switch ($itemType) { + case 'calendar' : + $pdo->exec(" + CREATE TABLE calendars ( + id INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, + principaluri VARCHAR(100), + displayname VARCHAR(100), + uri VARCHAR(200), + synctoken INT(11) UNSIGNED NOT NULL DEFAULT '1', + description TEXT, + calendarorder INT(11) UNSIGNED NOT NULL DEFAULT '0', + calendarcolor VARCHAR(10), + timezone TEXT, + components VARCHAR(20), + transparent TINYINT(1) NOT NULL DEFAULT '0', + UNIQUE(principaluri, uri) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + "); + break; + case 'addressbook' : + $pdo->exec(" + CREATE TABLE addressbooks ( + id INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, + principaluri VARCHAR(255), + displayname VARCHAR(255), + uri VARCHAR(200), + description TEXT, + synctoken INT(11) UNSIGNED NOT NULL DEFAULT '1', + UNIQUE(principaluri, uri) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + "); + break; + } + break; + + case 'sqlite' : + + $pdo->exec("ALTER TABLE $tableName RENAME TO $tableNameOld"); + + switch ($itemType) { + case 'calendar' : + $pdo->exec(" + CREATE TABLE calendars ( + id integer primary key asc, + principaluri text, + displayname text, + uri text, + synctoken integer, + description text, + calendarorder integer, + calendarcolor text, + timezone text, + components text, + transparent bool + ); + "); + break; + case 'addressbook' : + $pdo->exec(" + CREATE TABLE addressbooks ( + id integer primary key asc, + principaluri text, + displayname text, + uri text, + description text, + synctoken integer + ); + "); + + break; + } + break; + + } + echo "Creation of 2.0 $tableName table is complete\n"; + + } else { + + // Checking if there's a synctoken field already. + if (array_key_exists('synctoken', $row)) { + echo "The 'synctoken' field already exists in the $tableName table.\n"; + echo "It's likely you already upgraded, so we're simply leaving\n"; + echo "the $tableName table alone\n"; + } else { + + echo "1.8 table schema detected\n"; + switch ($driver) { + + case 'mysql' : + $pdo->exec("ALTER TABLE $tableName ADD synctoken INT(11) UNSIGNED NOT NULL DEFAULT '1'"); + $pdo->exec("ALTER TABLE $tableName DROP ctag"); + $pdo->exec("UPDATE $tableName SET synctoken = '1'"); + break; + case 'sqlite' : + $pdo->exec("ALTER TABLE $tableName ADD synctoken integer"); + $pdo->exec("UPDATE $tableName SET synctoken = '1'"); + echo "Note: there's no easy way to remove fields in sqlite.\n"; + echo "The ctag field is no longer used, but it's kept in place\n"; + break; + + } + + echo "Upgraded '$tableName' to 2.0 schema.\n"; + + } + + } + + try { + $pdo->query("SELECT * FROM $changesTable LIMIT 1"); + + echo "'$changesTable' already exists. Assuming that this part of the\n"; + echo "upgrade was already completed.\n"; + + } catch (Exception $e) { + echo "Creating '$changesTable' table.\n"; + + switch ($driver) { + + case 'mysql' : + $pdo->exec(" + CREATE TABLE $changesTable ( + id INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, + uri VARCHAR(200) NOT NULL, + synctoken INT(11) UNSIGNED NOT NULL, + {$itemType}id INT(11) UNSIGNED NOT NULL, + operation TINYINT(1) NOT NULL, + INDEX {$itemType}id_synctoken ({$itemType}id, synctoken) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + + "); + break; + case 'sqlite' : + $pdo->exec(" + + CREATE TABLE $changesTable ( + id integer primary key asc, + uri text, + synctoken integer, + {$itemType}id integer, + operation bool + ); + + "); + $pdo->exec("CREATE INDEX {$itemType}id_synctoken ON $changesTable ({$itemType}id, synctoken);"); + break; + + } + + } + +} + +try { + $pdo->query("SELECT * FROM calendarsubscriptions LIMIT 1"); + + echo "'calendarsubscriptions' already exists. Assuming that this part of the\n"; + echo "upgrade was already completed.\n"; + +} catch (Exception $e) { + echo "Creating calendarsubscriptions table.\n"; + + switch ($driver) { + + case 'mysql' : + $pdo->exec(" +CREATE TABLE calendarsubscriptions ( + id INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, + uri VARCHAR(200) NOT NULL, + principaluri VARCHAR(100) NOT NULL, + source TEXT, + displayname VARCHAR(100), + refreshrate VARCHAR(10), + calendarorder INT(11) UNSIGNED NOT NULL DEFAULT '0', + calendarcolor VARCHAR(10), + striptodos TINYINT(1) NULL, + stripalarms TINYINT(1) NULL, + stripattachments TINYINT(1) NULL, + lastmodified INT(11) UNSIGNED, + UNIQUE(principaluri, uri) +); + "); + break; + case 'sqlite' : + $pdo->exec(" + +CREATE TABLE calendarsubscriptions ( + id integer primary key asc, + uri text, + principaluri text, + source text, + displayname text, + refreshrate text, + calendarorder integer, + calendarcolor text, + striptodos bool, + stripalarms bool, + stripattachments bool, + lastmodified int +); + "); + + $pdo->exec("CREATE INDEX principaluri_uri ON calendarsubscriptions (principaluri, uri);"); + break; + + } + +} + +try { + $pdo->query("SELECT * FROM propertystorage LIMIT 1"); + + echo "'propertystorage' already exists. Assuming that this part of the\n"; + echo "upgrade was already completed.\n"; + +} catch (Exception $e) { + echo "Creating propertystorage table.\n"; + + switch ($driver) { + + case 'mysql' : + $pdo->exec(" +CREATE TABLE propertystorage ( + id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, + path VARBINARY(1024) NOT NULL, + name VARBINARY(100) NOT NULL, + value MEDIUMBLOB +); + "); + $pdo->exec(" +CREATE UNIQUE INDEX path_property ON propertystorage (path(600), name(100)); + "); + break; + case 'sqlite' : + $pdo->exec(" +CREATE TABLE propertystorage ( + id integer primary key asc, + path TEXT, + name TEXT, + value TEXT +); + "); + $pdo->exec(" +CREATE UNIQUE INDEX path_property ON propertystorage (path, name); + "); + + break; + + } + +} + +echo "Upgrading cards table to 2.0 schema\n"; + +try { + + $create = false; + $row = $pdo->query("SELECT * FROM cards LIMIT 1")->fetch(); + if (!$row) { + $random = mt_rand(1000, 9999); + echo "There was no data in the cards table, so we're re-creating it\n"; + echo "The old table will be renamed to cards_old$random, just in case.\n"; + + $create = true; + + switch ($driver) { + case 'mysql' : + $pdo->exec("RENAME TABLE cards TO cards_old$random"); + break; + case 'sqlite' : + $pdo->exec("ALTER TABLE cards RENAME TO cards_old$random"); + break; + + } + } + +} catch (Exception $e) { + + echo "Exception while checking cards table. Assuming that the table does not yet exist.\n"; + echo "Debug: ", $e->getMessage(), "\n"; + $create = true; + +} + +if ($create) { + switch ($driver) { + case 'mysql' : + $pdo->exec(" +CREATE TABLE cards ( + id INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, + addressbookid INT(11) UNSIGNED NOT NULL, + carddata MEDIUMBLOB, + uri VARCHAR(200), + lastmodified INT(11) UNSIGNED, + etag VARBINARY(32), + size INT(11) UNSIGNED NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + + "); + break; + + case 'sqlite' : + + $pdo->exec(" +CREATE TABLE cards ( + id integer primary key asc, + addressbookid integer, + carddata blob, + uri text, + lastmodified integer, + etag text, + size integer +); + "); + break; + + } +} else { + switch ($driver) { + case 'mysql' : + $pdo->exec(" + ALTER TABLE cards + ADD etag VARBINARY(32), + ADD size INT(11) UNSIGNED NOT NULL; + "); + break; + + case 'sqlite' : + + $pdo->exec(" + ALTER TABLE cards ADD etag text; + ALTER TABLE cards ADD size integer; + "); + break; + + } + echo "Reading all old vcards and populating etag and size fields.\n"; + $result = $pdo->query('SELECT id, carddata FROM cards'); + $stmt = $pdo->prepare('UPDATE cards SET etag = ?, size = ? WHERE id = ?'); + while ($row = $result->fetch(\PDO::FETCH_ASSOC)) { + $stmt->execute([ + md5($row['carddata']), + strlen($row['carddata']), + $row['id'] + ]); + } + + +} + +echo "Upgrade to 2.0 schema completed.\n"; diff --git a/vendor/sabre/dav/bin/migrateto21.php b/vendor/sabre/dav/bin/migrateto21.php new file mode 100755 index 000000000..f42c4cf88 --- /dev/null +++ b/vendor/sabre/dav/bin/migrateto21.php @@ -0,0 +1,180 @@ +#!/usr/bin/env php +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); +$pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); + +$driver = $pdo->getAttribute(PDO::ATTR_DRIVER_NAME); + +switch ($driver) { + + case 'mysql' : + echo "Detected MySQL.\n"; + break; + case 'sqlite' : + echo "Detected SQLite.\n"; + break; + default : + echo "Error: unsupported driver: " . $driver . "\n"; + die(-1); +} + +echo "Upgrading 'calendarobjects'\n"; +$addUid = false; +try { + $result = $pdo->query('SELECT * FROM calendarobjects LIMIT 1'); + $row = $result->fetch(\PDO::FETCH_ASSOC); + + if (!$row) { + echo "No data in table. Going to try to add the uid field anyway.\n"; + $addUid = true; + } elseif (array_key_exists('uid', $row)) { + echo "uid field exists. Assuming that this part of the migration has\n"; + echo "Already been completed.\n"; + } else { + echo "2.0 schema detected.\n"; + $addUid = true; + } + +} catch (Exception $e) { + echo "Could not find a calendarobjects table. Skipping this part of the\n"; + echo "upgrade.\n"; +} + +if ($addUid) { + + switch ($driver) { + case 'mysql' : + $pdo->exec('ALTER TABLE calendarobjects ADD uid VARCHAR(200)'); + break; + case 'sqlite' : + $pdo->exec('ALTER TABLE calendarobjects ADD uid TEXT'); + break; + } + + $result = $pdo->query('SELECT id, calendardata FROM calendarobjects'); + $stmt = $pdo->prepare('UPDATE calendarobjects SET uid = ? WHERE id = ?'); + $counter = 0; + + while ($row = $result->fetch(\PDO::FETCH_ASSOC)) { + + try { + $vobj = \Sabre\VObject\Reader::read($row['calendardata']); + } catch (\Exception $e) { + echo "Warning! Item with id $row[id] could not be parsed!\n"; + continue; + } + $uid = null; + $item = $vobj->getBaseComponent(); + if (!isset($item->UID)) { + echo "Warning! Item with id $item[id] does NOT have a UID property and this is required.\n"; + continue; + } + $uid = (string)$item->UID; + $stmt->execute([$uid, $row['id']]); + $counter++; + + } + +} + +echo "Creating 'schedulingobjects'\n"; + +switch ($driver) { + + case 'mysql' : + $pdo->exec('CREATE TABLE IF NOT EXISTS schedulingobjects +( + id INT(11) UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, + principaluri VARCHAR(255), + calendardata MEDIUMBLOB, + uri VARCHAR(200), + lastmodified INT(11) UNSIGNED, + etag VARCHAR(32), + size INT(11) UNSIGNED NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; + '); + break; + + + case 'sqlite' : + $pdo->exec('CREATE TABLE IF NOT EXISTS schedulingobjects ( + id integer primary key asc, + principaluri text, + calendardata blob, + uri text, + lastmodified integer, + etag text, + size integer +) +'); + break; + $pdo->exec(' + CREATE INDEX principaluri_uri ON calendarsubscriptions (principaluri, uri); + '); + break; +} + +echo "Done.\n"; + +echo "Upgrade to 2.1 schema completed.\n"; diff --git a/vendor/sabre/dav/bin/migrateto30.php b/vendor/sabre/dav/bin/migrateto30.php new file mode 100755 index 000000000..9ca77c13c --- /dev/null +++ b/vendor/sabre/dav/bin/migrateto30.php @@ -0,0 +1,171 @@ +#!/usr/bin/env php +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); +$pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); + +$driver = $pdo->getAttribute(PDO::ATTR_DRIVER_NAME); + +switch ($driver) { + + case 'mysql' : + echo "Detected MySQL.\n"; + break; + case 'sqlite' : + echo "Detected SQLite.\n"; + break; + default : + echo "Error: unsupported driver: " . $driver . "\n"; + die(-1); +} + +echo "Upgrading 'propertystorage'\n"; +$addValueType = false; +try { + $result = $pdo->query('SELECT * FROM propertystorage LIMIT 1'); + $row = $result->fetch(\PDO::FETCH_ASSOC); + + if (!$row) { + echo "No data in table. Going to re-create the table.\n"; + $random = mt_rand(1000, 9999); + echo "Renaming propertystorage -> propertystorage_old$random and creating new table.\n"; + + switch ($driver) { + + case 'mysql' : + $pdo->exec('RENAME TABLE propertystorage TO propertystorage_old' . $random); + $pdo->exec(' + CREATE TABLE propertystorage ( + id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, + path VARBINARY(1024) NOT NULL, + name VARBINARY(100) NOT NULL, + valuetype INT UNSIGNED, + value MEDIUMBLOB + ); + '); + $pdo->exec('CREATE UNIQUE INDEX path_property_' . $random . ' ON propertystorage (path(600), name(100));'); + break; + case 'sqlite' : + $pdo->exec('ALTER TABLE propertystorage RENAME TO propertystorage_old' . $random); + $pdo->exec(' +CREATE TABLE propertystorage ( + id integer primary key asc, + path text, + name text, + valuetype integer, + value blob +);'); + + $pdo->exec('CREATE UNIQUE INDEX path_property_' . $random . ' ON propertystorage (path, name);'); + break; + + } + } elseif (array_key_exists('valuetype', $row)) { + echo "valuetype field exists. Assuming that this part of the migration has\n"; + echo "Already been completed.\n"; + } else { + echo "2.1 schema detected. Going to perform upgrade.\n"; + $addValueType = true; + } + +} catch (Exception $e) { + echo "Could not find a propertystorage table. Skipping this part of the\n"; + echo "upgrade.\n"; + echo $e->getMessage(), "\n"; +} + +if ($addValueType) { + + switch ($driver) { + case 'mysql' : + $pdo->exec('ALTER TABLE propertystorage ADD valuetype INT UNSIGNED'); + break; + case 'sqlite' : + $pdo->exec('ALTER TABLE propertystorage ADD valuetype INT'); + + break; + } + + $pdo->exec('UPDATE propertystorage SET valuetype = 1 WHERE valuetype IS NULL '); + +} + +echo "Migrating vcardurl\n"; + +$result = $pdo->query('SELECT id, uri, vcardurl FROM principals WHERE vcardurl IS NOT NULL'); +$stmt1 = $pdo->prepare('INSERT INTO propertystorage (path, name, valuetype, value) VALUES (?, ?, 3, ?)'); + +while ($row = $result->fetch(\PDO::FETCH_ASSOC)) { + + // Inserting the new record + $stmt1->execute([ + 'addressbooks/' . basename($row['uri']), + '{http://calendarserver.org/ns/}me-card', + serialize(new Sabre\DAV\Xml\Property\Href($row['vcardurl'])) + ]); + + echo serialize(new Sabre\DAV\Xml\Property\Href($row['vcardurl'])); + +} + +echo "Done.\n"; +echo "Upgrade to 3.0 schema completed.\n"; diff --git a/vendor/sabre/dav/bin/naturalselection b/vendor/sabre/dav/bin/naturalselection new file mode 100755 index 000000000..52720e31e --- /dev/null +++ b/vendor/sabre/dav/bin/naturalselection @@ -0,0 +1,140 @@ +#!/usr/bin/env python + +# +# Copyright (c) 2009-2010 Evert Pot +# All rights reserved. +# http://www.rooftopsolutions.nl/ +# +# This utility is distributed along with SabreDAV +# license: http://sabre.io/license/ Modified BSD License + +import os +from optparse import OptionParser +import time + +def getfreespace(path): + stat = os.statvfs(path) + return stat.f_frsize * stat.f_bavail + +def getbytesleft(path,threshold): + return getfreespace(path)-threshold + +def run(cacheDir, threshold, sleep=5, simulate=False, min_erase = 0): + + bytes = getbytesleft(cacheDir,threshold) + if (bytes>0): + print "Bytes to go before we hit threshold:", bytes + else: + print "Threshold exceeded with:", -bytes, "bytes" + dir = os.listdir(cacheDir) + dir2 = [] + for file in dir: + path = cacheDir + '/' + file + dir2.append({ + "path" : path, + "atime": os.stat(path).st_atime, + "size" : os.stat(path).st_size + }) + + dir2.sort(lambda x,y: int(x["atime"]-y["atime"])) + + filesunlinked = 0 + gainedspace = 0 + + # Left is the amount of bytes that need to be freed up + # The default is the 'min_erase setting' + left = min_erase + + # If the min_erase setting is lower than the amount of bytes over + # the threshold, we use that number instead. + if left < -bytes : + left = -bytes + + print "Need to delete at least:", left; + + for file in dir2: + + # Only deleting files if we're not simulating + if not simulate: os.unlink(file["path"]) + left = int(left - file["size"]) + gainedspace = gainedspace + file["size"] + filesunlinked = filesunlinked + 1 + + if(left<0): + break + + print "%d files deleted (%d bytes)" % (filesunlinked, gainedspace) + + + time.sleep(sleep) + + + +def main(): + parser = OptionParser( + version="naturalselection v0.3", + description="Cache directory manager. Deletes cache entries based on accesstime and free space thresholds.\n" + + "This utility is distributed alongside SabreDAV.", + usage="usage: %prog [options] cacheDirectory", + ) + parser.add_option( + '-s', + dest="simulate", + action="store_true", + help="Don't actually make changes, but just simulate the behaviour", + ) + parser.add_option( + '-r','--runs', + help="How many times to check before exiting. -1 is infinite, which is the default", + type="int", + dest="runs", + default=-1 + ) + parser.add_option( + '-n','--interval', + help="Sleep time in seconds (default = 5)", + type="int", + dest="sleep", + default=5 + ) + parser.add_option( + '-l','--threshold', + help="Threshold in bytes (default = 10737418240, which is 10GB)", + type="int", + dest="threshold", + default=10737418240 + ) + parser.add_option( + '-m', '--min-erase', + help="Minimum number of bytes to erase when the threshold is reached. " + + "Setting this option higher will reduce the amount of times the cache directory will need to be scanned. " + + "(the default is 1073741824, which is 1GB.)", + type="int", + dest="min_erase", + default=1073741824 + ) + + options,args = parser.parse_args() + if len(args)<1: + parser.error("This utility requires at least 1 argument") + cacheDir = args[0] + + print "Natural Selection" + print "Cache directory:", cacheDir + free = getfreespace(cacheDir); + print "Current free disk space:", free + + runs = options.runs; + while runs!=0 : + run( + cacheDir, + sleep=options.sleep, + simulate=options.simulate, + threshold=options.threshold, + min_erase=options.min_erase + ) + if runs>0: + runs = runs - 1 + +if __name__ == '__main__' : + main() diff --git a/vendor/sabre/dav/bin/naturalselection.py b/vendor/sabre/dav/bin/naturalselection.py deleted file mode 100755 index aa5554dd0..000000000 --- a/vendor/sabre/dav/bin/naturalselection.py +++ /dev/null @@ -1,140 +0,0 @@ -#!/usr/bin/env python - -# -# Copyright (c) 2009-2010 Evert Pot -# All rights reserved. -# http://www.rooftopsolutions.nl/ -# -# This utility is distributed along with SabreDAV -# license: http://code.google.com/p/sabredav/wiki/License Modified BSD License - -import os -from optparse import OptionParser -import time - -def getfreespace(path): - stat = os.statvfs(path) - return stat.f_frsize * stat.f_bavail - -def getbytesleft(path,treshold): - return getfreespace(path)-treshold - -def run(cacheDir, treshold, sleep=5, simulate=False, min_erase = 0): - - bytes = getbytesleft(cacheDir,treshold) - if (bytes>0): - print "Bytes to go before we hit treshhold:", bytes - else: - print "Treshold exceeded with:", -bytes, "bytes" - dir = os.listdir(cacheDir) - dir2 = [] - for file in dir: - path = cacheDir + '/' + file - dir2.append({ - "path" : path, - "atime": os.stat(path).st_atime, - "size" : os.stat(path).st_size - }) - - dir2.sort(lambda x,y: int(x["atime"]-y["atime"])) - - filesunlinked = 0 - gainedspace = 0 - - # Left is the amount of bytes that need to be freed up - # The default is the 'min_erase setting' - left = min_erase - - # If the min_erase setting is lower than the amount of bytes over - # the treshold, we use that number instead. - if left < -bytes : - left = -bytes - - print "Need to delete at least:", left; - - for file in dir2: - - # Only deleting files if we're not simulating - if not simulate: os.unlink(file["path"]) - left = int(left - file["size"]) - gainedspace = gainedspace + file["size"] - filesunlinked = filesunlinked + 1 - - if(left<0): - break - - print "%d files deleted (%d bytes)" % (filesunlinked, gainedspace) - - - time.sleep(sleep) - - - -def main(): - parser = OptionParser( - version="naturalselecton v0.3", - description="Cache directory manager. Deletes cache entries based on accesstime and free space tresholds.\n" + - "This utility is distributed alongside SabreDAV.", - usage="usage: %prog [options] cacheDirectory", - ) - parser.add_option( - '-s', - dest="simulate", - action="store_true", - help="Don't actually make changes, but just simulate the behaviour", - ) - parser.add_option( - '-r','--runs', - help="How many times to check before exiting. -1 is infinite, which is the default", - type="int", - dest="runs", - default=-1 - ) - parser.add_option( - '-n','--interval', - help="Sleep time in seconds (default = 5)", - type="int", - dest="sleep", - default=5 - ) - parser.add_option( - '-l','--treshold', - help="Treshhold in bytes (default = 10737418240, which is 10GB)", - type="int", - dest="treshold", - default=10737418240 - ) - parser.add_option( - '-m', '--min-erase', - help="Minimum number of bytes to erase when the treshold is reached. " + - "Setting this option higher will reduce the amount of times the cache directory will need to be scanned. " + - "(the default is 1073741824, which is 1GB.)", - type="int", - dest="min_erase", - default=1073741824 - ) - - options,args = parser.parse_args() - if len(args)<1: - parser.error("This utility requires at least 1 argument") - cacheDir = args[0] - - print "Natural Selection" - print "Cache directory:", cacheDir - free = getfreespace(cacheDir); - print "Current free disk space:", free - - runs = options.runs; - while runs!=0 : - run( - cacheDir, - sleep=options.sleep, - simulate=options.simulate, - treshold=options.treshold, - min_erase=options.min_erase - ) - if runs>0: - runs = runs - 1 - -if __name__ == '__main__' : - main() diff --git a/vendor/sabre/dav/bin/sabredav.php b/vendor/sabre/dav/bin/sabredav.php index 34a674fd5..950075d1a 100755 --- a/vendor/sabre/dav/bin/sabredav.php +++ b/vendor/sabre/dav/bin/sabredav.php @@ -8,7 +8,7 @@ class CliLog { function __construct() { - $this->stream = fopen('php://stdout','w'); + $this->stream = fopen('php://stdout', 'w'); } @@ -20,19 +20,19 @@ class CliLog { $log = new CliLog(); -if (php_sapi_name()!=='cli-server') { +if (php_sapi_name() !== 'cli-server') { die("This script is intended to run on the built-in php webserver"); } // Finding composer -$paths = array( +$paths = [ __DIR__ . '/../vendor/autoload.php', __DIR__ . '/../../../autoload.php', -); +]; -foreach($paths as $path) { +foreach ($paths as $path) { if (file_exists($path)) { include $path; break; -- cgit v1.2.3 From 66effbfe0827fc61fff6d248797a894213ad20d6 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sat, 28 May 2016 17:46:24 +0200 Subject: upgrade to sabre32 --- vendor/sabre/dav/bin/build.php | 2 +- vendor/sabre/dav/bin/migrateto17.php | 52 +++---- vendor/sabre/dav/bin/migrateto21.php | 4 - vendor/sabre/dav/bin/migrateto32.php | 268 ++++++++++++++++++++++++++++++++++ vendor/sabre/dav/bin/naturalselection | 2 +- 5 files changed, 296 insertions(+), 32 deletions(-) create mode 100755 vendor/sabre/dav/bin/migrateto32.php (limited to 'vendor/sabre/dav/bin') diff --git a/vendor/sabre/dav/bin/build.php b/vendor/sabre/dav/bin/build.php index 82b1e7530..c4ba20941 100755 --- a/vendor/sabre/dav/bin/build.php +++ b/vendor/sabre/dav/bin/build.php @@ -110,7 +110,7 @@ function test() { echo " Running all unittests.\n"; echo " This may take a while.\n\n"; - system(__DIR__ . '/phpunit --configuration ' . $baseDir . '/tests/phpunit.xml --stop-on-failure', $code); + system(__DIR__ . '/phpunit --configuration ' . $baseDir . '/tests/phpunit.xml.dist --stop-on-failure', $code); if ($code != 0) { echo "PHPUnit reported error code $code\n"; die(1); diff --git a/vendor/sabre/dav/bin/migrateto17.php b/vendor/sabre/dav/bin/migrateto17.php index a1173c584..3ccf0a380 100755 --- a/vendor/sabre/dav/bin/migrateto17.php +++ b/vendor/sabre/dav/bin/migrateto17.php @@ -3,7 +3,7 @@ echo "SabreDAV migrate script for version 1.7\n"; -if ($argc < 2) { +if ($argc<2) { echo <<getAttribute(PDO::ATTR_DRIVER_NAME)) { + switch($pdo->getAttribute(PDO::ATTR_DRIVER_NAME)) { case 'mysql' : @@ -150,7 +150,7 @@ $stmt = $pdo->prepare('UPDATE calendarobjects SET etag = ?, size = ?, componentt echo "Total records found: " . $result->rowCount() . "\n"; $done = 0; $total = $result->rowCount(); -while ($row = $result->fetch()) { +while($row = $result->fetch()) { try { $newData = getDenormalizedData($row['calendardata']); @@ -161,14 +161,14 @@ while ($row = $result->fetch()) { echo "This record is ignored, you should inspect it to see if there's anything wrong.\n===\n"; continue; } - $stmt->execute([ + $stmt->execute(array( $newData['etag'], $newData['size'], $newData['componentType'], $newData['firstOccurence'], $newData['lastOccurence'], $row['id'], - ]); + )); $done++; if ($done % 500 === 0) { @@ -188,7 +188,7 @@ if (array_key_exists('transparent', $row)) { echo "Adding the 'transparent' field to the calendars table\n"; - switch ($pdo->getAttribute(PDO::ATTR_DRIVER_NAME)) { + switch($pdo->getAttribute(PDO::ATTR_DRIVER_NAME)) { case 'mysql' : $pdo->exec("ALTER TABLE calendars ADD transparent TINYINT(1) NOT NULL DEFAULT '0'"); @@ -229,8 +229,8 @@ function getDenormalizedData($calendarData) { $component = null; $firstOccurence = null; $lastOccurence = null; - foreach ($vObject->getComponents() as $component) { - if ($component->name !== 'VTIMEZONE') { + foreach($vObject->getComponents() as $component) { + if ($component->name!=='VTIMEZONE') { $componentType = $component->name; break; } @@ -262,7 +262,7 @@ function getDenormalizedData($calendarData) { $lastOccurence = $maxDate->getTimeStamp(); } else { $end = $it->getDtEnd(); - while ($it->valid() && $end < $maxDate) { + while($it->valid() && $end < $maxDate) { $end = $it->getDtEnd(); $it->next(); @@ -273,12 +273,12 @@ function getDenormalizedData($calendarData) { } } - return [ - 'etag' => md5($calendarData), - 'size' => strlen($calendarData), - 'componentType' => $componentType, + return array( + 'etag' => md5($calendarData), + 'size' => strlen($calendarData), + 'componentType' => $componentType, 'firstOccurence' => $firstOccurence, 'lastOccurence' => $lastOccurence, - ]; + ); } diff --git a/vendor/sabre/dav/bin/migrateto21.php b/vendor/sabre/dav/bin/migrateto21.php index f42c4cf88..c81ee5cca 100755 --- a/vendor/sabre/dav/bin/migrateto21.php +++ b/vendor/sabre/dav/bin/migrateto21.php @@ -169,10 +169,6 @@ switch ($driver) { ) '); break; - $pdo->exec(' - CREATE INDEX principaluri_uri ON calendarsubscriptions (principaluri, uri); - '); - break; } echo "Done.\n"; diff --git a/vendor/sabre/dav/bin/migrateto32.php b/vendor/sabre/dav/bin/migrateto32.php new file mode 100755 index 000000000..59732b511 --- /dev/null +++ b/vendor/sabre/dav/bin/migrateto32.php @@ -0,0 +1,268 @@ +#!/usr/bin/env php +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); +$pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); + +$driver = $pdo->getAttribute(PDO::ATTR_DRIVER_NAME); + +switch ($driver) { + + case 'mysql' : + echo "Detected MySQL.\n"; + break; + case 'sqlite' : + echo "Detected SQLite.\n"; + break; + default : + echo "Error: unsupported driver: " . $driver . "\n"; + die(-1); +} + +echo "Creating 'calendarinstances'\n"; +$addValueType = false; +try { + $result = $pdo->query('SELECT * FROM calendarinstances LIMIT 1'); + $result->fetch(\PDO::FETCH_ASSOC); + echo "calendarinstances exists. Assuming this part of the migration has already been done.\n"; +} catch (Exception $e) { + echo "calendarinstances does not yet exist. Creating table and migrating data.\n"; + + switch ($driver) { + case 'mysql' : + $pdo->exec(<<exec(" +INSERT INTO calendarinstances + ( + calendarid, + principaluri, + access, + displayname, + uri, + description, + calendarorder, + calendarcolor, + transparent + ) +SELECT + id, + principaluri, + 1, + displayname, + uri, + description, + calendarorder, + calendarcolor, + transparent +FROM calendars +"); + break; + case 'sqlite' : + $pdo->exec(<<exec(" +INSERT INTO calendarinstances + ( + calendarid, + principaluri, + access, + displayname, + uri, + description, + calendarorder, + calendarcolor, + transparent + ) +SELECT + id, + principaluri, + 1, + displayname, + uri, + description, + calendarorder, + calendarcolor, + transparent +FROM calendars +"); + break; + } + +} +try { + $result = $pdo->query('SELECT * FROM calendars LIMIT 1'); + $row = $result->fetch(\PDO::FETCH_ASSOC); + + if (!$row) { + echo "Source table is empty.\n"; + $migrateCalendars = true; + } + + $columnCount = count($row); + if ($columnCount === 3) { + echo "The calendars table has 3 columns already. Assuming this part of the migration was already done.\n"; + $migrateCalendars = false; + } else { + echo "The calendars table has " . $columnCount . " columns.\n"; + $migrateCalendars = true; + } + +} catch (Exception $e) { + echo "calendars table does not exist. This is a major problem. Exiting.\n"; + exit(-1); +} + +if ($migrateCalendars) { + + $calendarBackup = 'calendars_3_1_' . $backupPostfix; + echo "Backing up 'calendars' to '", $calendarBackup, "'\n"; + + switch ($driver) { + case 'mysql' : + $pdo->exec('RENAME TABLE calendars TO ' . $calendarBackup); + break; + case 'sqlite' : + $pdo->exec('ALTER TABLE calendars RENAME TO ' . $calendarBackup); + break; + + } + + echo "Creating new calendars table.\n"; + switch ($driver) { + case 'mysql' : + $pdo->exec(<<exec(<<exec(<< Date: Sun, 29 May 2016 00:33:28 +0200 Subject: missed some files --- vendor/sabre/dav/bin/migrateto17.php | 284 ----------------------------------- 1 file changed, 284 deletions(-) delete mode 100755 vendor/sabre/dav/bin/migrateto17.php (limited to 'vendor/sabre/dav/bin') diff --git a/vendor/sabre/dav/bin/migrateto17.php b/vendor/sabre/dav/bin/migrateto17.php deleted file mode 100755 index 3ccf0a380..000000000 --- a/vendor/sabre/dav/bin/migrateto17.php +++ /dev/null @@ -1,284 +0,0 @@ -#!/usr/bin/env php -setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); -$pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); - -echo "Validating existing table layout\n"; - -// The only cross-db way to do this, is to just fetch a single record. -$row = $pdo->query("SELECT * FROM calendarobjects LIMIT 1")->fetch(); - -if (!$row) { - echo "Error: This database did not have any records in the calendarobjects table, you should just recreate the table.\n"; - exit(-1); -} - -$requiredFields = array( - 'id', - 'calendardata', - 'uri', - 'calendarid', - 'lastmodified', -); - -foreach($requiredFields as $requiredField) { - if (!array_key_exists($requiredField,$row)) { - echo "Error: The current 'calendarobjects' table was missing a field we expected to exist.\n"; - echo "For safety reasons, this process is stopped.\n"; - exit(-1); - } -} - -$fields17 = array( - 'etag', - 'size', - 'componenttype', - 'firstoccurence', - 'lastoccurence', -); - -$found = 0; -foreach($fields17 as $field) { - if (array_key_exists($field, $row)) { - $found++; - } -} - -if ($found === 0) { - echo "The database had the 1.6 schema. Table will now be altered.\n"; - echo "This may take some time for large tables\n"; - - switch($pdo->getAttribute(PDO::ATTR_DRIVER_NAME)) { - - case 'mysql' : - - $pdo->exec(<<exec('ALTER TABLE calendarobjects ADD etag text'); - $pdo->exec('ALTER TABLE calendarobjects ADD size integer'); - $pdo->exec('ALTER TABLE calendarobjects ADD componenttype TEXT'); - $pdo->exec('ALTER TABLE calendarobjects ADD firstoccurence integer'); - $pdo->exec('ALTER TABLE calendarobjects ADD lastoccurence integer'); - break; - - default : - die('This upgrade script does not support this driver (' . $pdo->getAttribute(PDO::ATTR_DRIVER_NAME) . ")\n"); - - } - echo "Database schema upgraded.\n"; - -} elseif ($found === 5) { - - echo "Database already had the 1.7 schema\n"; - -} else { - - echo "The database had $found out of 5 from the changes for 1.7. This is scary and unusual, so we have to abort.\n"; - echo "You can manually try to upgrade the schema, and then run this script again.\n"; - exit(-1); - -} - -echo "Now, we need to parse every record and pull out some information.\n"; - -$result = $pdo->query('SELECT id, calendardata FROM calendarobjects'); -$stmt = $pdo->prepare('UPDATE calendarobjects SET etag = ?, size = ?, componenttype = ?, firstoccurence = ?, lastoccurence = ? WHERE id = ?'); - -echo "Total records found: " . $result->rowCount() . "\n"; -$done = 0; -$total = $result->rowCount(); -while($row = $result->fetch()) { - - try { - $newData = getDenormalizedData($row['calendardata']); - } catch (Exception $e) { - echo "===\nException caught will trying to parser calendarobject.\n"; - echo "Error message: " . $e->getMessage() . "\n"; - echo "Record id: " . $row['id'] . "\n"; - echo "This record is ignored, you should inspect it to see if there's anything wrong.\n===\n"; - continue; - } - $stmt->execute(array( - $newData['etag'], - $newData['size'], - $newData['componentType'], - $newData['firstOccurence'], - $newData['lastOccurence'], - $row['id'], - )); - $done++; - - if ($done % 500 === 0) { - echo "Completed: $done / $total\n"; - } -} -echo "Completed: $done / $total\n"; - -echo "Checking the calendars table needs changes.\n"; -$row = $pdo->query("SELECT * FROM calendars LIMIT 1")->fetch(); - -if (array_key_exists('transparent', $row)) { - - echo "The calendars table is already up to date\n"; - -} else { - - echo "Adding the 'transparent' field to the calendars table\n"; - - switch($pdo->getAttribute(PDO::ATTR_DRIVER_NAME)) { - - case 'mysql' : - $pdo->exec("ALTER TABLE calendars ADD transparent TINYINT(1) NOT NULL DEFAULT '0'"); - break; - case 'sqlite' : - $pdo->exec("ALTER TABLE calendars ADD transparent bool"); - break; - - default : - die('This upgrade script does not support this driver (' . $pdo->getAttribute(PDO::ATTR_DRIVER_NAME) . ")\n"); - - } - -} - -echo "Process completed!\n"; - -/** - * Parses some information from calendar objects, used for optimized - * calendar-queries. - * - * Blantently copied from Sabre\CalDAV\Backend\PDO - * - * Returns an array with the following keys: - * * etag - * * size - * * componentType - * * firstOccurence - * * lastOccurence - * - * @param string $calendarData - * @return array - */ -function getDenormalizedData($calendarData) { - - $vObject = \Sabre\VObject\Reader::read($calendarData); - $componentType = null; - $component = null; - $firstOccurence = null; - $lastOccurence = null; - foreach($vObject->getComponents() as $component) { - if ($component->name!=='VTIMEZONE') { - $componentType = $component->name; - break; - } - } - if (!$componentType) { - throw new \Sabre\DAV\Exception\BadRequest('Calendar objects must have a VJOURNAL, VEVENT or VTODO component'); - } - if ($componentType === 'VEVENT') { - $firstOccurence = $component->DTSTART->getDateTime()->getTimeStamp(); - // Finding the last occurence is a bit harder - if (!isset($component->RRULE)) { - if (isset($component->DTEND)) { - $lastOccurence = $component->DTEND->getDateTime()->getTimeStamp(); - } elseif (isset($component->DURATION)) { - $endDate = clone $component->DTSTART->getDateTime(); - $endDate->add(\Sabre\VObject\DateTimeParser::parse($component->DURATION->value)); - $lastOccurence = $endDate->getTimeStamp(); - } elseif (!$component->DTSTART->hasTime()) { - $endDate = clone $component->DTSTART->getDateTime(); - $endDate->modify('+1 day'); - $lastOccurence = $endDate->getTimeStamp(); - } else { - $lastOccurence = $firstOccurence; - } - } else { - $it = new \Sabre\VObject\Recur\EventIterator($vObject, (string)$component->UID); - $maxDate = new DateTime(\Sabre\CalDAV\Backend\PDO::MAX_DATE); - if ($it->isInfinite()) { - $lastOccurence = $maxDate->getTimeStamp(); - } else { - $end = $it->getDtEnd(); - while($it->valid() && $end < $maxDate) { - $end = $it->getDtEnd(); - $it->next(); - - } - $lastOccurence = $end->getTimeStamp(); - } - - } - } - - return array( - 'etag' => md5($calendarData), - 'size' => strlen($calendarData), - 'componentType' => $componentType, - 'firstOccurence' => $firstOccurence, - 'lastOccurence' => $lastOccurence, - ); - -} -- cgit v1.2.3 From cac6cef4952e6535788c1c6db8ef1e58e88536a0 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sun, 29 May 2016 10:58:11 +0200 Subject: use composer to install sabre32 --- vendor/sabre/dav/bin/build.php | 0 vendor/sabre/dav/bin/googlecode_upload.py | 0 vendor/sabre/dav/bin/migrateto20.php | 0 vendor/sabre/dav/bin/migrateto21.php | 0 vendor/sabre/dav/bin/migrateto30.php | 0 vendor/sabre/dav/bin/migrateto32.php | 0 vendor/sabre/dav/bin/sabredav.php | 0 7 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 vendor/sabre/dav/bin/build.php mode change 100755 => 100644 vendor/sabre/dav/bin/googlecode_upload.py mode change 100755 => 100644 vendor/sabre/dav/bin/migrateto20.php mode change 100755 => 100644 vendor/sabre/dav/bin/migrateto21.php mode change 100755 => 100644 vendor/sabre/dav/bin/migrateto30.php mode change 100755 => 100644 vendor/sabre/dav/bin/migrateto32.php mode change 100755 => 100644 vendor/sabre/dav/bin/sabredav.php (limited to 'vendor/sabre/dav/bin') diff --git a/vendor/sabre/dav/bin/build.php b/vendor/sabre/dav/bin/build.php old mode 100755 new mode 100644 diff --git a/vendor/sabre/dav/bin/googlecode_upload.py b/vendor/sabre/dav/bin/googlecode_upload.py old mode 100755 new mode 100644 diff --git a/vendor/sabre/dav/bin/migrateto20.php b/vendor/sabre/dav/bin/migrateto20.php old mode 100755 new mode 100644 diff --git a/vendor/sabre/dav/bin/migrateto21.php b/vendor/sabre/dav/bin/migrateto21.php old mode 100755 new mode 100644 diff --git a/vendor/sabre/dav/bin/migrateto30.php b/vendor/sabre/dav/bin/migrateto30.php old mode 100755 new mode 100644 diff --git a/vendor/sabre/dav/bin/migrateto32.php b/vendor/sabre/dav/bin/migrateto32.php old mode 100755 new mode 100644 diff --git a/vendor/sabre/dav/bin/sabredav.php b/vendor/sabre/dav/bin/sabredav.php old mode 100755 new mode 100644 -- cgit v1.2.3 From dcc65bbacb81801b5e138795c18ef9e740dbd26c Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 28 Jun 2016 21:45:14 +0200 Subject: update to sabre/dav to version 3.2.0 --- vendor/sabre/dav/bin/migrateto32.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'vendor/sabre/dav/bin') diff --git a/vendor/sabre/dav/bin/migrateto32.php b/vendor/sabre/dav/bin/migrateto32.php index 59732b511..7567aeb60 100644 --- a/vendor/sabre/dav/bin/migrateto32.php +++ b/vendor/sabre/dav/bin/migrateto32.php @@ -237,7 +237,7 @@ if ($migrateCalendars) { CREATE TABLE calendars ( id INTEGER UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT, synctoken INTEGER UNSIGNED NOT NULL DEFAULT '1', - components VARBINARY(20) + components VARBINARY(21) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; SQL ); -- cgit v1.2.3