Release 2.0.19 (#4022)
* prevent invoices with exceeding filename * fixed invalid LDAP log level * support locale switching in action events
This commit is contained in:
@@ -46,6 +46,7 @@ final class ActionsController extends BaseApiController
|
||||
*/
|
||||
private function convertEvent(PageActionsEvent $event, string $locale): array
|
||||
{
|
||||
$event->setLocale($locale);
|
||||
$this->dispatcher->dispatch($event, $event->getEventName());
|
||||
|
||||
$translator = $this->translator;
|
||||
|
||||
@@ -17,11 +17,11 @@ class Constants
|
||||
/**
|
||||
* The current release version
|
||||
*/
|
||||
public const VERSION = '2.0.18';
|
||||
public const VERSION = '2.0.19';
|
||||
/**
|
||||
* The current release: major * 10000 + minor * 100 + patch
|
||||
*/
|
||||
public const VERSION_ID = 20018;
|
||||
public const VERSION_ID = 20019;
|
||||
/**
|
||||
* The software name
|
||||
*/
|
||||
|
||||
@@ -18,9 +18,10 @@ use App\Entity\User;
|
||||
*/
|
||||
class PageActionsEvent extends ThemeEvent
|
||||
{
|
||||
private $action;
|
||||
private $view;
|
||||
private $divider = 0;
|
||||
private string $action;
|
||||
private string $view;
|
||||
private int $divider = 0;
|
||||
private ?string $locale = null;
|
||||
|
||||
public function __construct(User $user, array $payload, string $action, string $view)
|
||||
{
|
||||
@@ -195,4 +196,14 @@ class PageActionsEvent extends ThemeEvent
|
||||
|
||||
return \count($this->payload['actions']);
|
||||
}
|
||||
|
||||
public function getLocale(): ?string
|
||||
{
|
||||
return $this->locale;
|
||||
}
|
||||
|
||||
public function setLocale(?string $locale): void
|
||||
{
|
||||
$this->locale = $locale;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,8 +52,13 @@ class ThemeEvent extends Event
|
||||
return $this->payload;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since 2.0.19, will be removed with 2.1
|
||||
*/
|
||||
public function setPayload(mixed $payload): void
|
||||
{
|
||||
@trigger_error('ThemeEvent::setPayload() is deprecated, use AbstractActionsSubscriber instead.', E_USER_DEPRECATED);
|
||||
|
||||
$this->payload = $payload;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,8 @@ use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
|
||||
*/
|
||||
abstract class AbstractActionsSubscriber implements EventSubscriberInterface
|
||||
{
|
||||
private ?string $locale = null;
|
||||
|
||||
public function __construct(private AuthorizationCheckerInterface $auth, private UrlGeneratorInterface $urlGenerator)
|
||||
{
|
||||
}
|
||||
@@ -30,16 +32,27 @@ abstract class AbstractActionsSubscriber implements EventSubscriberInterface
|
||||
|
||||
protected function path(string $route, array $parameters = []): string
|
||||
{
|
||||
if ($this->locale !== null) {
|
||||
$parameters['_locale'] = $this->locale;
|
||||
}
|
||||
|
||||
return $this->urlGenerator->generate($route, $parameters);
|
||||
}
|
||||
|
||||
public static function getSubscribedEvents(): array
|
||||
{
|
||||
return [
|
||||
'actions.' . static::getActionName() => ['onActions', 1000],
|
||||
'actions.' . static::getActionName() => ['handleEvent', 1000],
|
||||
];
|
||||
}
|
||||
|
||||
final public function handleEvent(PageActionsEvent $event): void
|
||||
{
|
||||
$this->locale = $event->getLocale();
|
||||
|
||||
$this->onActions($event);
|
||||
}
|
||||
|
||||
public static function getActionName(): string
|
||||
{
|
||||
throw new \Exception('You need to overwrite getActionName() or getSubscribedEvents() in ' . static::class);
|
||||
|
||||
@@ -197,16 +197,22 @@ final class ServiceInvoice
|
||||
if (stripos($part, 'filename=') === false) {
|
||||
continue;
|
||||
}
|
||||
$filename = explode('filename=', $part);
|
||||
if (\count($filename) > 1) {
|
||||
$filename = $filename[1];
|
||||
$tmp = explode('filename=', $part);
|
||||
if (\count($tmp) > 1) {
|
||||
$filename = $tmp[1];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$disposition = $event->getResponse()->headers->get('Content-Type');
|
||||
$parts = explode(';', $disposition);
|
||||
$parts = explode('/', $parts[0]);
|
||||
$filename .= '.' . $parts[1];
|
||||
if (\count($parts) > 1) {
|
||||
$filename .= '.' . $parts[1];
|
||||
}
|
||||
}
|
||||
|
||||
if (mb_strlen($filename) >= 150) {
|
||||
throw new \Exception(sprintf('Invoice filename "%s" is too long, max. 150 characters allowed', $filename));
|
||||
}
|
||||
|
||||
if (is_file($invoiceDirectory . $filename)) {
|
||||
|
||||
@@ -118,6 +118,6 @@ class LdapDriver
|
||||
if (null === $this->logger) {
|
||||
return;
|
||||
}
|
||||
$this->logger->error($message, $context);
|
||||
$this->logger->debug($message, $context);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user