diff --git a/vendor/magento/module-catalog/Ui/Component/Listing/Columns.php b/vendor/magento/module-catalog/Ui/Component/Listing/Columns.php index 88edfc7b36cb6..5f56cf8d6e377 100644 --- a/vendor/magento/module-catalog/Ui/Component/Listing/Columns.php +++ b/vendor/magento/module-catalog/Ui/Component/Listing/Columns.php @@ -16,7 +16,7 @@ class Columns extends \Magento\Ui\Component\Listing\Columns /** * Default columns max order value */ - const DEFAULT_COLUMNS_MAX_ORDER = 100; + public const DEFAULT_COLUMNS_MAX_ORDER = 100; /** * @var \Magento\Catalog\Ui\Component\Listing\Attribute\RepositoryInterface @@ -71,6 +71,7 @@ public function prepare() $config['sortOrder'] = ++$columnSortOrder; if ($attribute->getIsFilterableInGrid()) { $config['filter'] = $this->getFilterType($attribute->getFrontendInput()); + $config['userDefined'] = $attribute->getIsUserDefined(); } $column = $this->columnFactory->create($attribute, $this->getContext(), $config); $column->prepare(); diff --git a/vendor/magento/module-cms/Model/ResourceModel/Block/Grid/Collection.php b/vendor/magento/module-cms/Model/ResourceModel/Block/Grid/Collection.php index 03369c0fd0565..6180cc58950ad 100644 --- a/vendor/magento/module-cms/Model/ResourceModel/Block/Grid/Collection.php +++ b/vendor/magento/module-cms/Model/ResourceModel/Block/Grid/Collection.php @@ -8,14 +8,12 @@ use Magento\Framework\Api\Search\SearchResultInterface; use Magento\Framework\Api\Search\AggregationInterface; use Magento\Cms\Model\ResourceModel\Block\Collection as BlockCollection; -use Magento\Framework\App\ObjectManager; use Magento\Framework\Data\Collection\Db\FetchStrategyInterface; use Magento\Framework\Data\Collection\EntityFactoryInterface; use Magento\Framework\DB\Adapter\AdapterInterface; use Magento\Framework\EntityManager\MetadataPool; use Magento\Framework\Event\ManagerInterface; use Magento\Framework\Model\ResourceModel\Db\AbstractDb; -use Magento\Framework\Stdlib\DateTime\TimezoneInterface; use Magento\Store\Model\StoreManagerInterface; use Psr\Log\LoggerInterface; @@ -24,11 +22,6 @@ */ class Collection extends BlockCollection implements SearchResultInterface { - /** - * @var TimezoneInterface - */ - private $timeZone; - /** * @var AggregationInterface */ @@ -54,7 +47,6 @@ class Collection extends BlockCollection implements SearchResultInterface * @param string $model * @param AdapterInterface|string|null $connection * @param AbstractDb $resource - * @param TimezoneInterface|null $timeZone * * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ @@ -71,8 +63,7 @@ public function __construct( $resourceModel, $model = \Magento\Framework\View\Element\UiComponent\DataProvider\Document::class, $connection = null, - ?AbstractDb $resource = null, - ?TimezoneInterface $timeZone = null + ?AbstractDb $resource = null ) { $this->resourceModel = $resourceModel; $this->model = $model; @@ -90,7 +81,6 @@ public function __construct( $this->_eventObject = $eventObject; $this->_init($this->model, $this->resourceModel); $this->setMainTable($mainTable); - $this->timeZone = $timeZone ?: ObjectManager::getInstance()->get(TimezoneInterface::class); } /** @@ -102,22 +92,6 @@ public function _resetState(): void $this->_init($this->model, $this->resourceModel); } - /** - * @inheritDoc - */ - public function addFieldToFilter($field, $condition = null) - { - if ($field === 'creation_time' || $field === 'update_time') { - if (is_array($condition)) { - foreach ($condition as $key => $value) { - $condition[$key] = $this->timeZone->convertConfigTimeToUtc($value); - } - } - } - - return parent::addFieldToFilter($field, $condition); - } - /** * Get aggregation interface instance * diff --git a/vendor/magento/module-cms/Model/ResourceModel/Page/Grid/Collection.php b/vendor/magento/module-cms/Model/ResourceModel/Page/Grid/Collection.php index b2a4e315ad8d8..1dde3b8564a23 100644 --- a/vendor/magento/module-cms/Model/ResourceModel/Page/Grid/Collection.php +++ b/vendor/magento/module-cms/Model/ResourceModel/Page/Grid/Collection.php @@ -8,13 +8,11 @@ use Magento\Framework\Api\Search\SearchResultInterface; use Magento\Framework\Api\Search\AggregationInterface; use Magento\Cms\Model\ResourceModel\Page\Collection as PageCollection; -use Magento\Framework\App\ObjectManager; use Magento\Framework\Data\Collection\Db\FetchStrategyInterface; use Magento\Framework\Data\Collection\EntityFactoryInterface; use Magento\Framework\EntityManager\MetadataPool; use Magento\Framework\Event\ManagerInterface; use Magento\Framework\Model\ResourceModel\Db\AbstractDb; -use Magento\Framework\Stdlib\DateTime\TimezoneInterface; use Magento\Store\Model\StoreManagerInterface; use Psr\Log\LoggerInterface; @@ -24,11 +22,6 @@ */ class Collection extends PageCollection implements SearchResultInterface { - /** - * @var TimezoneInterface - */ - private $timeZone; - /** * @var AggregationInterface */ @@ -54,7 +47,6 @@ class Collection extends PageCollection implements SearchResultInterface * @param string $model * @param mixed|null $connection * @param AbstractDb|null $resource - * @param TimezoneInterface|null $timeZone * * @SuppressWarnings(PHPMD.ExcessiveParameterList) */ @@ -71,8 +63,7 @@ public function __construct( $resourceModel, $model = \Magento\Framework\View\Element\UiComponent\DataProvider\Document::class, $connection = null, - ?AbstractDb $resource = null, - ?TimezoneInterface $timeZone = null + ?AbstractDb $resource = null ) { $this->resourceModel = $resourceModel; $this->model = $model; @@ -90,7 +81,6 @@ public function __construct( $this->_eventObject = $eventObject; $this->_init($this->model, $this->resourceModel); $this->setMainTable($mainTable); - $this->timeZone = $timeZone ?: ObjectManager::getInstance()->get(TimezoneInterface::class); } /** @@ -102,22 +92,6 @@ public function _resetState(): void $this->_init($this->model, $this->resourceModel); } - /** - * @inheritDoc - */ - public function addFieldToFilter($field, $condition = null) - { - if ($field === 'creation_time' || $field === 'update_time') { - if (is_array($condition)) { - foreach ($condition as $key => $value) { - $condition[$key] = $this->timeZone->convertConfigTimeToUtc($value); - } - } - } - - return parent::addFieldToFilter($field, $condition); - } - /** * Get aggregation interface instance * diff --git a/vendor/magento/module-customer/Model/ResourceModel/Grid/Collection.php b/vendor/magento/module-customer/Model/ResourceModel/Grid/Collection.php index 2c271f90bfa16..e1060f2c38cd2 100644 --- a/vendor/magento/module-customer/Model/ResourceModel/Grid/Collection.php +++ b/vendor/magento/module-customer/Model/ResourceModel/Grid/Collection.php @@ -1,18 +1,17 @@ ['entity_id' => 'main_table.entity_id']]; @@ -49,7 +43,7 @@ class Collection extends SearchResult * @param ResolverInterface $localeResolver * @param string $mainTable * @param string $resourceModel - * @param TimezoneInterface|null $timeZone + * @throws LocalizedException */ public function __construct( EntityFactory $entityFactory, @@ -58,13 +52,10 @@ public function __construct( EventManager $eventManager, ResolverInterface $localeResolver, $mainTable = 'customer_grid_flat', - $resourceModel = Customer::class, - ?TimezoneInterface $timeZone = null + $resourceModel = Customer::class ) { $this->localeResolver = $localeResolver; parent::__construct($entityFactory, $logger, $fetchStrategy, $eventManager, $mainTable, $resourceModel); - $this->timeZone = $timeZone ?: ObjectManager::getInstance() - ->get(TimezoneInterface::class); } /** @@ -92,14 +83,6 @@ public function addFieldToFilter($field, $condition = null) return $this; } - if ($field === 'created_at') { - if (is_array($condition)) { - foreach ($condition as $key => $value) { - $condition[$key] = $this->timeZone->convertConfigTimeToUtc($value); - } - } - } - if (is_string($field) && count(explode('.', $field)) === 1) { $field = 'main_table.' . $field; } diff --git a/vendor/magento/module-sales/Model/ResourceModel/Order/Grid/Collection.php b/vendor/magento/module-sales/Model/ResourceModel/Order/Grid/Collection.php index f1a3f7777f4a5..c445affa44fbe 100644 --- a/vendor/magento/module-sales/Model/ResourceModel/Order/Grid/Collection.php +++ b/vendor/magento/module-sales/Model/ResourceModel/Order/Grid/Collection.php @@ -1,15 +1,14 @@ timeZone = $timeZone ?: ObjectManager::getInstance() - ->get(TimezoneInterface::class); } /** @@ -63,20 +55,4 @@ protected function _initSelect() return $this; } - - /** - * @inheritDoc - */ - public function addFieldToFilter($field, $condition = null) - { - if ($field === 'created_at') { - if (is_array($condition)) { - foreach ($condition as $key => $value) { - $condition[$key] = $this->timeZone->convertConfigTimeToUtc($value); - } - } - } - - return parent::addFieldToFilter($field, $condition); - } } diff --git a/vendor/magento/module-sales/Plugin/Model/ResourceModel/Order/OrderGridCollectionFilter.php b/vendor/magento/module-sales/Plugin/Model/ResourceModel/Order/OrderGridCollectionFilter.php deleted file mode 100644 index c306998e96fb0..0000000000000 --- a/vendor/magento/module-sales/Plugin/Model/ResourceModel/Order/OrderGridCollectionFilter.php +++ /dev/null @@ -1,84 +0,0 @@ -timeZone = $timeZone; - } - - /** - * Conditional column filters with timezone convertor interface - * - * @param SearchResult $subject - * @param \Closure $proceed - * @param string $field - * @param string|null $condition - * @return SearchResult|mixed - * @throws \Magento\Framework\Exception\LocalizedException - */ - public function aroundAddFieldToFilter( - SearchResult $subject, - \Closure $proceed, - $field, - $condition = null - ) { - if ($field === 'created_at' || $field === 'order_created_at') { - if (is_array($condition)) { - foreach ($condition as $key => $value) { - if ($value = $this->isValidDate($value)) { - $condition[$key] = $value->setTimezone(new \DateTimeZone('UTC'))->format('Y-m-d H:i:s'); - } - } - } - - $fieldName = $subject->getConnection()->quoteIdentifier('main_table.' . $field); - $condition = $subject->getConnection()->prepareSqlCondition($fieldName, $condition); - $subject->getSelect()->where($condition, null, Select::TYPE_CONDITION); - - return $subject; - } - - return $proceed($field, $condition); - } - - /** - * Validate date string - * - * @param mixed $datetime - * @return mixed - */ - private function isValidDate(mixed $datetime): mixed - { - try { - return $datetime instanceof DateTimeInterface - ? $datetime : (is_string($datetime) - ? new DateTime($datetime, new \DateTimeZone($this->timeZone->getConfigTimezone())) : false); - } catch (\Exception $e) { - return false; - } - } -} diff --git a/vendor/magento/module-sales/etc/adminhtml/di.xml b/vendor/magento/module-sales/etc/adminhtml/di.xml index 6d07dca85c340..97e308212ee21 100644 --- a/vendor/magento/module-sales/etc/adminhtml/di.xml +++ b/vendor/magento/module-sales/etc/adminhtml/di.xml @@ -49,9 +49,6 @@ - - - \Magento\Catalog\Ui\DataProvider\Product\ProductCollectionFactory diff --git a/vendor/magento/module-ui/Component/Filters.php b/vendor/magento/module-ui/Component/Filters.php index aa418a4522044..c850962241ff3 100644 --- a/vendor/magento/module-ui/Component/Filters.php +++ b/vendor/magento/module-ui/Component/Filters.php @@ -1,7 +1,7 @@ filterMap[$filterType]) && !isset($this->columnFilters[$component->getName()])) { + $config = (array) $component->getData('config'); + $userDefined = (bool) ($config['userDefined'] ?? false); + $filterComponent = $this->uiComponentFactory->create( $component->getName(), $this->filterMap[$filterType], - ['context' => $this->getContext()] + [ + 'context' => $this->getContext(), + 'userDefined' => $userDefined, + ] ); $filterComponent->setData('config', $component->getConfiguration()); $filterComponent->prepare(); diff --git a/vendor/magento/module-ui/Component/Filters/Type/Date.php b/vendor/magento/module-ui/Component/Filters/Type/Date.php index 28ad8568ebe31..2c90fbd07117b 100644 --- a/vendor/magento/module-ui/Component/Filters/Type/Date.php +++ b/vendor/magento/module-ui/Component/Filters/Type/Date.php @@ -1,11 +1,15 @@ userDefined = $userDefined; + parent::__construct($context, $uiComponentFactory, $filterBuilder, $filterModifier, $components, $data); + } + /** * Prepare component configuration * @@ -128,7 +155,7 @@ protected function applyFilterByType($type, $value) * @param int $hour * @param int $minute * @param int $second - * @return \DateTime + * @return \DateTime|null */ private function convertDatetime(string $value, int $hour = 0, int $minute = 0, int $second = 0): ?\DateTime { @@ -137,12 +164,13 @@ private function convertDatetime(string $value, int $hour = 0, int $minute = 0, $value, !$this->getData('config/skipTimeZoneConversion') ) - : $this->wrappedComponent->convertDate( + : $this->wrappedComponent->convertDateWithTimezone( $value, $hour, $minute, $second, - !$this->getData('config/skipTimeZoneConversion') + !$this->getData('config/skipTimeZoneConversion'), + !$this->userDefined ); return $value; diff --git a/vendor/magento/module-ui/Component/Form/Element/DataType/Date.php b/vendor/magento/module-ui/Component/Form/Element/DataType/Date.php index ca5e295492fe9..eada697c2ebac 100644 --- a/vendor/magento/module-ui/Component/Form/Element/DataType/Date.php +++ b/vendor/magento/module-ui/Component/Form/Element/DataType/Date.php @@ -1,7 +1,7 @@ convertDate($date, $hour, $minute, $second, $setUtcTimeZone); + } + + try { + $date = $this->convertDateFormat($date); + $dateObj = $this->localeDate->date($date, $this->getLocale(), $useStoreTimeZone, false); + $dateObj->setTime($hour, $minute, $second); + //convert store date to default date in UTC timezone without DST + if ($setUtcTimeZone) { + $dateObj->setTimezone(new \DateTimeZone('UTC')); + } + return $dateObj; + } catch (Exception $e) { + return null; + } + } + /** * Convert given date to default (UTC) timezone * + * @deprecated + * @see convertDateWithTimezone * @param int $date * @param int $hour * @param int $minute