dav
dav copied to clipboard
PropPatch handler should be called only once for bulk updates
PropPatch::handleRemaining() registers a callback for every single property. However, the callback receives the full list of properties which all get handled in the first iteration, making every subsequent iteration redundant. At best, this does nothing except having a potential perfomance impact. At worst, the callback has side effects which may cause unexpected behaviour.
As a workaround, I keep track of the operation and abort the redundant callback invocations:
class PropertiesBackend implements BackendInterface
{
private bool $updateInProgress = false;
public function propPatch($path, PropPatch $propPatch): void
{
$propPatch->handleRemaining(fn($changedProps) => $this->updateProperties($changedProps));
$this->updateInProgress = false;
}
private function updateProperties(array $properties): bool
{
if ($this->updateInProgress) {
return true;
}
$this->updateInProgress = true;
...
}
...
}
Feel free to submit a pull request this these changes including a test case. THX a lot