herveguetin
5/26/2014 - 11:53 PM

Bugfix in Mage_Core_Model_Email_Template

Bugfix in Mage_Core_Model_Email_Template

<php
    /**
     * Parse variables string into array of variables
     *
     * @param string $variablesString
     * @return array
     */
    protected function _parseVariablesString($variablesString)
    {
        $variables = array();
        if ($variablesString && is_string($variablesString)) {
            $variablesString = str_replace("\n", '', $variablesString);
            
            // Bugfixes - need to replace line break by nothing + need to remove leading comma for proper JSON decoding
            $variablesString = str_replace("\r", '', $variablesString);
            $variablesString = str_replace(",}", '}', $variablesString);
            
            $variables = Zend_Json::decode($variablesString);
        }
        return $variables;
    }