PHP Fatal error: Uncaught TypeError: Unsupported operand types: string - string in /home/wwwroovendor/shardj/zf1-future/library/Zend/Locale/Math/PhpMath.php:97 Stack trace:
verision:[v20.1.0-rc2]
File: Mage_Adminhtml_Cms_PageController::_filterPostData()
when i save the cms page, this error comes.
protected function _filterPostData($data)
{
Mage::log($data);
$data = $this->_filterDates($data, ['custom_theme_from', 'custom_theme_to']);
Mage::log($data);
return $data;
}
from the code, system will validate two filed from the post custom_theme_from & custom_theme_to, even if it's empty.
file:Mage_Core_Controller_Varien_Action::_filterDates
protected function _filterDates($array, $dateFields)
{
if (empty($dateFields)) {
return $array;
}
$filterInput = new Zend_Filter_LocalizedToNormalized([
'date_format' => Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT)
]);
$filterInternal = new Zend_Filter_NormalizedToLocalized([
'date_format' => Varien_Date::DATE_INTERNAL_FORMAT
]);
foreach ($dateFields as $dateField) {
if (array_key_exists($dateField, $array) && !empty($dateField)) {
$array[$dateField] = $filterInput->filter($array[$dateField]);
$array[$dateField] = $filterInternal->filter($array[$dateField]);
}
}
return $array;
}
fix: array_key_exists($dateField, $array) && !empty($dateField) to array_key_exists($dateField, $array) && !empty($array[$dateField])
protected function _filterDates($array, $dateFields)
{
if (empty($dateFields)) {
return $array;
}
$filterInput = new Zend_Filter_LocalizedToNormalized([
'date_format' => Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT)
]);
$filterInternal = new Zend_Filter_NormalizedToLocalized([
'date_format' => Varien_Date::DATE_INTERNAL_FORMAT
]);
foreach ($dateFields as $dateField) {
if (array_key_exists($dateField, $array) && !empty($array[$dateField])) {
$array[$dateField] = $filterInput->filter($array[$dateField]);
$array[$dateField] = $filterInternal->filter($array[$dateField]);
}
}
return $array;
}
this is just happen on OpenMage 20.1.0-rc2
I am trying to reproduce this issue with OpenMage 20.1.0-rc4 based on the following steps:
- Backend > CMS > Pages
- I select from the grid the page named '404 'Not Found'
- I click [Save Page] button
I did not find any warnings/errors in the logs or browser window.
I install with clean OpenMage 20.1.0-rc2 or OpenMage 20.1.0-rc3
1,Backend > CMS > Pages 2,I select from the grid the page named '404 'Not Found' 3,I click [Save Page] button
after save the page error: This page isn’t working www.xxx.com is currently unable to handle this request. HTTP ERROR 500
after i check the php error log:
[21-Apr-2023 02:31:19 UTC] PHP Fatal error: Uncaught TypeError: Unsupported operand types: string - string in /home/wwwroot/lnmp01/domain/xxx.com/web/vendor/shardj/zf1-future/library/Zend/Locale/Math/PhpMath.php:97
Stack trace:
#0 /home/wwwroot/lnmp01/domain/xxx.com/web/vendor/shardj/zf1-future/library/Zend/Locale/Format.php(387): Zend_Locale_Math_PhpMath::Sub('0', '', 0)
#1 /home/wwwroot/lnmp01/domain/xxx.com/web/vendor/shardj/zf1-future/library/Zend/Locale/Format.php(666): Zend_Locale_Format::toNumber('', Array)
#2 /home/wwwroot/lnmp01/domain/xxx.com/web/vendor/shardj/zf1-future/library/Zend/Filter/NormalizedToLocalized.php(110): Zend_Locale_Format::toFloat('', Array)
#3 /home/wwwroot/lnmp01/domain/xxx.com/web/app/code/core/Mage/Core/Controller/Varien/Action.php(1000): Zend_Filter_NormalizedToLocalized->filter('')
#4 /home/wwwroot/lnmp01/domain/xxx.com/web/app/code/core/Mage/Adminhtml/controllers/Cms/PageController.php(245): Mage_Core_Controller_Varien_Action->_filterDates(Array, Array)
#5 /home/wwwroot/lnmp01/domain/xxx.com/web/app/code/core/Mage/Adminhtml/controllers/Cms/PageController.php(119): Mage_Adminhtml_Cms_PageController->_filterPostData(Array)
#6 /home/wwwroot/lnmp01/domain/xxx.com/web/app/code/core/Mage/Core/Controller/Varien/Action.php(422): Mage_Adminhtml_Cms_PageController->saveAction()
#7 /home/wwwroot/lnmp01/domain/xxx.com/web/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(256): Mage_Core_Controller_Varien_Action->dispatch('save')
#8 /home/wwwroot/lnmp01/domain/xxx.com/web/app/code/core/Mage/Core/Controller/Varien/Front.php(182): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#9 /home/wwwroot/lnmp01/domain/xxx.com/web/app/code/core/Mage/Core/Model/App.php(365): Mage_Core_Controller_Varien_Front->dispatch()
#10 /home/wwwroot/lnmp01/domain/xxx.com/web/app/Mage.php(739): Mage_Core_Model_App->run(Array)
#11 /home/wwwroot/lnmp01/domain/xxx.com/web/index.php(56): Mage::run('', 'store')
#12 {main}
thrown in /home/wwwroot/lnmp01/domain/xxx.com/web/vendor/shardj/zf1-future/library/Zend/Locale/Math/PhpMath.php on line 97
i think it's bug and i have test many times with the LNMP env.
mmmm i can't reproduce it on the main branch :-\
Oops, forgot to search first.. PR here: #3217
Fixed in https://github.com/OpenMage/magento-lts/pull/3217.