Skip to content

Commit d02629d

Browse files
committed
Merge remote-tracking branch 'origin/2025.4' into 2026.1
2 parents d6e51ca + 798fe7f commit d02629d

7 files changed

Lines changed: 47 additions & 10 deletions

File tree

src/Bundle/ApplicationLogger/Repository/LogRepository.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,10 @@ private function addPaging(QueryBuilder $queryBuilder, FilterParameter $paramete
198198
private function addSorting(QueryBuilder $queryBuilder, SortFilter $sortFilter): void
199199
{
200200
$queryBuilder
201-
->orderBy($sortFilter->getKey(), $sortFilter->getDirection());
201+
->orderBy(
202+
$this->dbResolver->get()->quoteIdentifier($sortFilter->getKey()),
203+
$sortFilter->getDirection()
204+
);
202205
}
203206

204207
/**

src/Class/Service/LayoutService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ private function getPreviewObject(TextLayoutPreviewParameters $parameters): ?Con
126126
}
127127

128128
$this->classDefinitionRepository->getClassDefinition($parameters->getClassName());
129-
$className = '\\Pimcore\\Model\\DataObject\\' . $parameters->getClassName();
129+
$className = '\\Pimcore\\Model\\DataObject\\' . ucfirst($parameters->getClassName());
130130

131131
return new $className();
132132
}

src/DataIndex/Grid/GridSearch.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ public function searchElementsForUser(
112112
GridParameter $gridParameter,
113113
UserInterface $user
114114
): AssetSearchResult|DataObjectSearchResult|DocumentSearchResult {
115+
$type = $this->getStudioElementType($type);
115116
/** @var AssetQueryInterface|DataObjectQueryInterface|DocumentQueryInterface $query */
116117
$query = $this->getSearchQuery($type, $gridParameter, $user);
117118

@@ -131,6 +132,7 @@ public function searchElementIdsForUser(
131132
GridParameter $gridParameter,
132133
UserInterface $user
133134
): array {
135+
$type = $this->getStudioElementType($type);
134136
/** @var AssetQueryInterface|DataObjectQueryInterface $query */
135137
$query = $this->getSearchQuery($type, $gridParameter, $user);
136138

@@ -147,7 +149,6 @@ private function getSearchQuery(
147149
UserInterface $user
148150
): QueryInterface {
149151
$filter = $gridParameter->getFilters();
150-
$type = $this->getStudioElementType($type);
151152
$filter = $this->setFilterPath($filter, $type, $gridParameter->getFolderId(), $user);
152153

153154
$query = $this->queryFactory->create($type);

src/MappedParameter/Filter/SortFilter.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
namespace Pimcore\Bundle\StudioBackendBundle\MappedParameter\Filter;
1515

1616
use Pimcore\Bundle\GenericDataIndexBundle\Enum\Search\SortDirection;
17+
use function strtolower;
1718

1819
/**
1920
* @internal
@@ -43,6 +44,9 @@ public function getKeyWithOutLocale(): string
4344

4445
public function getDirection(): string
4546
{
46-
return $this->direction;
47+
$normalised = strtolower($this->direction);
48+
$direction = SortDirection::tryFrom($normalised) ?? SortDirection::ASC;
49+
50+
return $direction->value;
4751
}
4852
}

src/Tag/Controller/CollectionController.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\DefaultResponses;
2626
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\SuccessResponse;
2727
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags;
28+
use Pimcore\Bundle\StudioBackendBundle\Security\PermissionsToCheck;
2829
use Pimcore\Bundle\StudioBackendBundle\Tag\MappedParameter\TagsParameters;
2930
use Pimcore\Bundle\StudioBackendBundle\Tag\Schema\Tag;
3031
use Pimcore\Bundle\StudioBackendBundle\Tag\Service\TagServiceInterface;
@@ -34,7 +35,6 @@
3435
use Symfony\Component\HttpFoundation\JsonResponse;
3536
use Symfony\Component\HttpKernel\Attribute\MapQueryString;
3637
use Symfony\Component\Routing\Attribute\Route;
37-
use Symfony\Component\Security\Http\Attribute\IsGranted;
3838
use Symfony\Component\Serializer\SerializerInterface;
3939

4040
/**
@@ -55,7 +55,6 @@ public function __construct(
5555
* @throws InvalidQueryTypeException
5656
*/
5757
#[Route('/tags', name: 'pimcore_studio_api_tags', methods: ['GET'])]
58-
#[IsGranted(UserPermissions::TAGS_CONFIGURATION->value)]
5958
#[Get(
6059
path: self::PREFIX . '/tags',
6160
operationId: 'tag_get_collection',
@@ -81,6 +80,14 @@ public function __construct(
8180
public function getTags(
8281
#[MapQueryString] TagsParameters $parameters): JsonResponse
8382
{
83+
$this->denyAccessUnlessGranted(
84+
'HasOneOf',
85+
new PermissionsToCheck([
86+
UserPermissions::TAGS_CONFIGURATION->value,
87+
UserPermissions::TAGS_SEARCH->value,
88+
])
89+
);
90+
8491
return $this->jsonResponse(['items' => $this->tagService->listTags($parameters)]);
8592
}
8693
}

src/Tag/Controller/GetController.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@
2020
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\DefaultResponses;
2121
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Response\SuccessResponse;
2222
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags;
23+
use Pimcore\Bundle\StudioBackendBundle\Security\PermissionsToCheck;
2324
use Pimcore\Bundle\StudioBackendBundle\Tag\Schema\Tag;
2425
use Pimcore\Bundle\StudioBackendBundle\Tag\Service\TagServiceInterface;
2526
use Pimcore\Bundle\StudioBackendBundle\Util\Constant\HttpResponseCodes;
2627
use Pimcore\Bundle\StudioBackendBundle\Util\Constant\UserPermissions;
2728
use Symfony\Component\HttpFoundation\JsonResponse;
2829
use Symfony\Component\Routing\Attribute\Route;
29-
use Symfony\Component\Security\Http\Attribute\IsGranted;
3030
use Symfony\Component\Serializer\SerializerInterface;
3131

3232
/**
@@ -42,7 +42,6 @@ public function __construct(
4242
}
4343

4444
#[Route('/tags/{id}', name: 'pimcore_studio_api_get_tag', methods: ['GET'])]
45-
#[IsGranted(UserPermissions::TAGS_CONFIGURATION->value)]
4645
#[Get(
4746
path: self::PREFIX . '/tags/{id}',
4847
operationId: 'tag_get_by_id',
@@ -61,6 +60,14 @@ public function __construct(
6160
])]
6261
public function getTags(int $id): JsonResponse
6362
{
63+
$this->denyAccessUnlessGranted(
64+
'HasOneOf',
65+
new PermissionsToCheck([
66+
UserPermissions::TAGS_CONFIGURATION->value,
67+
UserPermissions::TAGS_SEARCH->value,
68+
])
69+
);
70+
6471
return $this->jsonResponse($this->tagService->getTag($id));
6572
}
6673
}

src/Translation/Repository/TranslationRepository.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,11 @@
2525
use Pimcore\Bundle\StudioBackendBundle\Translation\Schema\UpdateTranslation;
2626
use Pimcore\Bundle\StudioBackendBundle\Translation\Service\TranslatorServiceInterface;
2727
use Pimcore\Bundle\StudioBackendBundle\Util\Constant\UserPermissions;
28+
use Pimcore\Config;
2829
use Pimcore\Model\Translation;
2930
use Pimcore\Model\Translation\Listing;
31+
use function array_unique;
32+
use function array_values;
3033
use function in_array;
3134
use function sprintf;
3235

@@ -41,6 +44,7 @@ public function __construct(
4144
private SettingsProviderInterface $systemSettingsProvider,
4245
private Connection $db,
4346
private SecurityServiceInterface $securityService,
47+
private Config $config,
4448
) {
4549
$settings = $this->systemSettingsProvider->getSettings();
4650
$this->validLanguages = $settings['validLanguages'] ?? [];
@@ -192,10 +196,10 @@ public function getTranslationKeysWithTextFilter(
192196

193197
public function getTranslationList(string $domain = TranslatorServiceInterface::DOMAIN): Listing
194198
{
199+
$this->assertValidDomain($domain);
200+
195201
$list = new Translation\Listing();
196202
$list->setDomain($domain);
197-
$list->setOrder('asc');
198-
$list->setOrderKey('translations_' . $domain . '.key', false);
199203

200204
return $list;
201205
}
@@ -245,4 +249,15 @@ private function validateLocale(string $locale): void
245249
throw new InvalidLocaleException($locale);
246250
}
247251
}
252+
253+
/**
254+
* @throws NotFoundException
255+
*/
256+
private function assertValidDomain(string $domain): void
257+
{
258+
$allowedDomains = array_values(array_unique($this->config['translations']['domains'] ?? []));
259+
if (!in_array($domain, $allowedDomains, true)) {
260+
throw new NotFoundException('Translation Domain', $domain);
261+
}
262+
}
248263
}

0 commit comments

Comments
 (0)