Skip to content

Commit

Permalink
Merge branch '5.x' into test/image_processor
Browse files Browse the repository at this point in the history
  • Loading branch information
theus77 authored Oct 8, 2023
2 parents 9a7399c + 00d77b8 commit 96b4e43
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
3 changes: 2 additions & 1 deletion EMS/core-bundle/src/Command/Environment/UnpublishCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int
foreach ($this->revisionSearcher->search($this->environment, $search) as $revisions) {
$this->revisionSearcher->lock($revisions, $this->lockUser);
$this->publishService->bulkStart($bulkSize, $this->logger);
$transactionEnvironment = $this->environmentService->clearCache()->giveByName($this->environment->getName());

foreach ($revisions->transaction() as $revision) {
$this->io->progressAdvance();

try {
$this->publishService->bulkUnpublish($revision, $this->environment);
$this->publishService->bulkUnpublish($revision, $transactionEnvironment);
++$this->counter;
} catch (\LogicException $e) {
$this->warnings[$e->getMessage()] = ($this->warnings[$e->getMessage()] ?? 0) + 1;
Expand Down
4 changes: 3 additions & 1 deletion EMS/core-bundle/src/Service/EnvironmentService.php
Original file line number Diff line number Diff line change
Expand Up @@ -331,11 +331,13 @@ public function getUserPublishEnvironments(): Collection
});
}

public function clearCache(): void
public function clearCache(): self
{
$this->environments = [];
$this->notSnapshotEnvironments = [];
$this->environmentsById = [];

return $this;
}

public function updateEnvironment(Environment $environment): void
Expand Down
10 changes: 8 additions & 2 deletions EMS/submission-bundle/src/Handler/HttpHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use EMS\SubmissionBundle\Response\NoHttpRequest;
use EMS\SubmissionBundle\Response\ResponseTransformer;
use EMS\SubmissionBundle\Twig\TwigRenderer;
use Symfony\Component\HttpClient\Exception\RedirectionException;
use Symfony\Contracts\HttpClient\HttpClientInterface;

final class HttpHandler extends AbstractHandler
Expand All @@ -31,8 +32,13 @@ public function handle(HandleRequestInterface $handleRequest): HandleResponseInt
if (null !== $httpRequest->getIgnoreBodyValue() && $body === $httpRequest->getIgnoreBodyValue()) {
$handleResponse = new NoHttpRequest();
} else {
$httpResponse = $this->client->request($httpRequest->getMethod(), $httpRequest->getUrl(), $httpRequest->getHttpOptions());
$httpResponseContent = $httpResponse->getContent(true);
try {
$httpResponse = $this->client->request($httpRequest->getMethod(), $httpRequest->getUrl(), $httpRequest->getHttpOptions());
$httpResponseContent = $httpResponse->getContent(true);
} catch (RedirectionException $exception) {
$httpResponse = $exception->getResponse();
$httpResponseContent = '';
}
$handleResponse = new HttpHandleResponse($httpResponse, $httpResponseContent);
}

Expand Down
1 change: 1 addition & 0 deletions EMS/submission-bundle/src/Request/HttpRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ final class HttpRequest extends AbstractRequest
'headers' => [],
'timeout' => 30,
'query' => [],
'max_redirects' => 20,
];

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public function testInvalidEndpoint(): void
$message = \file_get_contents(__DIR__.'/../fixtures/twig/message_http.twig');

$this->assertEquals(
'{"status":"error","data":"Submission failed, contact your admin. (Invalid endpoint configuration: The option \"test\" does not exist. Defined options are: \"auth_basic\", \"auth_bearer\", \"headers\", \"ignore_body_value\", \"method\", \"query\", \"timeout\", \"url\".)"}',
'{"status":"error","data":"Submission failed, contact your admin. (Invalid endpoint configuration: The option \"test\" does not exist. Defined options are: \"auth_basic\", \"auth_bearer\", \"headers\", \"ignore_body_value\", \"max_redirects\", \"method\", \"query\", \"timeout\", \"url\".)"}',
$this->handle($this->createForm(), $endpoint, $message)->getResponse()
);
}
Expand Down

0 comments on commit 96b4e43

Please sign in to comment.