Skip to content

Commit

Permalink
Remove ResponseRenderer::disable from Setup\ShowConfigController
Browse files Browse the repository at this point in the history
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
  • Loading branch information
MauricioFauth committed May 11, 2024
1 parent de7572b commit c7963ea
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 20 deletions.
2 changes: 1 addition & 1 deletion app/services_controllers.php
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,7 @@
],
Setup\ShowConfigController::class => [
'class' => Setup\ShowConfigController::class,
'arguments' => ['@' . ResponseFactory::class, '@response', '@template', '@config'],
'arguments' => ['@' . ResponseFactory::class, '@template', '@config'],
],
Setup\ValidateController::class => [
'class' => Setup\ValidateController::class,
Expand Down
25 changes: 6 additions & 19 deletions src/Controllers/Setup/ShowConfigController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use PhpMyAdmin\Http\Response;
use PhpMyAdmin\Http\ServerRequest;
use PhpMyAdmin\LanguageManager;
use PhpMyAdmin\ResponseRenderer;
use PhpMyAdmin\Setup\ConfigGenerator;
use PhpMyAdmin\Setup\SetupHelper;
use PhpMyAdmin\Template;
Expand All @@ -29,7 +28,6 @@ final class ShowConfigController implements InvocableController
{
public function __construct(
private readonly ResponseFactory $responseFactory,
private readonly ResponseRenderer $responseRenderer,
private readonly Template $template,
private readonly Config $config,
) {
Expand All @@ -52,8 +50,6 @@ public function __invoke(ServerRequest $request): Response
$formDisplay = new ConfigForm($configFile);
$formDisplay->save(['Config']);

$this->responseRenderer->disable();

/** @var mixed $eol */
$eol = $request->getParsedBodyParam('eol');
if ($eol !== null) {
Expand All @@ -65,34 +61,25 @@ public function __invoke(ServerRequest $request): Response
if (is_string($submitClear) && $submitClear !== '') {
// Clear current config and return to main page
$configFile->resetConfigData();
// drop post data
$this->responseRenderer->addHeader(
'Location',
'../setup/index.php' . Url::getCommonRaw(['route' => '/setup']),
);
$this->responseRenderer->setStatusCode(StatusCodeInterface::STATUS_SEE_OTHER);

return $this->responseRenderer->response();

return $this->responseFactory->createResponse(StatusCodeInterface::STATUS_FOUND)
->withHeader('Location', '../setup/index.php' . Url::getCommonRaw(['route' => '/setup']));
}

/** @var mixed $submitDownload */
$submitDownload = $request->getParsedBodyParam('submit_download');
if (is_string($submitDownload) && $submitDownload !== '') {
$response = $this->responseFactory->createResponse();
// Output generated config file
Core::downloadHeader('config.inc.php', 'text/plain');
$this->responseRenderer->disable();
echo ConfigGenerator::getConfigFile($configFile);

return $this->responseRenderer->response();
return $response->write(ConfigGenerator::getConfigFile($configFile));
}

// Show generated config file in a <textarea>
$this->responseRenderer->addHeader(
return $this->responseFactory->createResponse(StatusCodeInterface::STATUS_FOUND)->withHeader(
'Location',
'../setup/index.php' . Url::getCommonRaw(['route' => '/setup', 'page' => 'config']),
);
$this->responseRenderer->setStatusCode(StatusCodeInterface::STATUS_SEE_OTHER);

return $this->responseRenderer->response();
}
}

0 comments on commit c7963ea

Please sign in to comment.