Stamped-io / Magento-v2.x

2 stars 4 forks source link

PHP 8.0 issue while retrieving Store configuration values #15

Closed reense closed 1 year ago

reense commented 1 year ago

We're getting the following error:

Deprecated Functionality: explode(): Passing null to parameter #2 ($string) of type string is deprecated in /data/web/x/vendor/stamped-io/core/Model/ConfigProvider.php on line 144

This is because no 'Order status to trigger Rewards' value has been filled in Stores > configuration, however this should not thrown an error. This is solvable by changing `Model/ConfigProvider.php':

    public function getOrderStatuses($storeId = null)
    {
        return array_filter(explode(
            ',',
            $this->scopeConfig->getValue(
                self::STAMPED_CORE_ORDER_STATUS,
                ScopeInterface::SCOPE_STORE,
                $storeId
            )
        ));
    }

to

    public function getOrderStatuses($storeId = null)
    {
        return array_filter(explode(
            ',',
            $this->scopeConfig->getValue(
                self::STAMPED_CORE_ORDER_STATUS,
                ScopeInterface::SCOPE_STORE,
                $storeId
            ) ?: ''
        ));
    }

I can create a pull request if you want.