Merge branch 'master' into turbo

This commit is contained in:
Jan Böhmer 2022-07-24 01:26:22 +02:00
commit 79a1715290
55 changed files with 3699 additions and 3329 deletions

View file

@ -90,7 +90,7 @@ class ShowEventLogCommand extends Command
$total_count = $this->repo->count([]);
$max_page = (int) ceil($total_count / $limit);
if ($page > $max_page) {
if ($page > $max_page && $max_page > 0) {
$io->error("There is no page ${page}! The maximum page is ${max_page}.");
return 1;

View file

@ -25,6 +25,7 @@ namespace App\Entity\Attachments;
use App\Entity\Base\AbstractNamedDBElement;
use App\Validator\Constraints\Selectable;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use function in_array;
use InvalidArgumentException;
use LogicException;
@ -105,6 +106,7 @@ abstract class Attachment extends AbstractNamedDBElement
* @ORM\ManyToOne(targetEntity="AttachmentType", inversedBy="attachments_with_type")
* @ORM\JoinColumn(name="type_id", referencedColumnName="id")
* @Selectable()
* @Assert\NotNull(message="validator.attachment.must_not_be_null")
*/
protected $attachment_type;

View file

@ -87,7 +87,7 @@ abstract class AbstractDBElement implements \JsonSerializable
return $this->id;
}
public function jsonSerialize()
public function jsonSerialize(): array
{
return ['@id' => $this->getID()];
}

View file

@ -113,6 +113,7 @@ class Orderdetail extends AbstractDBElement implements TimeStampableInterface, N
* @var Supplier
* @ORM\ManyToOne(targetEntity="App\Entity\Parts\Supplier", inversedBy="orderdetails")
* @ORM\JoinColumn(name="id_supplier", referencedColumnName="id")
* @Assert\NotNull(message="validator.orderdetail.supplier_must_not_be_null")
*/
protected $supplier;

View file

@ -62,7 +62,7 @@ final class StructuralDBElementIterator extends ArrayIterator implements Recursi
return !empty($element->getSubelements());
}
public function getChildren()
public function getChildren(): StructuralDBElementIterator
{
/** @var AbstractStructuralDBElement $element */
$element = $this->current();

View file

@ -233,7 +233,7 @@ final class TreeViewNode implements JsonSerializable
return $this;
}
public function jsonSerialize()
public function jsonSerialize(): array
{
$ret = [
'text' => $this->text,

View file

@ -63,7 +63,7 @@ final class TreeViewNodeIterator extends ArrayIterator implements RecursiveItera
return !empty($element->getNodes());
}
public function getChildren()
public function getChildren(): TreeViewNodeIterator
{
/** @var TreeViewNode $element */
$element = $this->current();

View file

@ -8,6 +8,9 @@ use Doctrine\DBAL\Driver\AbstractMySQLDriver;
use Doctrine\DBAL\Driver\AbstractSQLiteDriver;
use Doctrine\DBAL\Exception;
use Doctrine\DBAL\Platforms\AbstractMySQLPlatform;
use Doctrine\DBAL\Platforms\MariaDBPlatform;
use Doctrine\DBAL\Platforms\MySQLPlatform;
use Doctrine\DBAL\Platforms\SqlitePlatform;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
use Psr\Log\LoggerInterface;
@ -124,11 +127,11 @@ abstract class AbstractMultiPlatformMigration extends AbstractMigration
*/
public function getDatabaseType(): ?string
{
if ($this->connection->getDriver() instanceof AbstractMySQLDriver) {
if ($this->connection->getDatabasePlatform() instanceof AbstractMySQLPlatform) {
return 'mysql';
}
if ($this->connection->getDriver() instanceof AbstractSQLiteDriver) {
if ($this->connection->getDatabasePlatform() instanceof SqlitePlatform) {
return 'sqlite';
}

View file

@ -45,6 +45,7 @@ namespace App\Services\Attachments;
use App\Entity\Attachments\Attachment;
use InvalidArgumentException;
use Liip\ImagineBundle\Service\FilterService;
use Psr\Log\LoggerInterface;
use RuntimeException;
use function strlen;
use Symfony\Component\Asset\Packages;
@ -59,15 +60,18 @@ class AttachmentURLGenerator
protected $attachmentHelper;
protected $filterService;
protected $logger;
public function __construct(Packages $assets, AttachmentPathResolver $pathResolver,
UrlGeneratorInterface $urlGenerator, AttachmentManager $attachmentHelper,
FilterService $filterService)
FilterService $filterService, LoggerInterface $logger)
{
$this->assets = $assets;
$this->pathResolver = $pathResolver;
$this->urlGenerator = $urlGenerator;
$this->attachmentHelper = $attachmentHelper;
$this->filterService = $filterService;
$this->logger = $logger;
//Determine a normalized path to the public folder (assets are relative to this folder)
$this->public_path = $this->pathResolver->parameterToAbsolutePath('public');
@ -168,8 +172,14 @@ class AttachmentURLGenerator
return $this->assets->getUrl($asset_path);
}
//Otherwise we can serve the relative path via Asset component
return $this->filterService->getUrlOfFilteredImage($asset_path, $filter_name);
try {
//Otherwise we can serve the relative path via Asset component
return $this->filterService->getUrlOfFilteredImage($asset_path, $filter_name);
} catch (\Imagine\Exception\RuntimeException $e) {
//If the filter fails, we can not serve the thumbnail and fall back to the original image and log an warning
$this->logger->warning('Could not open thumbnail for attachment with ID ' . $attachment->getID() . ': ' . $e->getMessage());
return $this->assets->getUrl($asset_path);
}
}
/**