Fix PROPFIND with Depth 1 if external bind is included

Previously something like this would be logged if debugging is enabled:

davical: LOG: Principal: Query: DBGQ: SELECT * FROM collection WHERE user_no= :user_no
davical: LOG: Principal: Query: DBGQ:  ":user_no" => ""
davical: BUG: :DAViCal Fatal Error: [42883] SQLSTATE[42883]: Undefined function: 7 ERROR:  operator does not exist: integer = boolean\nLINE 1: SELECT * FROM collection WHERE user_no= FALSE\n                                              ^\nHINT:  No operator matches the given name and argument types. You might need to add explicit type casts. at /home/puck/work/Calendar/awl/inc/AwlDatabase.php:94

And this would be returned as a response:

DAViCal Fatal Error

user_no doesn't get set when construction the Collection for the external
bind, so, just handle that instead of sending the empty string to the
database as a user_no.

Modify the tests from ccc7e182ba4cbfba66a4fe96e1c0620e46390b95 to tickle the
bug.

Closes #175.
This commit is contained in:
Andrew Ruthven committed 2024-02-18 01:51:56 +13:00
1 parent d7d19b906f
commit e989e1cf97
8 files changed
+516 -14

No files matched your search

+1
View File
@@ -29,5 +29,6 @@ Listen 127.0.1.1:80
# let caldav.php handle "anything else"
RewriteCond %{REQUEST_URI} !^/$
RewriteCond %{REQUEST_URI} !\.(php|css|png|gif|js|jpg|ico)
RewriteCond %{REQUEST_URI} !/testfiles/.*$
RewriteRule ^(.*)$ /caldav.php$1 [NC,L]
</VirtualHost>
@@ -9,7 +9,7 @@ Content-Type: text/plain; charset="utf-8"
bind_id: >1058<
bound_source_id: >1057<
dav_displayname: >Moon<
dav_name: >/user4/Moon/<
external_url: >http://regression.host/testfiles/mooncal.ics?lang=de&phases%5Bfull%5D=true&phases%5Bnew%5D=true&phases%5Bquarter%5D=true&phases%5Bdaily%5D=false&events%5Blunareclipse%5D=true&events%5Bsolareclipse%5D=true&events%5Bmoonlanding%5D=false&before=P6M&after=P2Y&zone=CET<
parent_container: >/user4/<
dav_name: >/teamclient1/Moon/<
external_url: >http://regression/testfiles/mooncal.ics?lang=de&phases%5Bfull%5D=true&phases%5Bnew%5D=true&phases%5Bquarter%5D=true&phases%5Bdaily%5D=false&events%5Blunareclipse%5D=true&events%5Bsolareclipse%5D=true&events%5Bmoonlanding%5D=false&before=P6M&after=P2Y&zone=CET<
parent_container: >/teamclient1/<
@@ -3,8 +3,8 @@
#
TYPE=BIND
URL=http://regression.host/caldav.php/user4/
AUTH=user4:user4
URL=http://regression.host/caldav.php/teamclient1/
AUTH=admin:nimda
HEADER=User-Agent: Test external bind
HEADER=Content-Type: text/xml; charset="UTF-8"
@@ -16,7 +16,7 @@ BEGINDATA
<?xml version="1.0" encoding="utf-8"?>
<bind xmlns="DAV:">
<segment>Moon</segment>
<href>http://regression.host/testfiles/mooncal.ics?lang=de&amp;phases%5Bfull%5D=true&amp;phases%5Bnew%5D=true&amp;phases%5Bquarter%5D=true&amp;phases%5Bdaily%5D=false&amp;events%5Blunareclipse%5D=true&amp;events%5Bsolareclipse%5D=true&amp;events%5Bmoonlanding%5D=false&amp;before=P6M&amp;after=P2Y&amp;zone=CET</href>
<href>http://regression/testfiles/mooncal.ics?lang=de&amp;phases%5Bfull%5D=true&amp;phases%5Bnew%5D=true&amp;phases%5Bquarter%5D=true&amp;phases%5Bdaily%5D=false&amp;events%5Blunareclipse%5D=true&amp;events%5Bsolareclipse%5D=true&amp;events%5Bmoonlanding%5D=false&amp;before=P6M&amp;after=P2Y&amp;zone=CET</href>
</bind>
ENDDATA
@@ -5,8 +5,8 @@
#
TYPE=GET
URL=http://regression.host/caldav.php/user4/Moon
AUTH=user4:user4
URL=http://regression.host/caldav.php/teamclient1/Moon
AUTH=user1:user1
HEADER=User-Agent: DAViCalTester/public
HEAD
@@ -0,0 +1,487 @@
HTTP/1.1 207 Multi-Status
Date: Dow, 01 Jan 2000 00:00:00 GMT
Content-Location: /caldav.php/teamclient1/
DAV: 1, 2, 3, access-control, calendar-access, calendar-schedule
DAV: extended-mkcol, bind, addressbook, calendar-auto-schedule, calendar-proxy
ETag: "ac625cb5a5ff728cc50520d0aaae27dd"
Content-Length: 11956
Content-Type: text/xml; charset="utf-8"
<?xml version="1.0" encoding="utf-8" ?>
<multistatus xmlns="DAV:" xmlns:C="http://calendarserver.org/ns/" xmlns:C1="urn:ietf:params:xml:ns:caldav" xmlns:X="http://xmlns.davical.org/davical" xmlns:C2="urn:ietf:params:xml:ns:carddav">
<response>
<href>/caldav.php/teamclient1/</href>
<propstat>
<prop>
<current-user-privilege-set>
<privilege>
<read/>
</privilege>
<privilege>
<read-current-user-privilege-set/>
</privilege>
</current-user-privilege-set>
<displayname>Team for Client1</displayname>
<C:getctag>"002aad3bf49fc30b841eedc6eb9d4206"</C:getctag>
<owner>
<href>/caldav.php/teamclient1/</href>
</owner>
<resource-id>
<href>/caldav.php/.resources/1013</href>
</resource-id>
<resourcetype>
<collection/>
<principal/>
</resourcetype>
<C1:schedule-default-calendar-URL>
<href>/caldav.php/teamclient1/home/</href>
</C1:schedule-default-calendar-URL>
<supported-report-set>
<supported-report>
<report>
<principal-property-search/>
</report>
</supported-report>
<supported-report>
<report>
<principal-search-property-set/>
</report>
</supported-report>
<supported-report>
<report>
<expand-property/>
</report>
</supported-report>
<supported-report>
<report>
<principal-match/>
</report>
</supported-report>
<supported-report>
<report>
<sync-collection/>
</report>
</supported-report>
</supported-report-set>
</prop>
<status>HTTP/1.1 200 OK</status>
</propstat>
</response>
<response>
<href>/caldav.php/teamclient1/Moon/</href>
<propstat>
<prop>
<add-member>
<href>/caldav.php/teamclient1/Moon/?add_member</href>
</add-member>
<current-user-privilege-set>
<privilege>
<read/>
</privilege>
<privilege>
<read-acl/>
</privilege>
<privilege>
<read-current-user-privilege-set/>
</privilege>
</current-user-privilege-set>
<displayname>Moon</displayname>
<C:getctag>"4998d2df79f8f730e2f56f4d715bdba8"</C:getctag>
<owner>
<href>/caldav.php/.external/127bf0002abfcecbe9203a3015c9b54f</href>
</owner>
<resource-id>
<href>/caldav.php/.resources/1057</href>
</resource-id>
<resourcetype>
<collection/>
<C1:calendar/>
<X:webdav-binding/>
</resourcetype>
<C1:schedule-default-calendar-URL>
<href>/caldav.php/</href>
</C1:schedule-default-calendar-URL>
<C1:supported-calendar-component-set>
<C1:comp name="VEVENT"/>
<C1:comp name="VTODO"/>
<C1:comp name="VJOURNAL"/>
</C1:supported-calendar-component-set>
<supported-report-set>
<supported-report>
<report>
<principal-property-search/>
</report>
</supported-report>
<supported-report>
<report>
<principal-search-property-set/>
</report>
</supported-report>
<supported-report>
<report>
<expand-property/>
</report>
</supported-report>
<supported-report>
<report>
<principal-match/>
</report>
</supported-report>
<supported-report>
<report>
<sync-collection/>
</report>
</supported-report>
<supported-report>
<report>
<C1:calendar-query/>
</report>
</supported-report>
<supported-report>
<report>
<C1:calendar-multiget/>
</report>
</supported-report>
<supported-report>
<report>
<C1:free-busy-query/>
</report>
</supported-report>
</supported-report-set>
<sync-token>data:,7</sync-token>
</prop>
<status>HTTP/1.1 200 OK</status>
</propstat>
</response>
<response>
<href>/caldav.php/teamclient1/home/</href>
<propstat>
<prop>
<add-member>
<href>/caldav.php/teamclient1/home/?add_member</href>
</add-member>
<current-user-privilege-set>
<privilege>
<read/>
</privilege>
<privilege>
<read-current-user-privilege-set/>
</privilege>
<privilege>
<C1:read-free-busy/>
</privilege>
</current-user-privilege-set>
<displayname>teamclient1 home</displayname>
<C:getctag>"edc1a74f98499d4a547a7c23125cabf2"</C:getctag>
<owner>
<href>/caldav.php/teamclient1/</href>
</owner>
<resource-id>
<href>/caldav.php/.resources/450</href>
</resource-id>
<resourcetype>
<collection/>
<C1:calendar/>
</resourcetype>
<C1:schedule-default-calendar-URL>
<href>/caldav.php/teamclient1/home/</href>
</C1:schedule-default-calendar-URL>
<C1:supported-calendar-component-set>
<C1:comp name="VEVENT"/>
<C1:comp name="VTODO"/>
<C1:comp name="VJOURNAL"/>
</C1:supported-calendar-component-set>
<supported-report-set>
<supported-report>
<report>
<principal-property-search/>
</report>
</supported-report>
<supported-report>
<report>
<principal-search-property-set/>
</report>
</supported-report>
<supported-report>
<report>
<expand-property/>
</report>
</supported-report>
<supported-report>
<report>
<principal-match/>
</report>
</supported-report>
<supported-report>
<report>
<sync-collection/>
</report>
</supported-report>
<supported-report>
<report>
<C1:calendar-query/>
</report>
</supported-report>
<supported-report>
<report>
<C1:calendar-multiget/>
</report>
</supported-report>
<supported-report>
<report>
<C1:free-busy-query/>
</report>
</supported-report>
</supported-report-set>
<sync-token>data:,8</sync-token>
</prop>
<status>HTTP/1.1 200 OK</status>
</propstat>
</response>
<response>
<href>/caldav.php/teamclient1/addresses/</href>
<propstat>
<prop>
<add-member>
<href>/caldav.php/teamclient1/addresses/?add_member</href>
</add-member>
<current-user-privilege-set>
<privilege>
<read/>
</privilege>
<privilege>
<read-current-user-privilege-set/>
</privilege>
</current-user-privilege-set>
<displayname>teamclient1 addresses</displayname>
<C:getctag>"edc1a74f98499d4a547a7c23125cabf2"</C:getctag>
<owner>
<href>/caldav.php/teamclient1/</href>
</owner>
<resource-id>
<href>/caldav.php/.resources/750</href>
</resource-id>
<resourcetype>
<collection/>
<C2:addressbook/>
</resourcetype>
<C1:schedule-default-calendar-URL>
<href>/caldav.php/teamclient1/home/</href>
</C1:schedule-default-calendar-URL>
<supported-report-set>
<supported-report>
<report>
<principal-property-search/>
</report>
</supported-report>
<supported-report>
<report>
<principal-search-property-set/>
</report>
</supported-report>
<supported-report>
<report>
<expand-property/>
</report>
</supported-report>
<supported-report>
<report>
<principal-match/>
</report>
</supported-report>
<supported-report>
<report>
<sync-collection/>
</report>
</supported-report>
<supported-report>
<report>
<C2:addressbook-query/>
</report>
</supported-report>
<supported-report>
<report>
<C2:addressbook-multiget/>
</report>
</supported-report>
</supported-report-set>
<sync-token>data:,9</sync-token>
</prop>
<status>HTTP/1.1 200 OK</status>
</propstat>
</response>
<response>
<href>/caldav.php/teamclient1/calendar-proxy-read/</href>
<propstat>
<prop>
<add-member>
<href>/caldav.php/teamclient1/calendar-proxy-read/?add_member</href>
</add-member>
<current-user-privilege-set>
<privilege>
<read/>
</privilege>
<privilege>
<read-current-user-privilege-set/>
</privilege>
<privilege>
<C1:read-free-busy/>
</privilege>
</current-user-privilege-set>
<displayname>/teamclient1/calendar-proxy-read/</displayname>
<C:getctag>"bfc43198a490f445e8676ca22863d1f1"</C:getctag>
<owner>
<href>/caldav.php/teamclient1/</href>
</owner>
<resourcetype>
<principal/>
<collection/>
<C:calendar-proxy-read/>
</resourcetype>
<C1:schedule-default-calendar-URL>
<href>/caldav.php/teamclient1/home/</href>
</C1:schedule-default-calendar-URL>
<supported-report-set>
<supported-report>
<report>
<principal-property-search/>
</report>
</supported-report>
<supported-report>
<report>
<principal-search-property-set/>
</report>
</supported-report>
<supported-report>
<report>
<expand-property/>
</report>
</supported-report>
<supported-report>
<report>
<principal-match/>
</report>
</supported-report>
<supported-report>
<report>
<sync-collection/>
</report>
</supported-report>
<supported-report>
<report>
<C1:calendar-query/>
</report>
</supported-report>
<supported-report>
<report>
<C1:calendar-multiget/>
</report>
</supported-report>
<supported-report>
<report>
<C1:free-busy-query/>
</report>
</supported-report>
<supported-report>
<report>
<C2:addressbook-query/>
</report>
</supported-report>
<supported-report>
<report>
<C2:addressbook-multiget/>
</report>
</supported-report>
</supported-report-set>
</prop>
<status>HTTP/1.1 200 OK</status>
</propstat>
</response>
<response>
<href>/caldav.php/teamclient1/calendar-proxy-write/</href>
<propstat>
<prop>
<add-member>
<href>/caldav.php/teamclient1/calendar-proxy-write/?add_member</href>
</add-member>
<current-user-privilege-set>
<privilege>
<read/>
</privilege>
<privilege>
<read-current-user-privilege-set/>
</privilege>
<privilege>
<C1:read-free-busy/>
</privilege>
</current-user-privilege-set>
<displayname>/teamclient1/calendar-proxy-write/</displayname>
<C:getctag>"f869e3b42c47170cd27adae8494859f3"</C:getctag>
<owner>
<href>/caldav.php/teamclient1/</href>
</owner>
<resourcetype>
<principal/>
<collection/>
<C:calendar-proxy-write/>
</resourcetype>
<C1:schedule-default-calendar-URL>
<href>/caldav.php/teamclient1/home/</href>
</C1:schedule-default-calendar-URL>
<supported-report-set>
<supported-report>
<report>
<principal-property-search/>
</report>
</supported-report>
<supported-report>
<report>
<principal-search-property-set/>
</report>
</supported-report>
<supported-report>
<report>
<expand-property/>
</report>
</supported-report>
<supported-report>
<report>
<principal-match/>
</report>
</supported-report>
<supported-report>
<report>
<sync-collection/>
</report>
</supported-report>
<supported-report>
<report>
<C1:calendar-query/>
</report>
</supported-report>
<supported-report>
<report>
<C1:calendar-multiget/>
</report>
</supported-report>
<supported-report>
<report>
<C1:free-busy-query/>
</report>
</supported-report>
<supported-report>
<report>
<C2:addressbook-query/>
</report>
</supported-report>
<supported-report>
<report>
<C2:addressbook-multiget/>
</report>
</supported-report>
</supported-report-set>
</prop>
<status>HTTP/1.1 200 OK</status>
</propstat>
</response>
</multistatus>
@@ -6,10 +6,13 @@
#
TYPE=PROPFIND
URL=http://regression.host/caldav.php/user4
AUTH=user4:user4
URL=http://regression.host/caldav.php/teamclient1
AUTH=user1:user1
HEADER=User-Agent: DAViCalTester/public
HEADER=Brief: t
HEADER=Depth: 1
HEADER=Prefer: return=minimal
HEAD
BEGINDATA