fix deleting invoice documents (#2980)

This commit is contained in:
Kevin Papst
2021-11-29 15:57:39 +01:00
committed by GitHub
parent d994339de5
commit 9491f07ade
3 changed files with 9 additions and 5 deletions

View File

@@ -17,11 +17,11 @@ class Constants
/**
* The current release version
*/
public const VERSION = '1.16.5';
public const VERSION = '1.16.6';
/**
* The current release: major * 10000 + minor * 100 + patch
*/
public const VERSION_ID = 11605;
public const VERSION_ID = 11606;
/**
* The current release status, either "stable" or "dev"
*/

View File

@@ -443,8 +443,8 @@ final class InvoiceController extends AbstractController
$csrfTokenManager->refreshToken('invoice.delete_document');
foreach ($documentRepository->findBuiltIn() as $document) {
if ($document->getId() === $id) {
foreach ($documentRepository->findBuiltIn() as $doc) {
if ($doc->getId() === $id) {
throw new \Exception('Document is built-in and cannot be deleted');
}
}

View File

@@ -55,7 +55,11 @@ final class InvoiceDocumentRepository
*/
public function remove(InvoiceDocument $invoiceDocument): void
{
@unlink($invoiceDocument->getFilename());
if (stripos($invoiceDocument->getFilename(), $this->getUploadDirectory()) === false) {
throw new \InvalidArgumentException('Cannot delete built-in invoice template');
}
@unlink(realpath($invoiceDocument->getFilename()));
}
/**