sabre-io / Baikal

Baïkal is a Calendar+Contacts server
https://sabre.io/baikal/
GNU General Public License v3.0
2.42k stars 281 forks source link

Baikal seems to be triggering errors in PHP 8.2.2 #1244

Open 60600009 opened 4 months ago

60600009 commented 4 months ago

Windows 10 Pro PHP 8.2.2 Apache 2.4.51 Baikal 0.9.4

PHP Error is continually repeated about 12 times a second in the log, these errors appeared after I upgraded PHP to 2.8.x. Baikal is operating OK in every respect. Hoping someone can tell me what is causing this issue, is it an issue caused by something I have done, if so what do I need to do to fix it?

[16-Mar-2024 13:07:12 Australia/Brisbane] Sabre\DAV\Exception\PreconditionFailed: An If-Match header was specified, but none of the specified ETags matched. in C:\Apache24\htdocs\taxhunter\baikal\vendor\sabre\dav\lib\DAV\Server.php:1331 Stack trace:

0 C:\Apache24\htdocs\taxhunter\baikal\vendor\sabre\dav\lib\DAV\Server.php(466): Sabre\DAV\Server->checkPreconditions(Object(Sabre\HTTP\Request), Object(Sabre\HTTP\Response))

1 C:\Apache24\htdocs\taxhunter\baikal\vendor\sabre\dav\lib\DAV\Server.php(253): Sabre\DAV\Server->invokeMethod(Object(Sabre\HTTP\Request), Object(Sabre\HTTP\Response))

2 C:\Apache24\htdocs\taxhunter\baikal\vendor\sabre\dav\lib\DAV\Server.php(321): Sabre\DAV\Server->start()

3 C:\Apache24\htdocs\taxhunter\baikal\Core\Frameworks\Baikal\Core\Server.php(119): Sabre\DAV\Server->exec()

4 C:\Apache24\htdocs\taxhunter\baikal\html\dav.php(69): Baikal\Core\Server->start()

5 {main}

phil-davis commented 4 months ago

sabre/dav is checking the HTTP precondition "If-Match" that is in the request header. It finds that the Etag in the header does not match the Etag of the resource on the server, so it throws a PreconditionFailed exception.

I expect that Baikal should catch this exception and return a 412 "Precondition failed" as the response. But I don't see where that exception is handled by Baikal.

I can't think why this logging of the exception would be new with PHP 8.2.

What version of PHP were you using before upgrading?

60600009 commented 3 months ago

Hi Phil,

Thanks for your reply, we were using PHP 7.4.26.

We are using Baikal and accessing if from CardBook on Thunderbird,

Up until the time we went to PHP 8.2 we were getting no Baikal errors in the php error logs, they may have been occurring previously but if they were they were not being logged.

Stuart

phil-davis commented 2 months ago

I'm not an actual Baikal user, I do maintenance for sabre/dav

If there is anyone else with this or a similar issue, please mention here and it might help give a clue about what is happening.

tino commented 1 month ago

I get it too on a local, fresh Baikal install with my calendar imported. macOS Calendar seems to trigger it:

baikal-1  | 192.168.65.1 - tino [12/Jun/2024:06:53:34 +0000] "PUT /cal.php/calendars/tino/tino1/7A64A834-25C4-43DC-96DB-4ACD5C806A63.ics HTTP/1.1" 412 381 "-" "macOS/14.5 (23F79) dataacce
ssd/1.0" "127.0.0.1"
baikal-1  | 2024/06/12 06:53:34 [error] 51#51: *122 FastCGI sent in stderr: "PHP message: Sabre\DAV\Exception\PreconditionFailed: An If-None-Match header was specified, but the ETag match
ed (or * was specified). in /var/www/baikal/vendor/sabre/dav/lib/DAV/Server.php:1377
baikal-1  | Stack trace:
baikal-1  | #0 /var/www/baikal/vendor/sabre/dav/lib/DAV/Server.php(466): Sabre\DAV\Server->checkPreconditions()
baikal-1  | #1 /var/www/baikal/vendor/sabre/dav/lib/DAV/Server.php(253): Sabre\DAV\Server->invokeMethod()
baikal-1  | #2 /var/www/baikal/vendor/sabre/dav/lib/DAV/Server.php(321): Sabre\DAV\Server->start()
baikal-1  | #3 /var/www/baikal/Core/Frameworks/Baikal/Core/Server.php(118): Sabre\DAV\Server->exec()
baikal-1  | #4 /var/www/baikal/html/cal.php(74): Baikal\Core\Server->start()
baikal-1  | #5 {main}" while reading response header from upstream, client: 192.168.65.1, server: _, request: "PUT /cal.php/calendars/tino/tino1/7A64A834-25C4-43DC-96DB-4ACD5C806A63.ics H
TTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm.sock:", host: "127.0.0.1:8080"

I do see the 412 in the request log line (first line), so is this just a warning?

Oh I get the same from Thunderbird whilst testing btw:

baikal-1  | 192.168.65.1 - tino [12/Jun/2024:07:01:47 +0000] "PUT /cal.php/calendars/tino/tino1/02A309B6-DD31-466B-8F62-6BA66E679C19.ics HTTP/1.1" 412 358 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:115.0) Gecko/20100101 Thunderbird/115.11.1" "127.0.0.1"
baikal-1  | 2024/06/12 07:01:47 [error] 51#51: *428 FastCGI sent in stderr: "PHP message: Sabre\DAV\Exception\PreconditionFailed: An If-Match header was specified and the resource did not exist in /var/www/baikal/vendor/sabre/dav/lib/DAV/Server.php:1304
baikal-1  | Stack trace:
baikal-1  | #0 /var/www/baikal/vendor/sabre/dav/lib/DAV/Server.php(466): Sabre\DAV\Server->checkPreconditions()
baikal-1  | #1 /var/www/baikal/vendor/sabre/dav/lib/DAV/Server.php(253): Sabre\DAV\Server->invokeMethod()
baikal-1  | #2 /var/www/baikal/vendor/sabre/dav/lib/DAV/Server.php(321): Sabre\DAV\Server->start()
baikal-1  | #3 /var/www/baikal/Core/Frameworks/Baikal/Core/Server.php(118): Sabre\DAV\Server->exec()
baikal-1  | #4 /var/www/baikal/html/cal.php(74): Baikal\Core\Server->start()
baikal-1  | #5 {main}" while reading response header from upstream, client: 192.168.65.1, server: _, request: "PUT /cal.php/calendars/tino/tino1/02A309B6-DD31-466B-8F62-6BA66E679C19.ics HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm.sock:", host: "127.0.0.1:8080"
baikal-1  | 192.168.65.1 - tino [12/Jun/2024:07:01:48 +0000] "PUT /cal.php/calendars/tino/tino1/02A309B6-DD31-466B-8F62-6BA66E679C19.ics HTTP/1.1" 201 0 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:115.0) Gecko/20100101 Thunderbird/115.11.1" "127.0.0.1"

It does seem to try again, if I read the last line correctly?

I've seen it hundreds of times. But not anymore now that I removed the events I was playing with.

root@71ddbca97f11:/# php --version
PHP 8.1.29 (cli) (built: Jun  6 2024 16:45:05) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.29, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.29, Copyright (c), by Zend Technologies