tine-groupware / tine

tine groupware main repository
https://www.tine-groupware.de
GNU Affero General Public License v3.0
14 stars 2 forks source link

sabre-dav issue in weekly-2024.30.1 (Double timezone specification) #68

Closed ignoreigor closed 3 months ago

ignoreigor commented 3 months ago

There is a problem with DAV-sync in weekly-2024.30.1. I got an error 500 when syncing /calendars/shared/51/

<d:error>
<s:exception>Exception</s:exception>
<s:message>
Failed to parse time string (@2024-01-07 09:12:33) at position 8 (-): Double timezone specification
</s:message>
</d:error>

I found the corresponding event, by looking for the date. It's the modification date of an appointment that has been in the calendar for a long time. If I delete it, the same error is displayed with another appointment long in the past. In the database record of this event there are no abnormalities visible.

Going back to weekly-2024.29.1, the error is gone and sync works as usual.

pschuele commented 3 months ago

hi @ignoreigor , thx for the report. do you have a stacktrace of the error in the php logs?

@paulmhh can you have a look at this problem, too?

ignoreigor commented 3 months ago

hi, there is no error in tine.log even after increasing the loglevel to DEBUG (8). But, after increasing the loglevel, a stacktrace is reported beneath the DAV-error when calling the suspicious container's URL via browser.

<d:error xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
  <s:exception>Exception</s:exception>
  <s:message>Failed to parse time string (@2024-07-29 07:17:08) at position 8 (-): Double timezone specification</s:message>
  <s:file>/var/www/vendor/sabre/dav/lib/DAV/Xml/Property/GetLastModified.php</s:file>
  <s:line>43</s:line>
  <s:code>0</s:code>
  <s:stacktrace>#0 /var/www/vendor/sabre/dav/lib/DAV/Xml/Property/GetLastModified.php(43): DateTime-&gt;__construct()
#1 /var/www/vendor/sabre/dav/lib/DAV/CorePlugin.php(751): Sabre\DAV\Xml\Property\GetLastModified-&gt;__construct()
#2 /var/www/vendor/sabre/dav/lib/DAV/PropFind.php(95): Sabre\DAV\CorePlugin-&gt;Sabre\DAV\{closure}()
#3 /var/www/vendor/sabre/dav/lib/DAV/CorePlugin.php(748): Sabre\DAV\PropFind-&gt;handle()
#4 /var/www/vendor/sabre/event/lib/WildcardEmitterTrait.php(89): Sabre\DAV\CorePlugin-&gt;propFind()
#5 /var/www/vendor/sabre/dav/lib/DAV/Server.php(1052): Sabre\DAV\Server-&gt;emit()
#6 /var/www/vendor/sabre/dav/lib/DAV/Server.php(984): Sabre\DAV\Server-&gt;getPropertiesByNode()
#7 [internal function]: Sabre\DAV\Server-&gt;getPropertiesIteratorForPath()
#8 /var/www/vendor/sabre/dav/lib/DAV/Server.php(941): iterator_to_array()
#9 /var/www/vendor/sabre/dav/lib/DAV/Server.php(824): Sabre\DAV\Server-&gt;getPropertiesForPath()
#10 /var/www/vendor/sabre/dav/lib/DAV/Browser/Plugin.php(268): Sabre\DAV\Server-&gt;getPropertiesForChildren()
#11 /var/www/vendor/sabre/dav/lib/DAV/Browser/Plugin.php(133): Sabre\DAV\Browser\Plugin-&gt;generateDirectoryIndex()
#12 /var/www/vendor/sabre/event/lib/WildcardEmitterTrait.php(89): Sabre\DAV\Browser\Plugin-&gt;httpGet()
#13 /var/www/vendor/sabre/dav/lib/DAV/Server.php(472): Sabre\DAV\Server-&gt;emit()
#14 /var/www/vendor/sabre/dav/lib/DAV/Server.php(253): Sabre\DAV\Server-&gt;invokeMethod()
#15 /var/www/vendor/sabre/dav/lib/DAV/Server.php(321): Sabre\DAV\Server-&gt;start()
#16 /var/www/Tinebase/Server/WebDAV.php(303): Sabre\DAV\Server-&gt;exec()
#17 /var/www/Tinebase/Core.php(270): Tinebase_Server_WebDAV-&gt;handle()
#18 /var/www/index.php(24): Tinebase_Core::dispatchRequest()
#19 {main}</s:stacktrace>
</d:error>
pschuele commented 3 months ago

thanks for the stacktrace, we'll have a look

ignoreigor commented 3 months ago

Constructor of GetLastModified in both versions is the same (quick look), but isn't called in my working version.

It seems to be caused by mixed date formats, passed by $time. Normally you would expect an integer unix timestamp to parse it with '@' in case it isn't already a DateTime-object. But sometimes $time is a formatted string, so the preprended '@' crashes the format.

Is the problem only with me because fields in the database are not clean or are there different call sources of the constructor that cause the error?

paulmhh commented 3 months ago

the problem should be fixed with https://github.com/tine-groupware/tine/commit/0d9165c1823925229bef130ccb35f9b73594c900 thank you for reporting

ignoreigor commented 3 months ago

the problem should be fixed with 0d9165c thank you for reporting

It works like a charm! Thank you!

ignoreigor commented 3 months ago

Rehi, another error is thrown, concerning this issue. I think you'll have to look at Calendar/Frontend/WebDAV/Container.php and do the same thing.

HTTP RESPONSE
Response{protocol=h2, code=500, message=, url=https://www.frotzelei.de/calendars/4dc71a8074e8e5b3bd47a1de2e161154cc7e0afe/35/}
<?xml version="1.0" encoding="utf-8"?>
<d:error xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
  <s:exception>TypeError</s:exception>
  <s:message>DateTime::__construct(): Argument #1 ($datetime) must be of type string, DateTimeImmutable given</s:message>
  <s:file>/var/www/Tinebase/DateTime.php</s:file>
  <s:line>114</s:line>
  <s:code>0</s:code>
  <s:stacktrace>#0 /var/www/Tinebase/DateTime.php(114): DateTime-&gt;__construct()
#1 /var/www/Calendar/Frontend/WebDAV/Container.php(283): Tinebase_DateTime-&gt;__construct()
#2 /var/www/vendor/sabre/dav/lib/CalDAV/Plugin.php(598): Calendar_Frontend_WebDAV_Container-&gt;calendarQuery()
#3 /var/www/vendor/sabre/dav/lib/CalDAV/Plugin.php(258): Sabre\CalDAV\Plugin-&gt;calendarQueryReport()
#4 /var/www/vendor/sabre/event/lib/WildcardEmitterTrait.php(89): Sabre\CalDAV\Plugin-&gt;report()
#5 /var/www/vendor/sabre/dav/lib/DAV/CorePlugin.php(690): Sabre\DAV\Server-&gt;emit()
#6 /var/www/vendor/sabre/event/lib/WildcardEmitterTrait.php(89): Sabre\DAV\CorePlugin-&gt;httpReport()
#7 /var/www/vendor/sabre/dav/lib/DAV/Server.php(472): Sabre\DAV\Server-&gt;emit()
#8 /var/www/vendor/sabre/dav/lib/DAV/Server.php(253): Sabre\DAV\Server-&gt;invokeMethod()
#9 /var/www/vendor/sabre/dav/lib/DAV/Server.php(321): Sabre\DAV\Server-&gt;start()
#10 /var/www/Tinebase/Server/WebDAV.php(303): Sabre\DAV\Server-&gt;exec()
#11 /var/www/Tinebase/Core.php(270): Tinebase_Server_WebDAV-&gt;handle()
#12 /var/www/index.php(24): Tinebase_Core::dispatchRequest()
#13 {main}</s:stacktrace>
</d:error>

Maybe something like

$timeRange['start'] = ($timeRange['start'] instanceof Tinebase_DateTime) ? $timeRange['start']->getTimestamp() : null;
$timeRange['end'] = ($timeRange['end'] instanceof Tinebase_DateTime) ? $timeRange['end']->getTimestamp() : null;

but that was maybe to trivial in this case.

paulmhh commented 3 months ago

this is actually a bug in Tinebase_DateTime, the new sabre.io dav library version provides DateTimeImmutables and Tinebase_DateTime can not be constructed with them, fixed that, will let you know once commit is available, thanks for reporting again

paulmhh commented 3 months ago

should be fixed in 7981d5023e4cab13f7307f70eb4eb2b085cd09bd