Open 4b69 opened 2 years ago
At https://github.com/sabre-io/dav/blob/master/lib/CalDAV/Backend/PDO.php#L984 I see:
if (null === $currentToken || $currentToken < $operation['synctoken'] + 1) {
And when I run the code, $operation['synctoken']
is a string (numeric string, thankfully). I am suspicious that strict_types=1
enabled for this code means that incrementing a string + 1
would not be allowed. But I don't think that strict_types
in PHP has got so far as to check that sort of thing. I can't reproduce a problem when I execute that code locally.
Can you post the code that is around /var/www/baikal/vendor/sabre/dav/lib/CalDAV/Backend/PDO.php:984 on your system?
I would first like to make sure that I know the correct line of code that is crashing.
if (null === $currentToken || $currentToken < $operation['synctoken'] + 1) {
// SyncToken in CalDAV perspective is consistently the next number of the last synced change event in this class.
$currentToken = $operation['synctoken'] + 1;
}
++$result_count;
switch ($operation['operation']) {
case 1:
$result['added'][] = $uri;
break;
case 2:
$result['modified'][] = $uri;
break;
case 3:
$result['deleted'][] = $uri;
break;
}
}
Line 984 on my system is the same as in your quote.
I've had a further look and am only able to replicate the issue when trying to sync with Thunderbird (TbSync + Provider for CalDAV & CardDAV). The issue doesn't seem to occur with DavX5 on Andorid.
@4b69 are you able to temporarily try putting an explicit (int)
cast in front of the $operation['synctoken']
uses?
if (null === $currentToken || $currentToken < (int) $operation['synctoken'] + 1) {
// SyncToken in CalDAV perspective is consistently the next number of the last synced change event in this class.
$currentToken = (int) $operation['synctoken'] + 1;
}
And if that does not help, it would be useful to see what the value of $operation['synctoken']
is - it is expected to always be a numeric string, but maybe it somehow has some mix of numbers and characters.
Note: the failing line is new code introduced in https://github.com/sabre-io/dav/pull/1248 which was released in https://github.com/sabre-io/dav/blob/master/CHANGELOG.md#422-2021-12-09
if (null === $currentToken || $currentToken < (int) $operation['synctoken'] + 1) {
// SyncToken in CalDAV perspective is consistently the next number of the last synced change event in this class.
$currentToken = (int) $operation['synctoken'] + 1;
}
That fixes the issue instantly.
That fixes the issue instantly.
Thanks for the feedback. It would be great if you are able to find out what $operation['synctoken']
- put in some debug code like:
$x = $operation['synctoken'];
var_dump($x);
and somewhere on the server be able to see that var_dump($x)
output in a log file or...
It will make us more sure of fixing it properly if we know what kind of data is happening at run-time.
Using
ob_start();
var_dump($operation['synctoken']);
$data = ob_get_clean();
$fp = fopen("/tmp/phpdbg.txt", "w");
fwrite($fp, $data);
fclose($fp);
the output file contains:
string(4) "1076"
I was thinking that something like this is happening:
<?php
$x = "1076a";
$y = $x + 1;
var_dump($x);
var_dump($y);
NOTICE A non well formed numeric value encountered on line number 4
string(5) "1076a" int(1077)
If the "number" has extra characters on the end (or even whitespace) then this sort of notice is emitted, and is becoming an exception.
But your string is a numeric string with 4 valid digits.
This is an issue specific to sabre/dav, not Baikal. Moving to the sabre/dav repo.
I'm experiencing this issue on Baikal 0.9.3.
Since upgrading to Baikal 0.91 running Debian Bullseye with PHP 7.4, Baikal produces this error: