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
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"minimum-stability": "dev",
"require": {
"php": "~8.3.0 || ~8.4.0 ",
"pimcore/pimcore": "^12.x-dev",
"nesbot/carbon": "^3.8.4",
"pimcore/pimcore": "^12.0",
"pimcore/static-resolver-bundle": "^1.4.0 || ^2.0",
"pimcore/opensearch-client": "^1.1",
"pimcore/elasticsearch-client": "^1.1",
Expand Down
9 changes: 6 additions & 3 deletions src/Model/DefaultSearch/Query/DateFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,12 @@ public function __construct(
int|Carbon|null $onTimestamp = null,
private bool $roundToDay = true,
) {
$this->startDate = is_int($startTimestamp) ? Carbon::createFromTimestamp($startTimestamp) : $startTimestamp;
$this->endDate = is_int($endTimestamp) ? Carbon::createFromTimestamp($endTimestamp) : $endTimestamp;
$this->onDate = is_int($onTimestamp) ? Carbon::createFromTimestamp($onTimestamp) : $onTimestamp;
$this->startDate = is_int($startTimestamp) ?
Carbon::createFromTimestamp($startTimestamp, date_default_timezone_get()) : $startTimestamp;
$this->endDate = is_int($endTimestamp) ?
Carbon::createFromTimestamp($endTimestamp, date_default_timezone_get()) : $endTimestamp;
$this->onDate = is_int($onTimestamp) ?
Carbon::createFromTimestamp($onTimestamp, date_default_timezone_get()) : $onTimestamp;
}

public static function createFromArray(string $field, array $params, bool $roundToDay = true): DateFilter
Expand Down
8 changes: 5 additions & 3 deletions src/Model/Search/Modifier/Filter/FieldType/DateFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ public function __construct(
private bool $roundToDay = true,
private bool $enablePqlFieldNameResolution = true,
) {
$this->startDate = is_int($startDate) ? Carbon::createFromTimestamp($startDate) : $startDate;
$this->endDate = is_int($endDate) ? Carbon::createFromTimestamp($endDate) : $endDate;
$this->onDate = is_int($onDate) ? Carbon::createFromTimestamp($onDate) : $onDate;
$this->startDate = is_int($startDate) ? Carbon::createFromTimestamp($startDate, date_default_timezone_get()) :
$startDate;
$this->endDate = is_int($endDate) ? Carbon::createFromTimestamp($endDate, date_default_timezone_get()) :
$endDate;
$this->onDate = is_int($onDate) ? Carbon::createFromTimestamp($onDate, date_default_timezone_get()) : $onDate;
}

public function getStartDate(): ?Carbon
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function getIndexMapping(): array
public function normalize(mixed $value): ?string
{
if (!empty($value)) {
return Carbon::createFromTimestamp($value)->format(DateTimeInterface::ATOM);
return Carbon::createFromTimestamp($value, date_default_timezone_get())->format(DateTimeInterface::ATOM);
}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
use Codeception\Test\Unit;
use Pimcore\Bundle\GenericDataIndexBundle\SearchIndexAdapter\SearchIndexServiceInterface;
use Pimcore\Bundle\GenericDataIndexBundle\Service\SearchIndex\CachedSearchIndexMappingService;
use Pimcore\Bundle\StaticResolverBundle\Lib\Cache\RuntimeCacheResolverInterface;
use Pimcore\Bundle\StaticResolverBundle\Contract\Lib\Cache\RuntimeCacheResolverContract;

/**
* @internal
Expand All @@ -30,37 +30,13 @@ final class CachedSearchIndexMappingServiceTest extends Unit

public function _before(): void
{
$runtimeCacheResolver = new class implements RuntimeCacheResolverInterface {
private ?array $cacheEntry = null;

public function load(string $id): mixed
{
return $this->cacheEntry;
}

public function save(mixed $data, string $id): void
{
$this->cacheEntry = $data;
}

public function isRegistered(string $index): bool
{
return is_array($this->cacheEntry);
}

public function clear(array $keepItems = []): void
{
$this->cacheEntry = null;
}
};

$searchIndexServiceMock = $this->createMock(SearchIndexServiceInterface::class);
$searchIndexServiceMock->method('getMapping')->willReturnCallback(function (string $indexName) {
return [$indexName . 'df' . uniqid('', true)];
});

$this->cachedSearchIndexMappingService = new CachedSearchIndexMappingService(
$runtimeCacheResolver,
new RuntimeCacheResolverContract(),
$searchIndexServiceMock
);
}
Expand Down