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

[BUGFIX] Restrict ics-import to pid per calendar #775

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions Classes/Domain/Repository/EventRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,20 @@ public function findBySearch(Search $search)

/**
* @param $importId
* @param $pid
*
* @return mixed|null
*/
public function findOneByImportId($importId)
public function findOneByImportId($importId, $pid)
{
$query = $this->createQuery();
$query->getQuerySettings()->setRespectStoragePage(false);
$query->getQuerySettings()->setIgnoreEnableFields(true);
$query->matching($query->equals('importId', $importId));

$query->matching($query->logicalAnd(
$query->equals('importId', $importId),
$query->equals('pid', $pid),
));
$result = $query->execute()->toArray();

return $result[0] ?? null;
Expand Down
7 changes: 4 additions & 3 deletions Classes/EventListener/ImportSingleIcalEventListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function __invoke(ImportSingleIcalEvent $event)
$pid = $event->getPid();

$importId = \strlen($calEvent->getUid()) <= 100 ? $calEvent->getUid() : md5($calEvent->getUid());
$eventObj = $this->initializeEventRecord($importId);
$eventObj = $this->initializeEventRecord($importId, $pid);
$this->hydrateEventRecord($eventObj, $calEvent, $pid);

if (null !== $eventObj->getUid() && (int)$eventObj->getUid() > 0) {
Expand All @@ -77,12 +77,13 @@ public function __invoke(ImportSingleIcalEvent $event)
* Initializes or gets an event by import id.
*
* @param string $importId
* @param int $pid
*
* @return Event
*/
private function initializeEventRecord(string $importId): Event
private function initializeEventRecord(string $importId, int $pid): Event
{
$eventObj = $this->eventRepository->findOneByImportId($importId);
$eventObj = $this->eventRepository->findOneByImportId($importId, $pid);

if (!($eventObj instanceof Event)) {
$eventObj = new Event();
Expand Down
Loading