12

I have updated my Magento Store from 1.9.2.4 to 1.9.3.0

We use shipping software (Shipworks) that connects via a SOAP/XML-RPC user.

After the update shipworks logging shows this response in the logs:

<?xml version="1.0" encoding="UTF-8"?>
-<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
-<SOAP-ENV:Body>
-<SOAP-ENV:Fault>
<faultcode>1</faultcode>
<faultstring>Internal Error. Please see log for details.</faultstring>
</SOAP-ENV:Fault>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

So I went and turned on exception logging in Magento and get the following error:

2016-10-13T18:24:14+00:00 ERR (3): 
SoapFault exception: [1] Internal Error. Please see log for details. in /public_html/app/code/core/Mage/Api/Model/Server/Adapter/Soap.php:196
Stack trace:
#0 /public_html/app/code/core/Mage/Api/Model/Server/Handler/Abstract.php(140): Mage_Api_Model_Server_Adapter_Soap->fault('1', 'Internal Error....')
#1 /public_html/app/code/core/Mage/Api/Model/Server/Handler/Abstract.php(48): Mage_Api_Model_Server_Handler_Abstract->_fault('internal')
#2 /public_html/app/code/core/Mage/Api/Model/Server/Handler/Abstract.php(559): Mage_Api_Model_Server_Handler_Abstract->handlePhpError(4096, 'Argument 1 pass...', '/home/deepsix/p...', 559, Array)
#3 /public_html/app/code/core/Mage/Api/Model/Server/Handler/Abstract.php(299): Mage_Api_Model_Server_Handler_Abstract->processingMethodResult('<?xml version="...')
#4 [internal function]: Mage_Api_Model_Server_Handler_Abstract->call('ca4d34d100c92c8...', 'shipWorksApi.ge...', Array)
#5 /public_html/lib/Zend/Soap/Server.php(889): SoapServer->handle('<?xml version="...')
#6 /public_html/app/code/core/Mage/Api/Model/Server/Adapter/Soap.php(174): Zend_Soap_Server->handle()
#7 /public_html/app/code/core/Mage/Api/Model/Server.php(138): Mage_Api_Model_Server_Adapter_Soap->run()
#8 /public_html/app/code/core/Mage/Api/controllers/SoapController.php(40): Mage_Api_Model_Server->run()
#9 /public_html/app/code/core/Mage/Core/Controller/Varien/Action.php(418): Mage_Api_SoapController->indexAction()
#10 /public_html/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(254): Mage_Core_Controller_Varien_Action->dispatch('index')
#11 /public_html/app/code/core/Mage/Core/Controller/Varien/Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#12 /public_html/app/code/core/Mage/Core/Model/App.php(365): Mage_Core_Controller_Varien_Front->dispatch()
#13 /public_html/app/Mage.php(684): Mage_Core_Model_App->run(Array)
#14 /public_html/index.php(83): Mage::run('', 'store')
#15 {main}

So I have went and done a diff between the Abstract.php from 1.9.2.4 and 1.9.3.0 and get the following:

290a291
>                 $result = array();
292c293
<                     return $model->$method((is_array($args) ? $args : array($args)));
---
>                     $result = $model->$method((is_array($args) ? $args : array($args)));
294c295
<                     return $model->$method($args);
---
>                     $result = $model->$method($args);
296c297
<                     return call_user_func_array(array(&$model, $method), $args);
---
>                     $result = call_user_func_array(array(&$model, $method), $args);
297a299
>                 return $this->processingMethodResult($result);
403a406
>                     $callResult = array();
405c408
<                         $result[] = $model->$method((is_array($args) ? $args : array($args)));
---
>                         $callResult = $model->$method((is_array($args) ? $args : array($args)));
407c410
<                         $result[] = $model->$method($args);
---
>                         $callResult = $model->$method($args);
409c412
<                         $result[] = call_user_func_array(array(&$model, $method), $args);
---
>                         $callResult = call_user_func_array(array(&$model, $method), $args);
410a414
>                     $result[] = $this->processingMethodResult($callResult);
544a549,585
>     }
> 
>     /**
>      * Prepare Api data for XML exporting
>      * See allowed characters in XML:
>      * @link http://www.w3.org/TR/2000/REC-xml-20001006#NT-Char
>      *
>      * @param array $result
>      * @return mixed
>      */
>     public function processingMethodResult(array $result)
>     {
>         foreach ($result as &$row) {
>             if (!is_null($row) && !is_bool($row) && !is_numeric($row)) {
>                 $row = $this->processingRow($row);
>             }
>         }
>         return $result;
>     }
> 
>     /**
>      * Prepare Api row data for XML exporting
>      * Convert not allowed symbol to numeric character reference
>      *
>      * @param $row
>      * @return mixed
>      */
>     public function processingRow($row)
>     {
>         $row = preg_replace_callback(
>             '/[^\x{0009}\x{000a}\x{000d}\x{0020}-\x{D7FF}\x{E000}-\x{FFFD}\x{10000}-\x{10FFFF}]/u',
>             function ($matches) {
>                 return '&#' . Mage::helper('core/string')->uniOrd($matches[0]) . ';';
>             },
>             $row
>         );
>         return $row;

Any help would be appreciated.

14

Same error with another extension here. system.log says

Argument 1 passed to Mage_Api_Model_Server_Handler_Abstract::processingMethodResult() must be of the type array, string given, called in app/code/core/Mage/Api/Model/Server/Handler/Abstract.php...

I think the problem is the new method

Mage_Api_Model_Server_Handler_Abstract::processingMethodResult(array $result)

which only accepts arrays. So every Api function returning a scalar value will throw this error. To get this going again i copied app/code/core/Mage/Api/Model/Server/Handler/Abstract.php to app/code/local/Mage/Api/Model/Server/Handler/Abstract.php and patched processingMethodResult:

public function processingMethodResult($result)
{
    if (is_array($result)) {
        foreach ($result as &$row) {
            if (!is_null($row) && !is_bool($row) && !is_numeric($row)) {
                if (is_array($row)) {
                    $row = $this->processingMethodResult($row);
                } else {
                    $row = $this->processingRow($row);
                }
            }
        }
    } else {
        if (!is_null($result) && !is_bool($result) && !is_numeric($result)) {
            $result = $this->processingRow($result);
        }
    }
    return $result;
}
  • which version of magento are you running? – LandonL Oct 14 '16 at 0:05
  • This does fix the problem. Why would the magento core file be changed to array vs string anyway here? – LandonL Oct 14 '16 at 0:30
  • Excellent fix, thank you. Has anyone raised this as a bug with Magento? Lots of people are going to get bitten by this. – BlueC Oct 14 '16 at 9:14
  • The change is more around PHP7, see my answer below. Also, stackoverflow.com/a/4103536/158325 it's not really a bug, but makes the API PHP7 compatible. – B00MER Oct 14 '16 at 12:55
  • 1
    @LandonL: I updated from 1.9.2.4 to 1.9.3.0. – Belgor Oct 15 '16 at 14:37
1

More than likely the ShipStation module and/or the PHP version you are running isn't compatible:

Guessing off the truncated PHP error message that's returned:

Argument 1 pass...' is most likely Argument 1 passed to methodhere() must be an instance of string, string given

What version of PHP are you running and have you consulted with ShipStation to see if they have any newer version and/or compatibility issues with the latest Magento version/patches.

Also, you can add a bit more logging here: https://github.com/OpenMage/magento-mirror/blob/magento-1.9/lib/Zend/Soap/Server.php#L889 to capture more of the truncated PHP error that's being returned, to get validation that it is the correct error being returned.

Hope this helps.

  • How would I get more of the truncated error? I am uncertain how to increase the length of the line. – LandonL Oct 14 '16 at 0:07
  • The system is currently running php 5.6.25, I called shipworks today, but since the magento update 1.9.3.0 just came out yesterday, I don't believe they have had a chance to look at the issue yet. – LandonL Oct 14 '16 at 0:13
1

Belgors answer really helped me, but I ended up modifying the patch slightly to allow for extra objects to be included in the API reposnse.

For example you now get aheadWorks storecredit and/or giftcard object-arrays with the Magento XML-RPC call for order information.

(code updated from suggestion by Björn Tantau - to better work with objects & collections)

public function processingMethodResult($result)
{
    if (is_object($result) && is_callable(array($result, 'toArray'))) {
        $result = $result->toArray();
    }
    if (is_array($result)) {
        foreach ($result as &$row) {
            if (is_object($row) && is_callable(array($row, 'toArray'))) {
                $row = $row->toArray();
            }
            if (!is_null($row) && !is_bool($row) && !is_numeric($row)) {
                if (is_array($row)) {
                    $row = $this->processingMethodResult($row);
                } else {
                    $row = $this->processingRow($row);
                }
            }
        }
    } else {
        if (!is_null($result) && !is_bool($result) && !is_numeric($result)) {
            $result = $this->processingRow($result);
        }
    }
    return $result;
}

protected by Community Jan 14 '17 at 21:18

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.