aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/dav/bin
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/sabre/dav/bin')
-rw-r--r--[-rwxr-xr-x]vendor/sabre/dav/bin/build.php2
-rw-r--r--[-rwxr-xr-x]vendor/sabre/dav/bin/googlecode_upload.py0
-rwxr-xr-xvendor/sabre/dav/bin/migrateto17.php284
-rw-r--r--[-rwxr-xr-x]vendor/sabre/dav/bin/migrateto20.php0
-rw-r--r--[-rwxr-xr-x]vendor/sabre/dav/bin/migrateto21.php4
-rw-r--r--[-rwxr-xr-x]vendor/sabre/dav/bin/migrateto30.php0
-rw-r--r--vendor/sabre/dav/bin/migrateto32.php268
-rwxr-xr-xvendor/sabre/dav/bin/naturalselection2
-rw-r--r--[-rwxr-xr-x]vendor/sabre/dav/bin/sabredav.php0
9 files changed, 270 insertions, 290 deletions
diff --git a/vendor/sabre/dav/bin/build.php b/vendor/sabre/dav/bin/build.php
index 82b1e7530..c4ba20941 100755..100644
--- 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/googlecode_upload.py b/vendor/sabre/dav/bin/googlecode_upload.py
index caafd5ded..caafd5ded 100755..100644
--- a/vendor/sabre/dav/bin/googlecode_upload.py
+++ b/vendor/sabre/dav/bin/googlecode_upload.py
diff --git a/vendor/sabre/dav/bin/migrateto17.php b/vendor/sabre/dav/bin/migrateto17.php
deleted file mode 100755
index a1173c584..000000000
--- a/vendor/sabre/dav/bin/migrateto17.php
+++ /dev/null
@@ -1,284 +0,0 @@
-#!/usr/bin/env php
-<?php
-
-echo "SabreDAV migrate script for version 1.7\n";
-
-if ($argc < 2) {
-
- echo <<<HELLO
-
-This script help you migrate from a pre-1.7 database to 1.7 and later\n
-Both the 'calendarobjects' and 'calendars' tables will be upgraded.
-
-If you do not have this table, or don't use the default PDO CalDAV backend
-it's pointless to run this script.
-
-Keep in mind that some processing will be done on every single record of this
-table and in addition, ALTER TABLE commands will be executed.
-If you have a large calendarobjects table, this may mean that this process
-takes a while.
-
-Usage:
-
-php {$argv[0]} [pdo-dsn] [username] [password]
-
-For example:
-
-php {$argv[0]} "mysql:host=localhost;dbname=sabredav" root password
-php {$argv[0]} sqlite:data/sabredav.db
-
-HELLO;
-
- exit();
-
-}
-
-// There's a bunch of places where the autoloader could be, so we'll try all of
-// them.
-$paths = [
- __DIR__ . '/../vendor/autoload.php',
- __DIR__ . '/../../../autoload.php',
-];
-
-foreach ($paths as $path) {
- if (file_exists($path)) {
- include $path;
- break;
- }
-}
-
-$dsn = $argv[1];
-$user = isset($argv[2]) ? $argv[2] : null;
-$pass = isset($argv[3]) ? $argv[3] : null;
-
-echo "Connecting to database: " . $dsn . "\n";
-
-$pdo = new PDO($dsn, $user, $pass);
-$pdo->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 = [
- '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 = [
- '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(<<<SQL
-ALTER TABLE calendarobjects
-ADD etag VARCHAR(32),
-ADD size INT(11) UNSIGNED,
-ADD componenttype VARCHAR(8),
-ADD firstoccurence INT(11) UNSIGNED,
-ADD lastoccurence INT(11) UNSIGNED
-SQL
- );
- break;
- case 'sqlite' :
- $pdo->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([
- $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 [
- '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
index 77236804f..77236804f 100755..100644
--- a/vendor/sabre/dav/bin/migrateto20.php
+++ b/vendor/sabre/dav/bin/migrateto20.php
diff --git a/vendor/sabre/dav/bin/migrateto21.php b/vendor/sabre/dav/bin/migrateto21.php
index f42c4cf88..c81ee5cca 100755..100644
--- 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/migrateto30.php b/vendor/sabre/dav/bin/migrateto30.php
index 9ca77c13c..9ca77c13c 100755..100644
--- a/vendor/sabre/dav/bin/migrateto30.php
+++ b/vendor/sabre/dav/bin/migrateto30.php
diff --git a/vendor/sabre/dav/bin/migrateto32.php b/vendor/sabre/dav/bin/migrateto32.php
new file mode 100644
index 000000000..7567aeb60
--- /dev/null
+++ b/vendor/sabre/dav/bin/migrateto32.php
@@ -0,0 +1,268 @@
+#!/usr/bin/env php
+<?php
+
+echo "SabreDAV migrate script for version 3.2\n";
+
+if ($argc < 2) {
+
+ echo <<<HELLO
+
+This script help you migrate from a 3.1 database to 3.2 and later
+
+Changes:
+* Created a new calendarinstances table to support calendar sharing.
+* Remove a lot of columns from calendars.
+
+Keep in mind that ALTER TABLE commands will be executed. If you have a large
+dataset this may mean that this process takes a while.
+
+Make a back-up first. This script has been tested, but the amount of
+potential variants are extremely high, so it's impossible to deal with every
+possible situation.
+
+In the worst case, you will lose all your data. This is not an overstatement.
+
+Lastly, if you are upgrading from an older version than 3.1, make sure you run
+the earlier migration script first. Migration scripts must be ran in order.
+
+Usage:
+
+php {$argv[0]} [pdo-dsn] [username] [password]
+
+For example:
+
+php {$argv[0]} "mysql:host=localhost;dbname=sabredav" root password
+php {$argv[0]} sqlite:data/sabredav.db
+
+HELLO;
+
+ exit();
+
+}
+
+// There's a bunch of places where the autoloader could be, so we'll try all of
+// them.
+$paths = [
+ __DIR__ . '/../vendor/autoload.php',
+ __DIR__ . '/../../../autoload.php',
+];
+
+foreach ($paths as $path) {
+ if (file_exists($path)) {
+ include $path;
+ break;
+ }
+}
+
+$dsn = $argv[1];
+$user = isset($argv[2]) ? $argv[2] : null;
+$pass = isset($argv[3]) ? $argv[3] : null;
+
+$backupPostfix = time();
+
+echo "Connecting to database: " . $dsn . "\n";
+
+$pdo = new PDO($dsn, $user, $pass);
+$pdo->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(<<<SQL
+CREATE TABLE calendarinstances (
+ id INTEGER UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
+ calendarid INTEGER UNSIGNED NOT NULL,
+ principaluri VARBINARY(100),
+ access TINYINT(1) NOT NULL DEFAULT '1' COMMENT '1 = owner, 2 = read, 3 = readwrite',
+ displayname VARCHAR(100),
+ uri VARBINARY(200),
+ description TEXT,
+ calendarorder INT(11) UNSIGNED NOT NULL DEFAULT '0',
+ calendarcolor VARBINARY(10),
+ timezone TEXT,
+ transparent TINYINT(1) NOT NULL DEFAULT '0',
+ share_href VARBINARY(100),
+ share_displayname VARCHAR(100),
+ share_invitestatus TINYINT(1) NOT NULL DEFAULT '2' COMMENT '1 = noresponse, 2 = accepted, 3 = declined, 4 = invalid',
+ UNIQUE(principaluri, uri),
+ UNIQUE(calendarid, principaluri),
+ UNIQUE(calendarid, share_href)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
+SQL
+ );
+ $pdo->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(<<<SQL
+CREATE TABLE calendarinstances (
+ id integer primary key asc NOT NULL,
+ calendarid integer,
+ principaluri text,
+ access integer COMMENT '1 = owner, 2 = read, 3 = readwrite' NOT NULL DEFAULT '1',
+ displayname text,
+ uri text NOT NULL,
+ description text,
+ calendarorder integer,
+ calendarcolor text,
+ timezone text,
+ transparent bool,
+ share_href text,
+ share_displayname text,
+ share_invitestatus integer DEFAULT '2',
+ UNIQUE (principaluri, uri),
+ UNIQUE (calendarid, principaluri),
+ UNIQUE (calendarid, share_href)
+);
+SQL
+ );
+ $pdo->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(<<<SQL
+CREATE TABLE calendars (
+ id INTEGER UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
+ synctoken INTEGER UNSIGNED NOT NULL DEFAULT '1',
+ components VARBINARY(21)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
+SQL
+);
+ break;
+ case 'sqlite' :
+ $pdo->exec(<<<SQL
+CREATE TABLE calendars (
+ id integer primary key asc NOT NULL,
+ synctoken integer DEFAULT 1 NOT NULL,
+ components text NOT NULL
+);
+SQL
+ );
+ break;
+
+ }
+
+ echo "Migrating data from old to new table\n";
+
+ $pdo->exec(<<<SQL
+INSERT INTO calendars (id, synctoken, components) SELECT id, synctoken, COALESCE(components,"VEVENT,VTODO,VJOURNAL") as components FROM $calendarBackup
+SQL
+ );
+
+}
+
+
+echo "Upgrade to 3.2 schema completed.\n";
diff --git a/vendor/sabre/dav/bin/naturalselection b/vendor/sabre/dav/bin/naturalselection
index 52720e31e..7e20439c1 100755
--- a/vendor/sabre/dav/bin/naturalselection
+++ b/vendor/sabre/dav/bin/naturalselection
@@ -107,7 +107,7 @@ def main():
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. " +
+ "Setting this option higher will reduce the number of times the cache directory will need to be scanned. " +
"(the default is 1073741824, which is 1GB.)",
type="int",
dest="min_erase",
diff --git a/vendor/sabre/dav/bin/sabredav.php b/vendor/sabre/dav/bin/sabredav.php
index 950075d1a..950075d1a 100755..100644
--- a/vendor/sabre/dav/bin/sabredav.php
+++ b/vendor/sabre/dav/bin/sabredav.php