NOV 03 2018

Uncaught ArgumentCountError: Too few arguments to function Mage_Sales_Model_Order::getCreatedAtFormated(), 0 passed

Problem description

The following fatal PHP error is triggered on attempt to place order or send order confirmation email after upgrade to PHP 7.2:

PHP Fatal error:  Uncaught ArgumentCountError: Too few arguments to function Mage_Sales_Model_Order::getCreatedAtFormated(), 0 passed in lib/Varien/Filter/Template.php on line 301 and exactly 1 expected in app/code/core/Mage/Sales/Model/Order.php:2083

Cause


There is a call to getCreatedAtFormated function in somewhere in the order confirmation email templates and it is passed without any arguments, i.e. like the following:
{{var invoice.getCreatedAtFormated()}}
To correct the error it should be enough to replace this call in order confirmation email template with a defined format, like
{{var invoice.getCreatedAtFormated(‘short’)}}

Solution

To correct the error it should be enough to replace this call in order confirmation email template with a defined format, like
{{var invoice.getCreatedAtFormated(‘short’)}}

Alternatively, the function definition can be changed with override in local code:

--- app/code/core/Mage/Sales/Model/Order.php
+++ app/code/local/Mage/Sales/Model/Order.php
@@ -2080,7 +2080,7 @@
      * @param   string $format date format type (short|medium|long|full)
      * @return  string
      */
-    public function getCreatedAtFormated($format)
+    public function getCreatedAtFormated($format = 'short')

Posted in: Fatal errors

Uncaught ArgumentCountError: Too few arguments to function Mage_Sales_Model_Order::getCreatedAtFormated(), 0 passed
1 vote, 5.00 avg. rating (92% score)