diff --git a/vendor/magento/module-media-gallery-renditions/Model/Config.php b/vendor/magento/module-media-gallery-renditions/Model/Config.php index 6622ef36dffd7..7fd8841442390 100644 --- a/vendor/magento/module-media-gallery-renditions/Model/Config.php +++ b/vendor/magento/module-media-gallery-renditions/Model/Config.php @@ -1,23 +1,21 @@ scopeConfig = $scopeConfig; - $this->resourceConnection = $resourceConnection; + $this->initialConfig = $initialConfig; } /** @@ -72,11 +70,9 @@ public function isEnabled(): bool */ public function getWidth(): int { - try { - return $this->getDatabaseValue(self::XML_PATH_MEDIA_GALLERY_RENDITIONS_WIDTH_PATH); - } catch (NoSuchEntityException $exception) { - return (int) $this->scopeConfig->getValue(self::XML_PATH_MEDIA_GALLERY_RENDITIONS_WIDTH_PATH); - } + $width = $this->scopeConfig->getValue(self::XML_PATH_MEDIA_GALLERY_RENDITIONS_WIDTH_PATH) + ?? $this->initialConfig->getData('default')['system']['media_gallery_renditions']['width']; + return (int)$width; } /** @@ -86,44 +82,8 @@ public function getWidth(): int */ public function getHeight(): int { - try { - return $this->getDatabaseValue(self::XML_PATH_MEDIA_GALLERY_RENDITIONS_HEIGHT_PATH); - } catch (NoSuchEntityException $exception) { - return (int) $this->scopeConfig->getValue(self::XML_PATH_MEDIA_GALLERY_RENDITIONS_HEIGHT_PATH); - } - } - - /** - * Get value from database bypassing config cache - * - * @param string $path - * @return int - * @throws NoSuchEntityException - */ - private function getDatabaseValue(string $path): int - { - $connection = $this->resourceConnection->getConnection(); - $select = $connection->select() - ->from( - [ - 'config' => $this->resourceConnection->getTableName(self::TABLE_CORE_CONFIG_DATA) - ], - [ - 'value' - ] - ) - ->where('config.path = ?', $path); - $value = $connection->query($select)->fetchColumn(); - - if ($value === false) { - throw new NoSuchEntityException( - __( - 'The config value for %path is not saved to database.', - ['path' => $path] - ) - ); - } - - return (int) $value; + $height = $this->scopeConfig->getValue(self::XML_PATH_MEDIA_GALLERY_RENDITIONS_HEIGHT_PATH) + ?? $this->initialConfig->getData('default')['system']['media_gallery_renditions']['height']; + return (int)$height; } } diff --git a/vendor/magento/module-media-gallery-renditions/etc/adminhtml/system.xml b/vendor/magento/module-media-gallery-renditions/etc/adminhtml/system.xml index f36f628cb122f..2e4c6502b753a 100644 --- a/vendor/magento/module-media-gallery-renditions/etc/adminhtml/system.xml +++ b/vendor/magento/module-media-gallery-renditions/etc/adminhtml/system.xml @@ -1,8 +1,8 @@ @@ -18,12 +18,12 @@ Changing these settings will update all generated images. - validate-zero-or-greater validate-digits + validate-greater-than-zero validate-digits required-entry Enter the maximum width of an image in pixels. - validate-zero-or-greater validate-digits + validate-greater-than-zero validate-digits required-entry Enter the maximum height of an image in pixels.