Skip to content

Commit

Permalink
Fix a potential issue when deleting real estate via import
Browse files Browse the repository at this point in the history
  • Loading branch information
zoglo committed Nov 12, 2024
1 parent b808fb5 commit 1e8fe59
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/Resources/contao/classes/RealEstateImporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -796,11 +796,15 @@ protected function updateCatalog($contactPersonRecords, $realEstateRecords)
continue;
}

// Delete real estate
$this->deleteRealEstateImages($objRealEstate, $objProvider);
$objRealEstate->delete();
$this->addLog('Real estate was deleted: ' . $realEstateRecords[$i][$this->objInterface->uniqueField], 2, 'success');
continue;
// Do not delete if the real estate does not exist
if (null !== $objRealEstate)
{
// Delete real estate
$this->deleteRealEstateImages($objRealEstate, $objProvider);
$objRealEstate->delete();
$this->addLog('Real estate was deleted: ' . $realEstateRecords[$i][$this->objInterface->uniqueField], 2, 'success');
continue;
}
}else{
$this->addLog('Real estate was updated: ' . $realEstateRecords[$i][$this->objInterface->uniqueField], 2, 'success');
}
Expand Down Expand Up @@ -1471,6 +1475,11 @@ protected function copyFile($fileName, $objFolder, $providerDirectoryName, $dire

protected function deleteRealEstateImages($objRealEstate, $objProvider)
{
if (null === $objRealEstate || null === $objProvider)
{
return;
}

$deleteFolder = $this->objFilesFolder->path . '/' . $objProvider->anbieternr . '/' . $objRealEstate->{$this->objInterface->uniqueField};

Files::getInstance()->rrdir($deleteFolder);
Expand Down

0 comments on commit 1e8fe59

Please sign in to comment.