Add Response return for UserPreferences::redirect()
Signed-off-by: Maurício Meneghini Fauth <mauricio@mfauth.net>
This commit is contained in:
parent
43ea6900cd
commit
4c789727e9
@ -61,9 +61,8 @@ final readonly class ExportController implements InvocableController
|
||||
// reload config
|
||||
$this->config->loadUserPreferences($this->themeManager);
|
||||
$hash = ltrim($request->getParsedBodyParamAsString('tab_hash'), '#');
|
||||
$this->userPreferences->redirect('index.php?route=/preferences/export', null, $hash);
|
||||
|
||||
return $this->response->response();
|
||||
return $this->userPreferences->redirect('index.php?route=/preferences/export', null, $hash);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -61,9 +61,8 @@ final readonly class FeaturesController implements InvocableController
|
||||
// reload config
|
||||
$this->config->loadUserPreferences($this->themeManager);
|
||||
$hash = ltrim($request->getParsedBodyParamAsString('tab_hash'), '#');
|
||||
$this->userPreferences->redirect('index.php?route=/preferences/features', null, $hash);
|
||||
|
||||
return $this->response->response();
|
||||
return $this->userPreferences->redirect('index.php?route=/preferences/features', null, $hash);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -61,9 +61,8 @@ final readonly class ImportController implements InvocableController
|
||||
// reload config
|
||||
$this->config->loadUserPreferences($this->themeManager);
|
||||
$hash = ltrim($request->getParsedBodyParamAsString('tab_hash'), '#');
|
||||
$this->userPreferences->redirect('index.php?route=/preferences/import', null, $hash);
|
||||
|
||||
return $this->response->response();
|
||||
return $this->userPreferences->redirect('index.php?route=/preferences/import', null, $hash);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -61,9 +61,8 @@ final readonly class MainPanelController implements InvocableController
|
||||
// reload config
|
||||
$this->config->loadUserPreferences($this->themeManager);
|
||||
$hash = ltrim($request->getParsedBodyParamAsString('tab_hash'), '#');
|
||||
$this->userPreferences->redirect('index.php?route=/preferences/main-panel', null, $hash);
|
||||
|
||||
return $this->response->response();
|
||||
return $this->userPreferences->redirect('index.php?route=/preferences/main-panel', null, $hash);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -219,9 +219,8 @@ final class ManageController implements InvocableController
|
||||
|
||||
// reload config
|
||||
$this->config->loadUserPreferences($this->themeManager);
|
||||
$this->userPreferences->redirect($returnUrl ?? '', $redirectParams);
|
||||
|
||||
return $this->response->response();
|
||||
return $this->userPreferences->redirect($returnUrl ?? '', $redirectParams);
|
||||
}
|
||||
|
||||
$error = $result;
|
||||
@ -230,9 +229,8 @@ final class ManageController implements InvocableController
|
||||
$result = $this->userPreferences->save([]);
|
||||
if ($result === true) {
|
||||
$this->config->removeCookie('pma_lang');
|
||||
$this->userPreferences->redirect('index.php?route=/preferences/manage');
|
||||
|
||||
return $this->response->response();
|
||||
return $this->userPreferences->redirect('index.php?route=/preferences/manage');
|
||||
}
|
||||
|
||||
return $this->response->response();
|
||||
|
||||
@ -61,9 +61,8 @@ final readonly class NavigationController implements InvocableController
|
||||
// reload config
|
||||
$this->config->loadUserPreferences($this->themeManager);
|
||||
$hash = ltrim($request->getParsedBodyParamAsString('tab_hash'), '#');
|
||||
$this->userPreferences->redirect('index.php?route=/preferences/navigation', null, $hash);
|
||||
|
||||
return $this->response->response();
|
||||
return $this->userPreferences->redirect('index.php?route=/preferences/navigation', null, $hash);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -61,9 +61,8 @@ final readonly class SqlController implements InvocableController
|
||||
// reload config
|
||||
$this->config->loadUserPreferences($this->themeManager);
|
||||
$hash = ltrim($request->getParsedBodyParamAsString('tab_hash'), '#');
|
||||
$this->userPreferences->redirect('index.php?route=/preferences/sql', null, $hash);
|
||||
|
||||
return $this->response->response();
|
||||
return $this->userPreferences->redirect('index.php?route=/preferences/sql', null, $hash);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -9,6 +9,7 @@ use PhpMyAdmin\Config\Forms\User\UserFormList;
|
||||
use PhpMyAdmin\ConfigStorage\Relation;
|
||||
use PhpMyAdmin\Dbal\ConnectionType;
|
||||
use PhpMyAdmin\Dbal\DatabaseInterface;
|
||||
use PhpMyAdmin\Http\Response;
|
||||
use PhpMyAdmin\Identifiers\DatabaseName;
|
||||
|
||||
use function __;
|
||||
@ -259,7 +260,7 @@ class UserPreferences
|
||||
string $fileName,
|
||||
array|null $params = null,
|
||||
string|null $hash = null,
|
||||
): void {
|
||||
): Response {
|
||||
// redirect
|
||||
$urlParams = ['saved' => 1];
|
||||
if (is_array($params)) {
|
||||
@ -270,9 +271,12 @@ class UserPreferences
|
||||
$hash = '#' . urlencode($hash);
|
||||
}
|
||||
|
||||
ResponseRenderer::getInstance()->redirect(
|
||||
$responseRenderer = ResponseRenderer::getInstance();
|
||||
$responseRenderer->redirect(
|
||||
'./' . $fileName . Url::getCommonRaw($urlParams, ! str_contains($fileName, '?') ? '?' : '&') . $hash,
|
||||
);
|
||||
|
||||
return $responseRenderer->response();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -327,13 +327,12 @@ class UserPreferencesTest extends AbstractTestCase
|
||||
|
||||
$dbi = DatabaseInterface::getInstance();
|
||||
$userPreferences = new UserPreferences($dbi, new Relation($dbi), new Template());
|
||||
$userPreferences->redirect(
|
||||
$response = $userPreferences->redirect(
|
||||
'file.html',
|
||||
['a' => 'b'],
|
||||
'h ash',
|
||||
);
|
||||
|
||||
$response = $responseStub->getResponse();
|
||||
self::assertSame(['/phpmyadmin/file.html?a=b&saved=1&server=2#h+ash'], $response->getHeader('Location'));
|
||||
self::assertSame(302, $response->getStatusCode());
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user