Technical resource
Magento Checkout is broken after SUPEE-11085 with PHP<5.5
Note: This is a historical reference, not a current security baseline. Magento 1 is end-of-life.
Magento checkout page is broken after installing SUPEE-11085 (Authorize.net Direct Post Signature Key patch). Proceed to Checkout button results in a blank page, PHP fatal error is thrown:
Fatal error: Can't use method return value in write context in app/code/core/Mage/Authorizenet/Model/Directpost.php on line 392
Cause
empty() function used in the patch with a function return value. As per official PHP documentation:Prior to PHP 5.5,empty()function only supports variables; anything else will result in a parse error. In other words, the following will not work:empty(trim($name)). Instead, usetrim($name) == false.
Solution
Upgrade to newer PHP version (i.e. use our service to switch to faster PHP 7.2) or change the function usage according to your PHP version:
--- app/code/core/Mage/Authorizenet/Model/Directpost.php
+++ app/code/local/Mage/Authorizenet/Model/Directpost.php
@@ -389,7 +389,8 @@
public function validateResponse()
{
$response = $this->getResponse();
- $hashConfigKey = !empty($response->getData('x_SHA2_Hash')) ? 'signature_key' : 'trans_md5';
+ $response_getData_hash = $response->getData('x_SHA2_Hash');
+ $hashConfigKey = !empty($response_getData_hash) ? 'signature_key' : 'trans_md5';
//hash check
if (!$this->getConfigData($hashConfigKey)
--- app/code/core/Mage/Authorizenet/Model/Directpost/Request.php
+++ app/code/local/Mage/Authorizenet/Model/Directpost/Request.php
@@ -187,7 +187,8 @@
{
$fpTimestamp = time();
- if (!empty($this->_getSignatureKey())) {
+ $this_getSignatureKey = $this->_getSignatureKey();
+ if (!empty($this_getSignatureKey)) {
$hash = $this->_generateSha2RequestSign(
$this->getXLogin(),
$this->_getSignatureKey(),
--- app/code/core/Mage/Authorizenet/Model/Directpost/Response.php
+++ app/code/local/Mage/Authorizenet/Model/Directpost/Response.php
@@ -56,14 +56,17 @@
*/
public function isValidHash($storedHash, $merchantApiLogin)
{
- if (empty($this->getData('x_amount'))) {
+ $this_getData_x_amount = $this->getData('x_amount');
+ if (empty($this_getData_x_amount)) {
$this->setData('x_amount', '0.00');
}
- if (!empty($this->getData('x_SHA2_Hash'))) {
+ $this_getData_x_SHA2_Hash = $this->getData('x_SHA2_Hash');
+ $this_getData_x_MD5_Hash = $this->getData('x_MD5_Hash');
+ if (!empty($this_getData_x_SHA2_Hash)) {
$hash = $this->generateSha2Hash($storedHash);
return $hash == $this->getData('x_SHA2_Hash');
- } elseif (!empty($this->getData('x_MD5_Hash'))) {
+ } elseif (!empty($this_getData_x_MD5_Hash)) {
$hash = $this->generateHash($storedHash, $merchantApiLogin, $this->getXAmount(), $this->getXTransId());
return $hash == $this->getData('x_MD5_Hash');
}
Or use our ZIP bundle with these local overrides for PHP 5.4 and earlier versions from here:
| Magento version | SUPEE-11085 ZIP bundle |
|---|---|
| CE 1.9.2.4 - CE 1.9.4.0 (PHP5.5 and newer) | SUPEE-11085-1.9.x |
| CE 1.9.2.4 - CE 1.9.4.0 (PHP5.4 and older) | SUPEE-11085-1.9.x-oldPHP |
If you have any difficulties with solving this problem or got a similar one, please let us know in comments below, so we can find the solution together.