From f46a8a8c2cec604862c008fcc1a01850d88282fd Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Fri, 19 Jan 2024 21:56:52 +0100 Subject: [PATCH 1/2] Added helper methods to cast getStoreConfig to int or float --- app/Mage.php | 20 +++++++++++++++++++ app/code/core/Mage/Admin/Model/User.php | 2 +- .../Adminhtml/Block/Notification/Security.php | 2 +- .../core/Mage/Adminhtml/Block/Page/Head.php | 2 +- app/code/core/Mage/Catalog/Helper/Image.php | 2 +- .../Model/Api2/Product/Rest/Admin/V1.php | 4 ++-- .../Block/Stockqty/Abstract.php | 2 +- .../CatalogInventory/Model/Resource/Stock.php | 2 +- .../Model/Resource/Stock/Item.php | 2 +- .../CatalogInventory/Model/Stock/Item.php | 6 +++--- app/code/core/Mage/Checkout/Helper/Data.php | 6 +++--- .../Checkout/Model/Type/Multishipping.php | 2 +- .../Helper/Swatchdimensions.php | 2 +- .../core/Mage/Core/Block/Html/Calendar.php | 2 +- .../Mage/Core/Controller/Varien/Front.php | 2 +- .../core/Mage/Core/Model/Resource/Session.php | 2 +- .../Core/Model/Session/Abstract/Varien.php | 2 +- app/code/core/Mage/Customer/Helper/Data.php | 10 +++++----- .../core/Mage/Customer/Model/Customer.php | 2 +- .../Currency/Import/Currencyconverterapi.php | 2 +- .../Model/Currency/Import/Fixerio.php | 2 +- .../core/Mage/ImportExport/Helper/Data.php | 4 ++-- app/code/core/Mage/Log/Helper/Data.php | 2 +- app/code/core/Mage/Log/Model/Log.php | 2 +- .../core/Mage/Log/Model/Visitor/Online.php | 2 +- app/code/core/Mage/Oauth/Helper/Data.php | 4 ++-- app/code/core/Mage/Persistent/Helper/Data.php | 2 +- .../Resource/Product/Lowstock/Collection.php | 4 ++-- .../Mage/Rss/Block/Catalog/NotifyStock.php | 2 +- .../core/Mage/SalesRule/Helper/Coupon.php | 4 ++-- app/code/core/Mage/Sendfriend/Helper/Data.php | 6 +++--- app/code/core/Mage/Tax/Helper/Data.php | 4 ++-- 32 files changed, 67 insertions(+), 47 deletions(-) diff --git a/app/Mage.php b/app/Mage.php index fa839ec14c0..fd2abf8fe8a 100644 --- a/app/Mage.php +++ b/app/Mage.php @@ -411,6 +411,26 @@ public static function getStoreConfig($path, $store = null) return self::app()->getStore($store)->getConfig($path); } + /** + * @param string $path + * @param null|string|bool|int|Mage_Core_Model_Store $store + * @return float + */ + public static function getStoreConfigAsFloat(string $path, $store = null): float + { + return (float) self::getStoreConfig($path, $store); + } + + /** + * @param string $path + * @param null|string|bool|int|Mage_Core_Model_Store $store + * @return int + */ + public static function getStoreConfigAsInt(string $path, $store = null): int + { + return (int) self::getStoreConfig($path, $store); + } + /** * Retrieve config flag for store by path * diff --git a/app/code/core/Mage/Admin/Model/User.php b/app/code/core/Mage/Admin/Model/User.php index b10e26a982f..10ce60260a1 100644 --- a/app/code/core/Mage/Admin/Model/User.php +++ b/app/code/core/Mage/Admin/Model/User.php @@ -784,7 +784,7 @@ public function getUserCreateAdditionalEmail() */ public function getMinAdminPasswordLength() { - $minLength = (int)Mage::getStoreConfig(self::XML_PATH_MIN_ADMIN_PASSWORD_LENGTH); + $minLength = Mage::getStoreConfigAsInt(self::XML_PATH_MIN_ADMIN_PASSWORD_LENGTH); $absoluteMinLength = Mage_Core_Model_App::ABSOLUTE_MIN_PASSWORD_LENGTH; return ($minLength < $absoluteMinLength) ? $absoluteMinLength : $minLength; } diff --git a/app/code/core/Mage/Adminhtml/Block/Notification/Security.php b/app/code/core/Mage/Adminhtml/Block/Notification/Security.php index 4d85996a8b5..52db59889cc 100644 --- a/app/code/core/Mage/Adminhtml/Block/Notification/Security.php +++ b/app/code/core/Mage/Adminhtml/Block/Notification/Security.php @@ -47,7 +47,7 @@ protected function _canShowNotification() if ($this->_isFileAccessible()) { return true; } - $adminSessionLifetime = (int)Mage::getStoreConfig('admin/security/session_cookie_lifetime'); + $adminSessionLifetime = Mage::getStoreConfigAsInt('admin/security/session_cookie_lifetime'); Mage::app()->saveCache(true, self::VERIFICATION_RESULT_CACHE_KEY, [], $adminSessionLifetime); return false; } diff --git a/app/code/core/Mage/Adminhtml/Block/Page/Head.php b/app/code/core/Mage/Adminhtml/Block/Page/Head.php index 2c7a92c4852..1e008cfed85 100644 --- a/app/code/core/Mage/Adminhtml/Block/Page/Head.php +++ b/app/code/core/Mage/Adminhtml/Block/Page/Head.php @@ -47,6 +47,6 @@ public function getFormKey() */ public function getLoadingTimeout() { - return (int)Mage::getStoreConfig('admin/design/loading_timeout'); + return Mage::getStoreConfigAsInt('admin/design/loading_timeout'); } } diff --git a/app/code/core/Mage/Catalog/Helper/Image.php b/app/code/core/Mage/Catalog/Helper/Image.php index 47040931f42..0809ccd6eac 100644 --- a/app/code/core/Mage/Catalog/Helper/Image.php +++ b/app/code/core/Mage/Catalog/Helper/Image.php @@ -143,7 +143,7 @@ public function init(Mage_Catalog_Model_Product $product, $attributeName, $image Mage::getStoreConfig("design/watermark/{$this->_getModel()->getDestinationSubdir()}_image") ); $this->setWatermarkImageOpacity( - Mage::getStoreConfig("design/watermark/{$this->_getModel()->getDestinationSubdir()}_imageOpacity") + Mage::getStoreConfigAsInt("design/watermark/{$this->_getModel()->getDestinationSubdir()}_imageOpacity") ); $this->setWatermarkPosition( Mage::getStoreConfig("design/watermark/{$this->_getModel()->getDestinationSubdir()}_position") diff --git a/app/code/core/Mage/Catalog/Model/Api2/Product/Rest/Admin/V1.php b/app/code/core/Mage/Catalog/Model/Api2/Product/Rest/Admin/V1.php index 3c6a08f2271..9b9d0a7c3fe 100644 --- a/app/code/core/Mage/Catalog/Model/Api2/Product/Rest/Admin/V1.php +++ b/app/code/core/Mage/Catalog/Model/Api2/Product/Rest/Admin/V1.php @@ -276,7 +276,7 @@ protected function _prepareDataForSave($product, $productData) if (!$productData['use_config_gift_message_available'] && ($product->getData('gift_message_available') === null) ) { - $product->setData('gift_message_available', (int) Mage::getStoreConfig( + $product->setData('gift_message_available', Mage::getStoreConfigAsInt( Mage_GiftMessage_Helper_Message::XPATH_CONFIG_GIFT_MESSAGE_ALLOW_ITEMS, $product->getStoreId() )); @@ -288,7 +288,7 @@ protected function _prepareDataForSave($product, $productData) && ($product->getData('gift_wrapping_available') === null) ) { $xmlPathGiftWrappingAvailable = 'sales/gift_options/wrapping_allow_items'; - $product->setData('gift_wrapping_available', (int)Mage::getStoreConfig( + $product->setData('gift_wrapping_available', Mage::getStoreConfigAsInt( $xmlPathGiftWrappingAvailable, $product->getStoreId() )); diff --git a/app/code/core/Mage/CatalogInventory/Block/Stockqty/Abstract.php b/app/code/core/Mage/CatalogInventory/Block/Stockqty/Abstract.php index efa7787fb07..b159750842e 100644 --- a/app/code/core/Mage/CatalogInventory/Block/Stockqty/Abstract.php +++ b/app/code/core/Mage/CatalogInventory/Block/Stockqty/Abstract.php @@ -58,7 +58,7 @@ public function getStockQty() public function getThresholdQty() { if (!$this->hasData('threshold_qty')) { - $qty = (float) Mage::getStoreConfig(self::XML_PATH_STOCK_THRESHOLD_QTY); + $qty = Mage::getStoreConfigAsFloat(self::XML_PATH_STOCK_THRESHOLD_QTY); $this->setData('threshold_qty', $qty); } return $this->getData('threshold_qty'); diff --git a/app/code/core/Mage/CatalogInventory/Model/Resource/Stock.php b/app/code/core/Mage/CatalogInventory/Model/Resource/Stock.php index 55b5c16a0c7..e93eaca91af 100644 --- a/app/code/core/Mage/CatalogInventory/Model/Resource/Stock.php +++ b/app/code/core/Mage/CatalogInventory/Model/Resource/Stock.php @@ -220,7 +220,7 @@ protected function _initConfig() ]; foreach ($configMap as $field => $const) { - $this->$field = (int)Mage::getStoreConfig($const); + $this->$field = Mage::getStoreConfigAsInt($const); } $this->_isConfig = true; diff --git a/app/code/core/Mage/CatalogInventory/Model/Resource/Stock/Item.php b/app/code/core/Mage/CatalogInventory/Model/Resource/Stock/Item.php index 0c60e4f4e27..b23ad90d025 100644 --- a/app/code/core/Mage/CatalogInventory/Model/Resource/Stock/Item.php +++ b/app/code/core/Mage/CatalogInventory/Model/Resource/Stock/Item.php @@ -72,7 +72,7 @@ protected function _getLoadSelect($field, $value, $object) public function addCatalogInventoryToProductCollection($productCollection) { $adapter = $this->_getReadAdapter(); - $isManageStock = (int)Mage::getStoreConfig(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_MANAGE_STOCK); + $isManageStock = Mage::getStoreConfigAsInt(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_MANAGE_STOCK); $stockExpr = $adapter->getCheckSql('cisi.use_config_manage_stock = 1', $isManageStock, 'cisi.manage_stock'); $stockExpr = $adapter->getCheckSql("({$stockExpr} = 1)", 'cisi.is_in_stock', '1'); diff --git a/app/code/core/Mage/CatalogInventory/Model/Stock/Item.php b/app/code/core/Mage/CatalogInventory/Model/Stock/Item.php index ae9ff1b8509..abc109a3bd4 100644 --- a/app/code/core/Mage/CatalogInventory/Model/Stock/Item.php +++ b/app/code/core/Mage/CatalogInventory/Model/Stock/Item.php @@ -363,7 +363,7 @@ public function getMaxSaleQty() public function getNotifyStockQty() { if ($this->getUseConfigNotifyStockQty()) { - return (float) Mage::getStoreConfig(self::XML_PATH_NOTIFY_STOCK_QTY); + return Mage::getStoreConfigAsFloat(self::XML_PATH_NOTIFY_STOCK_QTY); } return (float) $this->getData('notify_stock_qty'); } @@ -411,7 +411,7 @@ public function getQtyIncrements() public function getDefaultQtyIncrements() { return Mage::getStoreConfigFlag(self::XML_PATH_ENABLE_QTY_INCREMENTS) - ? (int)Mage::getStoreConfig(self::XML_PATH_QTY_INCREMENTS) + ? Mage::getStoreConfigAsInt(self::XML_PATH_QTY_INCREMENTS) : false; } @@ -423,7 +423,7 @@ public function getDefaultQtyIncrements() public function getBackorders() { if ($this->getUseConfigBackorders()) { - return (int) Mage::getStoreConfig(self::XML_PATH_BACKORDERS); + return Mage::getStoreConfigAsInt(self::XML_PATH_BACKORDERS); } return $this->getData('backorders'); } diff --git a/app/code/core/Mage/Checkout/Helper/Data.php b/app/code/core/Mage/Checkout/Helper/Data.php index e9e0f9e4f80..684080229a3 100644 --- a/app/code/core/Mage/Checkout/Helper/Data.php +++ b/app/code/core/Mage/Checkout/Helper/Data.php @@ -280,16 +280,16 @@ protected function _getEmails($configPath, $storeId) public function isMultishippingCheckoutAvailable() { $quote = $this->getQuote(); - $isMultiShipping = (bool)(int)Mage::getStoreConfig('shipping/option/checkout_multiple'); + $isMultiShipping = (bool)Mage::getStoreConfigAsInt('shipping/option/checkout_multiple'); if ((!$quote) || !$quote->hasItems()) { return $isMultiShipping; } - $maximunQty = (int)Mage::getStoreConfig('shipping/option/checkout_multiple_maximum_qty'); + $maximumQty = Mage::getStoreConfigAsInt('shipping/option/checkout_multiple_maximum_qty'); return $isMultiShipping && !$quote->hasItemsWithDecimalQty() && $quote->validateMinimumAmount(true) && (($quote->getItemsSummaryQty() - $quote->getItemVirtualQty()) > 0) - && ($quote->getItemsSummaryQty() <= $maximunQty) + && ($quote->getItemsSummaryQty() <= $maximumQty) && !$quote->hasNominalItems() ; } diff --git a/app/code/core/Mage/Checkout/Model/Type/Multishipping.php b/app/code/core/Mage/Checkout/Model/Type/Multishipping.php index f4667dfe864..fe98a27ef32 100644 --- a/app/code/core/Mage/Checkout/Model/Type/Multishipping.php +++ b/app/code/core/Mage/Checkout/Model/Type/Multishipping.php @@ -210,7 +210,7 @@ public function setShippingItemsInformation($info) } } - $maxQty = (int)Mage::getStoreConfig('shipping/option/checkout_multiple_maximum_qty'); + $maxQty = Mage::getStoreConfigAsInt('shipping/option/checkout_multiple_maximum_qty'); if ($allQty > $maxQty) { Mage::throwException(Mage::helper('checkout')->__('Maximum qty allowed for Shipping to multiple addresses is %s', $maxQty)); } diff --git a/app/code/core/Mage/ConfigurableSwatches/Helper/Swatchdimensions.php b/app/code/core/Mage/ConfigurableSwatches/Helper/Swatchdimensions.php index 788b16d91cb..54f23f28e69 100644 --- a/app/code/core/Mage/ConfigurableSwatches/Helper/Swatchdimensions.php +++ b/app/code/core/Mage/ConfigurableSwatches/Helper/Swatchdimensions.php @@ -47,7 +47,7 @@ class Mage_ConfigurableSwatches_Helper_Swatchdimensions extends Mage_Core_Helper */ public function getDimension($area, $dimension, $outer = false) { - $dimension = (int) Mage::getStoreConfig( + $dimension = Mage::getStoreConfigAsInt( Mage_ConfigurableSwatches_Helper_Data::CONFIG_PATH_BASE . '/' . $area . '/' . $dimension ); if ($outer) { diff --git a/app/code/core/Mage/Core/Block/Html/Calendar.php b/app/code/core/Mage/Core/Block/Html/Calendar.php index 57fb031ae72..cff47742e81 100644 --- a/app/code/core/Mage/Core/Block/Html/Calendar.php +++ b/app/code/core/Mage/Core/Block/Html/Calendar.php @@ -53,7 +53,7 @@ protected function _toHtml() $this->assign('pm', Mage::helper('core')->jsonEncode(Zend_Locale_Data::getContent($localeCode, 'pm'))); // get first day of week and weekend days - $this->assign('firstDay', (int)Mage::getStoreConfig('general/locale/firstday')); + $this->assign('firstDay', Mage::getStoreConfigAsInt('general/locale/firstday')); $this->assign('weekendDays', Mage::helper('core')->jsonEncode((string)Mage::getStoreConfig('general/locale/weekend'))); // define default format and tooltip format diff --git a/app/code/core/Mage/Core/Controller/Varien/Front.php b/app/code/core/Mage/Core/Controller/Varien/Front.php index 52da8dc2aff..9d79f64aa72 100644 --- a/app/code/core/Mage/Core/Controller/Varien/Front.php +++ b/app/code/core/Mage/Core/Controller/Varien/Front.php @@ -329,7 +329,7 @@ protected function _checkBaseUrl($request) return; } - $redirectCode = (int)Mage::getStoreConfig('web/url/redirect_to_base'); + $redirectCode = Mage::getStoreConfigAsInt('web/url/redirect_to_base'); if (!$redirectCode) { return; } elseif ($redirectCode != 301) { diff --git a/app/code/core/Mage/Core/Model/Resource/Session.php b/app/code/core/Mage/Core/Model/Resource/Session.php index 0427f2a5258..56d246f80f4 100644 --- a/app/code/core/Mage/Core/Model/Resource/Session.php +++ b/app/code/core/Mage/Core/Model/Resource/Session.php @@ -90,7 +90,7 @@ public function getLifeTime() if (is_null($this->_lifeTime)) { $configNode = Mage::app()->getStore()->isAdmin() ? 'admin/security/session_cookie_lifetime' : 'web/cookie/cookie_lifetime'; - $this->_lifeTime = (int) Mage::getStoreConfig($configNode); + $this->_lifeTime = Mage::getStoreConfigAsInt($configNode); if ($this->_lifeTime < 60) { $this->_lifeTime = ini_get('session.gc_maxlifetime'); diff --git a/app/code/core/Mage/Core/Model/Session/Abstract/Varien.php b/app/code/core/Mage/Core/Model/Session/Abstract/Varien.php index 5660d366af5..481c3bfef32 100644 --- a/app/code/core/Mage/Core/Model/Session/Abstract/Varien.php +++ b/app/code/core/Mage/Core/Model/Session/Abstract/Varien.php @@ -94,7 +94,7 @@ public function start($sessionName = null) $cookie = $this->getCookie(); if (Mage::app()->getStore()->isAdmin()) { $sessionMaxLifetime = Mage_Core_Model_Resource_Session::SEESION_MAX_COOKIE_LIFETIME; - $adminSessionLifetime = (int)Mage::getStoreConfig('admin/security/session_cookie_lifetime'); + $adminSessionLifetime = Mage::getStoreConfigAsInt('admin/security/session_cookie_lifetime'); if ($adminSessionLifetime > $sessionMaxLifetime) { $adminSessionLifetime = $sessionMaxLifetime; } diff --git a/app/code/core/Mage/Customer/Helper/Data.php b/app/code/core/Mage/Customer/Helper/Data.php index 25441dc83a6..49d8d29495d 100644 --- a/app/code/core/Mage/Customer/Helper/Data.php +++ b/app/code/core/Mage/Customer/Helper/Data.php @@ -472,7 +472,7 @@ public function getIsRequireAdminUserToChangeUserPassword() */ public function getDefaultCustomerGroupId($store = null) { - return (int)Mage::getStoreConfig(Mage_Customer_Model_Group::XML_PATH_DEFAULT_ID, $store); + return Mage::getStoreConfigAsInt(Mage_Customer_Model_Group::XML_PATH_DEFAULT_ID, $store); } /** @@ -482,7 +482,7 @@ public function getDefaultCustomerGroupId($store = null) */ public function getCustomerForgotPasswordFlowSecure() { - return (int)Mage::getStoreConfig(self::XML_PATH_CUSTOMER_FORGOT_PASSWORD_FLOW_SECURE); + return Mage::getStoreConfigAsInt(self::XML_PATH_CUSTOMER_FORGOT_PASSWORD_FLOW_SECURE); } /** @@ -492,7 +492,7 @@ public function getCustomerForgotPasswordFlowSecure() */ public function getCustomerForgotPasswordEmailTimes() { - return (int)Mage::getStoreConfig(self::XML_PATH_CUSTOMER_FORGOT_PASSWORD_EMAIL_TIMES); + return Mage::getStoreConfigAsInt(self::XML_PATH_CUSTOMER_FORGOT_PASSWORD_EMAIL_TIMES); } /** @@ -502,7 +502,7 @@ public function getCustomerForgotPasswordEmailTimes() */ public function getCustomerForgotPasswordIpTimes() { - return (int)Mage::getStoreConfig(self::XML_PATH_CUSTOMER_FORGOT_PASSWORD_IP_TIMES); + return Mage::getStoreConfigAsInt(self::XML_PATH_CUSTOMER_FORGOT_PASSWORD_IP_TIMES); } /** @@ -527,7 +527,7 @@ public function getCustomerGroupIdBasedOnVatNumber($customerCountryCode, $vatVal ]; if (isset($vatClassToGroupXmlPathMap[$vatClass])) { - $groupId = (int)Mage::getStoreConfig($vatClassToGroupXmlPathMap[$vatClass], $store); + $groupId = Mage::getStoreConfigAsInt($vatClassToGroupXmlPathMap[$vatClass], $store); } return $groupId; diff --git a/app/code/core/Mage/Customer/Model/Customer.php b/app/code/core/Mage/Customer/Model/Customer.php index 72ce68e6b58..e99da3223ec 100644 --- a/app/code/core/Mage/Customer/Model/Customer.php +++ b/app/code/core/Mage/Customer/Model/Customer.php @@ -1634,7 +1634,7 @@ public function cleanPasswordsValidationData() */ public function getMinPasswordLength() { - $minLength = (int)Mage::getStoreConfig(self::XML_PATH_MIN_PASSWORD_LENGTH); + $minLength = Mage::getStoreConfigAsInt(self::XML_PATH_MIN_PASSWORD_LENGTH); $absoluteMinLength = Mage_Core_Model_App::ABSOLUTE_MIN_PASSWORD_LENGTH; return ($minLength < $absoluteMinLength) ? $absoluteMinLength : $minLength; } diff --git a/app/code/core/Mage/Directory/Model/Currency/Import/Currencyconverterapi.php b/app/code/core/Mage/Directory/Model/Currency/Import/Currencyconverterapi.php index b2fd8ad78a8..b9e1541b59d 100644 --- a/app/code/core/Mage/Directory/Model/Currency/Import/Currencyconverterapi.php +++ b/app/code/core/Mage/Directory/Model/Currency/Import/Currencyconverterapi.php @@ -117,7 +117,7 @@ protected function _convertBatch(array $data, $currencyFrom, array $currenciesTo $this->_url ); - $timeLimitCalculated = 2 * (int) Mage::getStoreConfig(self::XML_PATH_CURRENCY_CONVERTER_TIMEOUT) + $timeLimitCalculated = 2 * Mage::getStoreConfigAsInt(self::XML_PATH_CURRENCY_CONVERTER_TIMEOUT) + (int) ini_get('max_execution_time'); @set_time_limit($timeLimitCalculated); diff --git a/app/code/core/Mage/Directory/Model/Currency/Import/Fixerio.php b/app/code/core/Mage/Directory/Model/Currency/Import/Fixerio.php index 54498d0b906..0b6aa44c81e 100644 --- a/app/code/core/Mage/Directory/Model/Currency/Import/Fixerio.php +++ b/app/code/core/Mage/Directory/Model/Currency/Import/Fixerio.php @@ -116,7 +116,7 @@ protected function _convertBatch(array $data, $currencyFrom, array $currenciesTo $this->_url ); - $timeLimitCalculated = 2 * (int) Mage::getStoreConfig(self::XML_PATH_FIXERIO_TIMEOUT) + $timeLimitCalculated = 2 * Mage::getStoreConfigAsInt(self::XML_PATH_FIXERIO_TIMEOUT) + (int) ini_get('max_execution_time'); @set_time_limit($timeLimitCalculated); diff --git a/app/code/core/Mage/ImportExport/Helper/Data.php b/app/code/core/Mage/ImportExport/Helper/Data.php index a907e10f86e..33d499afc26 100644 --- a/app/code/core/Mage/ImportExport/Helper/Data.php +++ b/app/code/core/Mage/ImportExport/Helper/Data.php @@ -57,7 +57,7 @@ public function getLocalValidPaths() */ public function getBunchSize() { - return (int)Mage::getStoreConfig(self::XML_PATH_BUNCH_SIZE); + return Mage::getStoreConfigAsInt(self::XML_PATH_BUNCH_SIZE); } /** @@ -67,6 +67,6 @@ public function getBunchSize() */ public function getImportConfigurablePageSize() { - return (int)Mage::getStoreConfig(self::XML_PATH_IMPORT_CONFIGURABLE_PAGE_SIZE); + return Mage::getStoreConfigAsInt(self::XML_PATH_IMPORT_CONFIGURABLE_PAGE_SIZE); } } diff --git a/app/code/core/Mage/Log/Helper/Data.php b/app/code/core/Mage/Log/Helper/Data.php index ca1144def1d..263f75a22c9 100644 --- a/app/code/core/Mage/Log/Helper/Data.php +++ b/app/code/core/Mage/Log/Helper/Data.php @@ -41,7 +41,7 @@ class Mage_Log_Helper_Data extends Mage_Core_Helper_Abstract */ public function __construct(array $data = []) { - $this->_logLevel = $data['log_level'] ?? (int) Mage::getStoreConfig(self::XML_PATH_LOG_ENABLED); + $this->_logLevel = $data['log_level'] ?? Mage::getStoreConfigAsInt(self::XML_PATH_LOG_ENABLED); } /** diff --git a/app/code/core/Mage/Log/Model/Log.php b/app/code/core/Mage/Log/Model/Log.php index 1c9b2115c11..fb4b0c2d6ed 100644 --- a/app/code/core/Mage/Log/Model/Log.php +++ b/app/code/core/Mage/Log/Model/Log.php @@ -50,7 +50,7 @@ protected function _construct() */ public function getLogCleanTime() { - return (int)Mage::getStoreConfig(self::XML_LOG_CLEAN_DAYS) * 60 * 60 * 24; + return Mage::getStoreConfigAsInt(self::XML_LOG_CLEAN_DAYS) * 60 * 60 * 24; } /** diff --git a/app/code/core/Mage/Log/Model/Visitor/Online.php b/app/code/core/Mage/Log/Model/Visitor/Online.php index 7e404476a92..366fabe4c79 100644 --- a/app/code/core/Mage/Log/Model/Visitor/Online.php +++ b/app/code/core/Mage/Log/Model/Visitor/Online.php @@ -98,7 +98,7 @@ public function getUpdateFrequency() */ public function getOnlineInterval() { - $value = (int) Mage::getStoreConfig(self::XML_PATH_ONLINE_INTERVAL); + $value = Mage::getStoreConfigAsInt(self::XML_PATH_ONLINE_INTERVAL); if (!$value) { $value = Mage_Log_Model_Visitor::DEFAULT_ONLINE_MINUTES_INTERVAL; } diff --git a/app/code/core/Mage/Oauth/Helper/Data.php b/app/code/core/Mage/Oauth/Helper/Data.php index a25c44c328f..fc471c1b9b7 100644 --- a/app/code/core/Mage/Oauth/Helper/Data.php +++ b/app/code/core/Mage/Oauth/Helper/Data.php @@ -197,7 +197,7 @@ public function getProtocolEndpointUrl($type) public function isCleanupProbability() { // Safe get cleanup probability value from system configuration - $configValue = (int) Mage::getStoreConfig(self::XML_PATH_CLEANUP_PROBABILITY); + $configValue = Mage::getStoreConfigAsInt(self::XML_PATH_CLEANUP_PROBABILITY); return $configValue > 0 ? mt_rand(1, $configValue) == 1 : false; } @@ -208,7 +208,7 @@ public function isCleanupProbability() */ public function getCleanupExpirationPeriod() { - $minutes = (int) Mage::getStoreConfig(self::XML_PATH_CLEANUP_EXPIRATION_PERIOD); + $minutes = Mage::getStoreConfigAsInt(self::XML_PATH_CLEANUP_EXPIRATION_PERIOD); return $minutes > 0 ? $minutes : self::CLEANUP_EXPIRATION_PERIOD_DEFAULT; } diff --git a/app/code/core/Mage/Persistent/Helper/Data.php b/app/code/core/Mage/Persistent/Helper/Data.php index ae2a7294262..f866ddeb953 100644 --- a/app/code/core/Mage/Persistent/Helper/Data.php +++ b/app/code/core/Mage/Persistent/Helper/Data.php @@ -92,7 +92,7 @@ public function isShoppingCartPersist($store = null) */ public function getLifeTime($store = null) { - $lifeTime = (int) Mage::getStoreConfig(self::XML_PATH_LIFE_TIME, $store); + $lifeTime = Mage::getStoreConfigAsInt(self::XML_PATH_LIFE_TIME, $store); return ($lifeTime < 0) ? 0 : $lifeTime; } diff --git a/app/code/core/Mage/Reports/Model/Resource/Product/Lowstock/Collection.php b/app/code/core/Mage/Reports/Model/Resource/Product/Lowstock/Collection.php index fe64bf6c872..78e835754b2 100644 --- a/app/code/core/Mage/Reports/Model/Resource/Product/Lowstock/Collection.php +++ b/app/code/core/Mage/Reports/Model/Resource/Product/Lowstock/Collection.php @@ -204,7 +204,7 @@ public function useManageStockFilter($storeId = null) $this->joinInventoryItem(); $manageStockExpr = $this->getConnection()->getCheckSql( $this->_getInventoryItemField('use_config_manage_stock') . ' = 1', - (int) Mage::getStoreConfig(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_MANAGE_STOCK, $storeId), + Mage::getStoreConfigAsInt(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_MANAGE_STOCK, $storeId), $this->_getInventoryItemField('manage_stock') ); $this->getSelect()->where($manageStockExpr . ' = ?', 1); @@ -222,7 +222,7 @@ public function useNotifyStockQtyFilter($storeId = null) $this->joinInventoryItem(['qty']); $notifyStockExpr = $this->getConnection()->getCheckSql( $this->_getInventoryItemField('use_config_notify_stock_qty') . ' = 1', - (int)Mage::getStoreConfig(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_NOTIFY_STOCK_QTY, $storeId), + Mage::getStoreConfigAsInt(Mage_CatalogInventory_Model_Stock_Item::XML_PATH_NOTIFY_STOCK_QTY, $storeId), $this->_getInventoryItemField('notify_stock_qty') ); $this->getSelect()->where('qty < ?', $notifyStockExpr); diff --git a/app/code/core/Mage/Rss/Block/Catalog/NotifyStock.php b/app/code/core/Mage/Rss/Block/Catalog/NotifyStock.php index fc74f26284c..406d08ec2cc 100644 --- a/app/code/core/Mage/Rss/Block/Catalog/NotifyStock.php +++ b/app/code/core/Mage/Rss/Block/Catalog/NotifyStock.php @@ -57,7 +57,7 @@ protected function _toHtml() ]; $rssObj->_addHeader($data); - $globalNotifyStockQty = (float) Mage::getStoreConfig( + $globalNotifyStockQty = Mage::getStoreConfigAsFloat( Mage_CatalogInventory_Model_Stock_Item::XML_PATH_NOTIFY_STOCK_QTY ); Mage::helper('rss')->disableFlat(); diff --git a/app/code/core/Mage/SalesRule/Helper/Coupon.php b/app/code/core/Mage/SalesRule/Helper/Coupon.php index 6b649145502..1cc6858dd6a 100644 --- a/app/code/core/Mage/SalesRule/Helper/Coupon.php +++ b/app/code/core/Mage/SalesRule/Helper/Coupon.php @@ -71,7 +71,7 @@ public function getFormatsList() */ public function getDefaultLength() { - return (int)Mage::getStoreConfig(self::XML_PATH_SALES_RULE_COUPON_LENGTH); + return Mage::getStoreConfigAsInt(self::XML_PATH_SALES_RULE_COUPON_LENGTH); } /** @@ -111,7 +111,7 @@ public function getDefaultSuffix() */ public function getDefaultDashInterval() { - return (int)Mage::getStoreConfig(self::XML_PATH_SALES_RULE_COUPON_DASH_INTERVAL); + return Mage::getStoreConfigAsInt(self::XML_PATH_SALES_RULE_COUPON_DASH_INTERVAL); } /** diff --git a/app/code/core/Mage/Sendfriend/Helper/Data.php b/app/code/core/Mage/Sendfriend/Helper/Data.php index dca37362eaa..096cd7829e2 100644 --- a/app/code/core/Mage/Sendfriend/Helper/Data.php +++ b/app/code/core/Mage/Sendfriend/Helper/Data.php @@ -65,7 +65,7 @@ public function isAllowForGuest($store = null) */ public function getMaxRecipients($store = null) { - return (int)Mage::getStoreConfig(self::XML_PATH_MAX_RECIPIENTS, $store); + return Mage::getStoreConfigAsInt(self::XML_PATH_MAX_RECIPIENTS, $store); } /** @@ -76,7 +76,7 @@ public function getMaxRecipients($store = null) */ public function getMaxEmailPerPeriod($store = null) { - return (int)Mage::getStoreConfig(self::XML_PATH_MAX_PER_HOUR, $store); + return Mage::getStoreConfigAsInt(self::XML_PATH_MAX_PER_HOUR, $store); } /** @@ -97,7 +97,7 @@ public function getPeriod() */ public function getLimitBy($store = null) { - return (int)Mage::getStoreConfig(self::XML_PATH_LIMIT_BY, $store); + return Mage::getStoreConfigAsInt(self::XML_PATH_LIMIT_BY, $store); } /** diff --git a/app/code/core/Mage/Tax/Helper/Data.php b/app/code/core/Mage/Tax/Helper/Data.php index 642c969458f..82012c90f7e 100644 --- a/app/code/core/Mage/Tax/Helper/Data.php +++ b/app/code/core/Mage/Tax/Helper/Data.php @@ -928,7 +928,7 @@ public function getTaxBasedOn($store = null) */ public function applyTaxOnCustomPrice($store = null) { - return ((int)Mage::getStoreConfig(Mage_Tax_Model_Config::CONFIG_XML_PATH_APPLY_ON, $store) == 0); + return (Mage::getStoreConfigAsInt(Mage_Tax_Model_Config::CONFIG_XML_PATH_APPLY_ON, $store) == 0); } /** @@ -939,7 +939,7 @@ public function applyTaxOnCustomPrice($store = null) */ public function applyTaxOnOriginalPrice($store = null) { - return ((int)Mage::getStoreConfig(Mage_Tax_Model_Config::CONFIG_XML_PATH_APPLY_ON, $store) == 1); + return (Mage::getStoreConfigAsInt(Mage_Tax_Model_Config::CONFIG_XML_PATH_APPLY_ON, $store) == 1); } /** From 9edbadc9ef0002f8cb5ebc4b6ff549a0ae5cb97b Mon Sep 17 00:00:00 2001 From: Sven Reichel Date: Fri, 2 Feb 2024 00:50:34 +0100 Subject: [PATCH 2/2] Use Mage::getStoreConfigFlag() --- app/code/core/Mage/Checkout/Helper/Data.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/core/Mage/Checkout/Helper/Data.php b/app/code/core/Mage/Checkout/Helper/Data.php index 684080229a3..cd660c35133 100644 --- a/app/code/core/Mage/Checkout/Helper/Data.php +++ b/app/code/core/Mage/Checkout/Helper/Data.php @@ -280,7 +280,7 @@ protected function _getEmails($configPath, $storeId) public function isMultishippingCheckoutAvailable() { $quote = $this->getQuote(); - $isMultiShipping = (bool)Mage::getStoreConfigAsInt('shipping/option/checkout_multiple'); + $isMultiShipping = Mage::getStoreConfigFlag('shipping/option/checkout_multiple'); if ((!$quote) || !$quote->hasItems()) { return $isMultiShipping; }