Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(caldav): add repair steps in sabre calendarobject change hook #42347

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tcitworld
Copy link
Member

@tcitworld tcitworld commented Dec 18, 2023

Summary

Introduce a middleware repair step for calendar data before it's being saved or updated.

TODO

  • Add an appconfig to opt-in to the middleware repair step, as this could be quite heavy on the database
  • Add a test for the description repair step
  • Make it more generic to handle CardDAV data as well?

Checklist

@tcitworld tcitworld added 2. developing Work in progress feature: caldav Related to CalDAV internals labels Dec 18, 2023
@tcitworld tcitworld added this to the Nextcloud 29 milestone Dec 18, 2023
// Compare descriptions
$isSameDescription = (string) $oldObject->DESCRIPTION === (string) $newObject->DESCRIPTION;
$isSameXAltDesc = (string) $oldObject->{self::X_ALT_DESC_PROP_NAME} === (string) $newObject->{self::X_ALT_DESC_PROP_NAME};
$isSameAltRep = (string) $oldObject->DESCRIPTION['ALTREP'] === (string) $newObject->DESCRIPTION['ALTREP'];

Check failure

Code scanning / Psalm

InvalidCast Error

Sabre\VObject\Node cannot be cast to string
// Compare descriptions
$isSameDescription = (string) $oldObject->DESCRIPTION === (string) $newObject->DESCRIPTION;
$isSameXAltDesc = (string) $oldObject->{self::X_ALT_DESC_PROP_NAME} === (string) $newObject->{self::X_ALT_DESC_PROP_NAME};
$isSameAltRep = (string) $oldObject->DESCRIPTION['ALTREP'] === (string) $newObject->DESCRIPTION['ALTREP'];

Check failure

Code scanning / Psalm

InvalidCast Error

Sabre\VObject\Node cannot be cast to string

public function onCalendarObjectChange(?VCalendar $oldVCalendar, ?VCalendar $newVCalendar, bool &$modified): void {
$keyedOldComponents = [];
foreach ($oldVCalendar->children() as $child) {

Check notice

Code scanning / Psalm

PossiblyNullReference Note

Cannot call method children on possibly null value
if (!($child instanceof Component)) {
continue;
}
$keyedOldComponents[$child->UID] = $child;

Check notice

Code scanning / Psalm

PossiblyNullArrayOffset Note

Cannot access value on variable $keyedOldComponents[$child->UID] using possibly null offset Sabre\VObject\Property|null

class Plugin extends ServerPlugin {

private Server $server;

Check notice

Code scanning / Psalm

PropertyNotSetInConstructor Note

Property OCA\DAV\CalDAV\Repair\Plugin::$server is not defined in constructor of OCA\DAV\CalDAV\Repair\Plugin or in any private or final methods called in the constructor
}

public function registerRepairStep(string $repairStep): self {
$this->addRepairStep(new $repairStep);

Check notice

Code scanning / Psalm

InvalidStringClass Note

String cannot be used as a class
}

public function registerRepairStep(string $repairStep): self {
$this->addRepairStep(new $repairStep);

Check notice

Code scanning / Psalm

ArgumentTypeCoercion Note

Argument 1 of OCA\DAV\CalDAV\Repair\RepairStepFactory::addRepairStep expects OCA\DAV\CalDAV\Repair\IRepairStep, but parent type object provided
This was referenced Mar 12, 2024
This was referenced Mar 20, 2024
@skjnldsv skjnldsv mentioned this pull request Mar 28, 2024
81 tasks
@skjnldsv skjnldsv modified the milestones: Nextcloud 29, Nextcloud 30 Mar 28, 2024
This was referenced Jul 30, 2024
This was referenced Aug 5, 2024
@skjnldsv skjnldsv mentioned this pull request Aug 13, 2024
@skjnldsv skjnldsv removed this from the Nextcloud 30 milestone Aug 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2. developing Work in progress feature: caldav Related to CalDAV internals
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants