Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 34 additions & 34 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,42 +46,42 @@
"scienta/doctrine-json-functions": "^6",
"siriusphp/upload": "^4.0",
"squirrelphp/twig-php-syntax": "^1.6",
"symfony/asset": "^6.4",
"symfony/cache": "^6.4",
"symfony/console": "^6.4",
"symfony/debug-bundle": "^6.4",
"symfony/dependency-injection": "^6.4",
"symfony/dotenv": "^6.4",
"symfony/error-handler": "^6.4",
"symfony/event-dispatcher": "^6.4",
"symfony/expression-language": "^6.4",
"symfony/asset": "^7.0",
"symfony/cache": "^7.0",
"symfony/console": "^7.0",
"symfony/debug-bundle": "^7.0",
"symfony/dependency-injection": "^7.0",
"symfony/dotenv": "^7.0",
"symfony/error-handler": "^7.0",
"symfony/event-dispatcher": "^7.0",
"symfony/expression-language": "^7.0",
"symfony/flex": "^2.0",
"symfony/form": "^6.4",
"symfony/framework-bundle": "^6.4",
"symfony/http-client": "^6.4",
"symfony/mailer": "^6.4",
"symfony/mime": "^6.4",
"symfony/monolog-bridge": "^6.4",
"symfony/form": "^7.0",
"symfony/framework-bundle": "^7.0",
"symfony/http-client": "^7.0",
"symfony/mailer": "^7.0",
"symfony/mime": "^7.0",
"symfony/monolog-bridge": "^7.0",
"symfony/monolog-bundle": "^3.7",
"symfony/password-hasher": "^6.4",
"symfony/password-hasher": "^7.0",
"symfony/polyfill-php72": "^1.23",
"symfony/polyfill-php84": "^1.31",
"symfony/rate-limiter": "^6.4",
"symfony/runtime": "^6.4",
"symfony/security-bundle": "^6.4",
"symfony/security-csrf": "^6.4",
"symfony/serializer": "^6.4",
"symfony/stopwatch": "^6.4",
"symfony/string": "^6.4",
"symfony/translation": "^6.4",
"symfony/twig-bridge": "^6.4",
"symfony/twig-bundle": "^6.4",
"symfony/validator": "^6.4",
"symfony/var-dumper": "^6.4",
"symfony/var-exporter": "^6.4",
"symfony/web-profiler-bundle": "^6.4",
"symfony/rate-limiter": "^7.0",
"symfony/runtime": "^7.0",
"symfony/security-bundle": "^7.0",
"symfony/security-csrf": "^7.0",
"symfony/serializer": "^7.0",
"symfony/stopwatch": "^7.0",
"symfony/string": "^7.0",
"symfony/translation": "^7.0",
"symfony/twig-bridge": "^7.0",
"symfony/twig-bundle": "^7.0",
"symfony/validator": "^7.0",
"symfony/var-dumper": "^7.0",
"symfony/var-exporter": "^7.0",
"symfony/web-profiler-bundle": "^7.0",
"symfony/webpack-encore-bundle": "^2.2",
"symfony/yaml": "^6.4",
"symfony/yaml": "^7.0",
"symfonycasts/reset-password-bundle": "^1.9",
"twig/extra-bundle": "^3.3",
"twig/html-extra": "^3.3",
Expand Down Expand Up @@ -122,8 +122,8 @@
"phpstan/phpstan-symfony": "2.0.9",
"phpunit/phpunit": "^11.5",
"rector/rector": "2.2.11",
"symfony/browser-kit": "^6.4",
"symfony/css-selector": "^6.4",
"symfony/browser-kit": "^7.0",
"symfony/css-selector": "^7.0",
"symplify/easy-coding-standard": "13.2.3"
},
"config": {
Expand All @@ -147,7 +147,7 @@
"public-dir": "public",
"symfony": {
"allow-contrib": true,
"require": "^6.4"
"require": "^7.0"
}
},
"autoload": {
Expand Down
8 changes: 4 additions & 4 deletions src/Controller/Backend/Async/SelectOptionsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@
#[Route(path: '/select-options', name: 'bolt_async_select_options', methods: [Request::METHOD_GET])]
public function handleSelectOptions(Request $request): JsonResponse
{
[$contentTypeSlug, $format] = explode('/', (string) $request->get('values'));
[$contentTypeSlug, $format] = explode('/', (string) $request->query->get('values'));

if (empty($maxAmount = $request->get('limit'))) {
if (empty($maxAmount = $request->query->get('limit'))) {
$maxAmount = $this->config->get('general/maximum_listing_select', 200);
}

$order = $request->get('order');
$order = $request->query->get('order');

$options = [];

Expand All @@ -56,7 +56,7 @@
'order' => $order,
];

$field = $this->fieldExtension->fieldFactory($request->get('name'));
$field = $this->fieldExtension->fieldFactory($request->query->get('name'));

Check failure on line 59 in src/Controller/Backend/Async/SelectOptionsController.php

View workflow job for this annotation

GitHub Actions / PHPStan - PHP 8.3

Parameter #1 $name of method Bolt\Twig\FieldExtension::fieldFactory() expects string, string|null given.

Check failure on line 59 in src/Controller/Backend/Async/SelectOptionsController.php

View workflow job for this annotation

GitHub Actions / PHPStan - PHP 8.4

Parameter #1 $name of method Bolt\Twig\FieldExtension::fieldFactory() expects string, string|null given.

Check failure on line 59 in src/Controller/Backend/Async/SelectOptionsController.php

View workflow job for this annotation

GitHub Actions / PHPStan - PHP 8.2

Parameter #1 $name of method Bolt\Twig\FieldExtension::fieldFactory() expects string, string|null given.

$options = array_merge($options, $this->fieldExtension->selectOptionsHelper($contentTypeSlug, $params, $field, $format));

Expand Down
2 changes: 1 addition & 1 deletion src/Controller/Backend/Async/UploadController.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
], Response::HTTP_FORBIDDEN);
}

$url = $request->get('url', '');
$url = $request->request->get('url', '');

// Make sure the submitting URL is a valid URL
$violations = $validator->validate($url, new Url());
Expand All @@ -78,7 +78,7 @@
// Prevent SSRF: only fetch URLs with an allowed scheme that resolve to
// a public IP address (not a private, reserved or loopback address).
try {
UrlSafetyChecker::assertSafe($url);

Check failure on line 81 in src/Controller/Backend/Async/UploadController.php

View workflow job for this annotation

GitHub Actions / PHPStan - PHP 8.3

Parameter #1 $url of static method Bolt\Utils\UrlSafetyChecker::assertSafe() expects string, bool|float|int|string given.

Check failure on line 81 in src/Controller/Backend/Async/UploadController.php

View workflow job for this annotation

GitHub Actions / PHPStan - PHP 8.4

Parameter #1 $url of static method Bolt\Utils\UrlSafetyChecker::assertSafe() expects string, bool|float|int|string given.

Check failure on line 81 in src/Controller/Backend/Async/UploadController.php

View workflow job for this annotation

GitHub Actions / PHPStan - PHP 8.2

Parameter #1 $url of static method Bolt\Utils\UrlSafetyChecker::assertSafe() expects string, bool|float|int|string given.
} catch (Throwable $e) {
return new JsonResponse([
'error' => [
Expand All @@ -98,7 +98,7 @@
// performed through a client that re-validates the address actually
// connected to on every hop. This prevents SSRF bypasses via HTTP
// redirects or DNS rebinding to a private/reserved/loopback address.
$this->downloadUrlToFile($url, $tmpFile);

Check failure on line 101 in src/Controller/Backend/Async/UploadController.php

View workflow job for this annotation

GitHub Actions / PHPStan - PHP 8.3

Parameter #1 $url of method Bolt\Controller\Backend\Async\UploadController::downloadUrlToFile() expects string, bool|float|int|string given.

Check failure on line 101 in src/Controller/Backend/Async/UploadController.php

View workflow job for this annotation

GitHub Actions / PHPStan - PHP 8.4

Parameter #1 $url of method Bolt\Controller\Backend\Async\UploadController::downloadUrlToFile() expects string, bool|float|int|string given.

Check failure on line 101 in src/Controller/Backend/Async/UploadController.php

View workflow job for this annotation

GitHub Actions / PHPStan - PHP 8.2

Parameter #1 $url of method Bolt\Controller\Backend\Async\UploadController::downloadUrlToFile() expects string, bool|float|int|string given.
} catch (Throwable $e) {
$this->filesystem->remove($tmpFile);

Expand All @@ -111,7 +111,7 @@

$file = new UploadedFile($tmpFile, basename((string) $url));
$bag = new FileBag();
$bag->add([$file]);

Check failure on line 114 in src/Controller/Backend/Async/UploadController.php

View workflow job for this annotation

GitHub Actions / PHPStan - PHP 8.3

Parameter #1 $files of method Symfony\Component\HttpFoundation\FileBag::add() expects array<string, mixed>, array<int, Symfony\Component\HttpFoundation\File\UploadedFile> given.

Check failure on line 114 in src/Controller/Backend/Async/UploadController.php

View workflow job for this annotation

GitHub Actions / PHPStan - PHP 8.4

Parameter #1 $files of method Symfony\Component\HttpFoundation\FileBag::add() expects array<string, mixed>, array<int, Symfony\Component\HttpFoundation\File\UploadedFile> given.

Check failure on line 114 in src/Controller/Backend/Async/UploadController.php

View workflow job for this annotation

GitHub Actions / PHPStan - PHP 8.2

Parameter #1 $files of method Symfony\Component\HttpFoundation\FileBag::add() expects array<string, mixed>, array<int, Symfony\Component\HttpFoundation\File\UploadedFile> given.
$request->files = $bag;

$response = $this->handleUpload($request);
Expand Down Expand Up @@ -161,7 +161,7 @@
], Response::HTTP_FORBIDDEN);
}

$locationName = $request->query->getString('location') ?? 'files';

Check failure on line 164 in src/Controller/Backend/Async/UploadController.php

View workflow job for this annotation

GitHub Actions / PHPStan - PHP 8.3

Expression on left side of ?? is not nullable.

Check failure on line 164 in src/Controller/Backend/Async/UploadController.php

View workflow job for this annotation

GitHub Actions / PHPStan - PHP 8.4

Expression on left side of ?? is not nullable.

Check failure on line 164 in src/Controller/Backend/Async/UploadController.php

View workflow job for this annotation

GitHub Actions / PHPStan - PHP 8.2

Expression on left side of ?? is not nullable.
$this->denyAccessUnlessGranted('managefiles:' . $locationName);

$path = $request->query->getString('path') ?? '';
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/Backend/DashboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function index(Request $request, Query $query): Response

// TODO PERMISSIONS: implement listing that only lists content that the user is allowed to see
$amount = (int) $this->config->get('general/records_per_page', 10);
$page = (int) ($request->get('page') ?? 1);
$page = (int) ($request->query->get('page') ?? 1);
$contentTypes = $this->config->get('contenttypes')->where('show_on_dashboard', true)->keys()->implode(',');
$filter = strip_tags((string) $this->getFromRequest($request, 'filter', ''));

Expand Down
4 changes: 2 additions & 2 deletions src/Controller/Backend/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ public function __construct(
public function users(Request $request, Query $query): Response
{
$order = 'username';
if ($request->get('sortBy')) {
if ($request->query->get('sortBy')) {
$order = $this->getFromRequest($request, 'sortBy');
}

$like = '';
if ($request->get('filter')) {
if ($request->query->get('filter')) {
$like = '%' . $this->getFromRequest($request, 'filter') . '%';
}

Expand Down
2 changes: 1 addition & 1 deletion src/Controller/Backend/UserEditController.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public function status(Request $request, User $user): Response
{
$this->validateCsrf($request, 'useredit');

$newStatus = $request->get('status') ?? UserStatus::DISABLED;
$newStatus = $request->query->get('status', $request->request->get('status')) ?? UserStatus::DISABLED;

$user->setStatus($newStatus);
$this->addFlash('success', 'user.updated_successfully');
Expand Down
12 changes: 11 additions & 1 deletion src/Controller/CsrfTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,17 @@ public function setCsrfTokenManager(CsrfTokenManagerInterface $csrfTokenManager)

protected function validateCsrf(Request $request, string $tokenId): void
{
$token = new CsrfToken($tokenId, $request->get('_csrf_token', $request->get('token')));
$tokenValue = $request->attributes->get(
'_csrf_token',
$request->query->get(
'_csrf_token',
$request->request->get(
'_csrf_token',
$request->attributes->get('token', $request->query->get('token', $request->request->get('token')))
)
)
);
$token = new CsrfToken($tokenId, $tokenValue);

if (! $this->csrfTokenManager->isTokenValid($token)) {
throw new InvalidCsrfTokenException();
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/Frontend/DetailController.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function record(Request $request, $slugOrId, ?string $contentTypeSlug = n
$this->contentHelper->setCanonicalPath($record);

// Check if we're attempting to preview an unpublished Record
if ($record && $this->validateSecret($request->get('secret') ?? '', (string) $record->getId())) {
if ($record && $this->validateSecret($request->query->get('secret', ''), (string) $record->getId())) {
$requirePublished = false;
}

Expand Down
22 changes: 15 additions & 7 deletions src/Controller/TwigAwareController.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ protected function redirectToDefaultLocale(Request $request): ?Response
$params['_locale'] = $this->defaultLocale;
}

return $this->redirectToRoute($request->get('_route'), $params);
return $this->redirectToRoute($request->attributes->get('_route'), $params);
}

private function setTwigLoader(): void
Expand Down Expand Up @@ -246,18 +246,18 @@ public function createPagerParams(Request $request, string $order): array
'returnmultiple' => true,
];

if ($request->get('sortBy')) {
if ($request->query->get('sortBy')) {
$params['order'] = $this->getFromRequest($request, 'sortBy');
} else {
$params['order'] = $order;
}

if ($request->get('filter')) {
$key = $request->get('filterKey', 'anyField');
if ($request->query->get('filter')) {
$key = $request->query->get('filterKey', 'anyField');
$params[$key] = '%' . $this->getFromRequest($request, 'filter') . '%';
}

if ($request->get('taxonomy')) {
if ($request->query->get('taxonomy')) {
$taxonomy = explode('=', (string) $this->getFromRequest($request, 'taxonomy'));
$params[$taxonomy[0]] = $taxonomy[1];
}
Expand All @@ -267,17 +267,25 @@ public function createPagerParams(Request $request, string $order): array

public function getFromRequestRaw(Request $request, string $parameter): string
{
return $request->get($parameter) ?? '';
return $this->getRequestParameter($request, $parameter) ?? '';
}

public function getFromRequest(Request $request, string $parameter, ?string $default = null): ?string
{
$parameter = mb_trim($this->sanitiser->clean($request->get($parameter, '') ?? ''));
$parameter = mb_trim($this->sanitiser->clean($this->getRequestParameter($request, $parameter, '') ?? ''));

// `clean` returns a string, but we want to be able to get `null`.
return empty($parameter) ? $default : $parameter;
}

protected function getRequestParameter(Request $request, string $parameter, mixed $default = null): mixed
{
return $request->attributes->get(
$parameter,
$request->query->get($parameter, $request->request->get($parameter, $default))
);
}

public function getFromRequestArray(Request $request, array $parameters, ?string $default = null): ?string
{
foreach ($parameters as $parameter) {
Expand Down
1 change: 1 addition & 0 deletions src/Event/Subscriber/ExtensionSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public function onKernelController(ControllerEvent $event): void
if ($controller instanceof ExtensionController) {
$controller->injectObjects([
'manager' => $this->objectManager,
'container' => $this->container,
'query' => $this->query,
]);
}
Expand Down
9 changes: 4 additions & 5 deletions src/Extension/ServicesTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ trait ServicesTrait
/** @var EntityManagerInterface */
protected $entityManager;

/** @var ContainerInterface */
protected $container;
protected ?ContainerInterface $servicesContainer = null;

/** @var Query */
protected $query;
Expand All @@ -45,8 +44,8 @@ public function injectObjects(array $objects): void
$this->entityManager = $objects['manager'];
$this->query = $objects['query'];

if (! $this->container && $container = $objects['container'] ?? null) {
$this->container = $container;
if (! $this->servicesContainer && $container = $objects['container'] ?? null) {
$this->servicesContainer = $container;
}
}

Expand Down Expand Up @@ -147,7 +146,7 @@ public function getLogger(): LoggerInterface

public function getContainer(): ContainerInterface
{
return $this->container;
return $this->servicesContainer;
}

public function getQuery(): Query
Expand Down
8 changes: 6 additions & 2 deletions src/Security/LoginFormAuthenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,12 @@ public function authenticate(Request $request): Passport
public function onAuthenticationSuccess(Request $request, TokenInterface $token, string $firewallName): ?Response
{
// @todo: Allow different roles to redirect to different pages on success.
if ($request->get('_target_path', false)) {
$fallback = $request->get('_target_path');
$targetPath = $request->attributes->get(
'_target_path',
$request->query->get('_target_path', $request->request->get('_target_path', false))
);
if ($targetPath) {
$fallback = $targetPath;
} elseif ($this->security->isGranted('dashboard')) {
$fallback = $this->router->generate('bolt_dashboard');
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/Storage/Handler/SelectQueryHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private function createPaginator(?Request $request, Query $query, int $amountPer
if ($page === null) {
// If we don't have $request, we're likely not in a web context.
if ($request) {
$page = (int) $request->get('page', 1);
$page = (int) $request->query->get('page', 1);
} else {
$page = 1;
}
Expand Down
Loading