From 729b23ec44bb72bb0b36f76a605cd6bded2ad263 Mon Sep 17 00:00:00 2001 From: Joossensei Date: Fri, 26 Nov 2021 12:37:06 +0100 Subject: [PATCH 1/2] Fix the date format expected for params like 'today' --- src/Storage/SelectQuery.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Storage/SelectQuery.php b/src/Storage/SelectQuery.php index 1d51b1087..fb97c97f0 100644 --- a/src/Storage/SelectQuery.php +++ b/src/Storage/SelectQuery.php @@ -10,6 +10,7 @@ use Bolt\Entity\Field\CheckboxField; use Bolt\Entity\Field\NumberField; use Bolt\Entity\Field\SelectField; +use Carbon\Carbon; use Doctrine\ORM\EntityManagerInterface; use Doctrine\ORM\Query\Expr\Andx; use Doctrine\ORM\Query\Expr\Base; @@ -329,7 +330,7 @@ public function build(): QueryBuilder $fieldName = preg_replace('/(_[0-9]+)$/', '', $key); // Use strtotime on 'date' fields to allow selections like "today", "in 3 weeks" or "this year" if (in_array($fieldName, $dateFields, true) && (strtotime($param) !== false)) { - $param = date('c', strtotime($param)); + $param = Carbon::parse(strtotime($param))->toIso8601ZuluString('milisecond'); } if (in_array($fieldName, $this->regularFields, true) && ! in_array($fieldName, $numberFields, true)) { From d0a43ea1ced7467a4bee6995c470bfa88ab7c0ce Mon Sep 17 00:00:00 2001 From: Joossensei Date: Fri, 26 Nov 2021 13:18:42 +0100 Subject: [PATCH 2/2] Fix the phpstan :smile: --- src/Storage/SelectQuery.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Storage/SelectQuery.php b/src/Storage/SelectQuery.php index fb97c97f0..897655537 100644 --- a/src/Storage/SelectQuery.php +++ b/src/Storage/SelectQuery.php @@ -330,7 +330,7 @@ public function build(): QueryBuilder $fieldName = preg_replace('/(_[0-9]+)$/', '', $key); // Use strtotime on 'date' fields to allow selections like "today", "in 3 weeks" or "this year" if (in_array($fieldName, $dateFields, true) && (strtotime($param) !== false)) { - $param = Carbon::parse(strtotime($param))->toIso8601ZuluString('milisecond'); + $param = Carbon::parse((string) strtotime($param))->toIso8601ZuluString('milisecond'); } if (in_array($fieldName, $this->regularFields, true) && ! in_array($fieldName, $numberFields, true)) {