fix(dav): scope CalDAV UID lookups to calendar objects - #62639
fix(dav): scope CalDAV UID lookups to calendar objects#62639joshtrichards wants to merge 4 commits into
Conversation
Signed-off-by: Josh <josh.t.richards@gmail.com>
Signed-off-by: Josh <josh.t.richards@gmail.com>
This prevents scheduling to work with subscriptions or federated calendars, not that we really support that, but it would prevent it. |
Yeah, but that already doesn't work with the way this function, query, and return are structured today (unless I'm overlooking something). And callers of this function today also assume the result will always be a regular calendar type. I think we'd be better off with dedicated function(s) for those needs rather than overloading this one. |
Signed-off-by: Josh <josh.t.richards@gmail.com>
SabreDAV uses this method (it's part of the interface) and doesn't expect anything on this level, so I'm afraid there could be other future uses that SabreDAV might introduce, which could lead us into issues. |
Signed-off-by: Josh <josh.t.richards@gmail.com>
Summary
This is equally a correctness, performance, bug elimination, and robustness PR. But it's still tiny1 and I think straightforward.
It tightens
CalDavBackend::getCalendarObjectByUID(), mostly so that it only resolves objects from regular calendars, rather than subscription or federated-calendar objects. The method’s documentation is also updated, particularly surrounding the the ambiguity of unrestricted lookups when the same UID exists in multiple owned calendars. It's possible theJOINchange will be performance bump, but that depends on the sophistication of the in-use database query optimizers.Specifics:
LEFT JOINtoINNER JOINbecause theWHEREis right-focused and the query filters onc.principaluri(so rows without a matchingcalendars(c) record are excluded anyway), so it makes no sense toLEFT JOINunless I'm somehow mistaken? (Also looks like this is already done presumably safely elsewhere, such as in the function immediately after,getCalendarObjectById()).$calendarUriparameter as an optional collection-scope filter and it's impact on caller responsibility.Notes:
Possible follow-up:
getCalendarObjectById()might have at least one of the above Issues too; worth a follow-up look.BirthdayServiceand any other consumers ofgetCalendarObjectByUID()that use mode 2.CalDavBackendfunctions for similar issues.TODO
Checklist
3. to review, feature component)stable32)AI (if applicable)
Footnotes
Well, excluding the docs I suppose! ↩
setMaxResults(1)only avoids retrieving unnecessary rows; it does not choose the correct calendar. The UID lookup itself has two valid modes: 1. Collection-scoped (caller supplies$calendarUri; deterministic); 2. Cross-calendar (this function supplies theCalendarUri, but the caller has to pay attention to it or else they'll perform the follow-up operation on the wrong calendar). Looks like consumers such asImportServicealready use mode 1, butBirthdayServiceuses mode 2 so it may need to look to make sure it's not problematic (existing behavior; not created by this PR). ↩