Skip to content
Merged
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
5 changes: 4 additions & 1 deletion src/Bundle/ApplicationLogger/Repository/LogRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,10 @@ private function addPaging(QueryBuilder $queryBuilder, FilterParameter $paramete
private function addSorting(QueryBuilder $queryBuilder, SortFilter $sortFilter): void
{
$queryBuilder
->orderBy($sortFilter->getKey(), $sortFilter->getDirection());
->orderBy(
$this->dbResolver->get()->quoteIdentifier($sortFilter->getKey()),
$sortFilter->getDirection()
);
}

/**
Expand Down
6 changes: 5 additions & 1 deletion src/MappedParameter/Filter/SortFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
namespace Pimcore\Bundle\StudioBackendBundle\MappedParameter\Filter;

use Pimcore\Bundle\GenericDataIndexBundle\Enum\Search\SortDirection;
use function strtolower;

/**
* @internal
Expand Down Expand Up @@ -43,6 +44,9 @@

public function getDirection(): string
{
return $this->direction;
$normalised = strtolower($this->direction);
$direction = SortDirection::tryFrom($normalised) ?? SortDirection::ASC;

Check warning on line 48 in src/MappedParameter/Filter/SortFilter.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/MappedParameter/Filter/SortFilter.php#L48

Avoid using static access to class '\Pimcore\Bundle\GenericDataIndexBundle\Enum\Search\SortDirection' in method 'getDirection'.

return $direction->value;
}
}
19 changes: 17 additions & 2 deletions src/Translation/Repository/TranslationRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@
use Pimcore\Bundle\StudioBackendBundle\Translation\Schema\UpdateTranslation;
use Pimcore\Bundle\StudioBackendBundle\Translation\Service\TranslatorServiceInterface;
use Pimcore\Bundle\StudioBackendBundle\Util\Constant\UserPermissions;
use Pimcore\Config;
use Pimcore\Model\Translation;
use Pimcore\Model\Translation\Listing;
use function array_unique;
use function array_values;
use function in_array;
use function sprintf;

Expand All @@ -41,6 +44,7 @@
private SettingsProviderInterface $systemSettingsProvider,
private Connection $db,
private SecurityServiceInterface $securityService,
private Config $config,
) {
$settings = $this->systemSettingsProvider->getSettings();
$this->validLanguages = $settings['validLanguages'] ?? [];
Expand Down Expand Up @@ -192,10 +196,10 @@

public function getTranslationList(string $domain = TranslatorServiceInterface::DOMAIN): Listing
{
$this->assertValidDomain($domain);

$list = new Translation\Listing();
$list->setDomain($domain);
$list->setOrder('asc');
$list->setOrderKey('translations_' . $domain . '.key', false);

return $list;
}
Expand Down Expand Up @@ -245,4 +249,15 @@
throw new InvalidLocaleException($locale);
}
}

/**
* @throws NotFoundException
*/
private function assertValidDomain(string $domain): void
{
$allowedDomains = array_values(array_unique($this->config['translations']['domains'] ?? []));
if (!in_array($domain, $allowedDomains, true)) {
throw new NotFoundException('Translation Domain', $domain);

Check failure on line 260 in src/Translation/Repository/TranslationRepository.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/Translation/Repository/TranslationRepository.php#L260

All output should be run through an escaping function (see the Security sections in the WordPress Developer Handbooks), found '$domain'.
}
}
}
Loading