onpayio / prestashop

Prestashop 1.7+ module
MIT License
2 stars 1 forks source link

Error when viewing orders in backoffice - 500 Internal Server Error #1

Closed zyberland closed 4 years ago

zyberland commented 4 years ago

With prestashop version 1.7.6.1 and this module installed and activated we encountered an issue. When accessing orders in the backoffice, the resulting page looks wrong and ends with the following message: Oops! An Error Occurred The server returned a "500 Internal Server Error". Something is broken. Please let us know what you were doing when this error occurred. We will fix it as soon as possible. Sorry for any inconvenience caused.

And furthermore there is some error messages in the browser console like the following: ReferenceError: $ is not defined index.php:223:11

https://test.site.dk/admin/index.php?controller=AdminOrders&id_order=37&token=0ced4095680f4ac7ac7924e34141eec5&vieworder=1:223 ReferenceError: $ is not defined index.php:363:11 https://test.site.dk/admin/index.php?controller=AdminOrders&id_order=37&token=0ced4095680f4ac7ac7924e34141eec5&vieworder=1:363 ReferenceError: $ is not defined index.php:633:11 https://test.site.dk/admin/index.php?controller=AdminOrders&id_order=37&token=0ced4095680f4ac7ac7924e34141eec5&vieworder=1:633 We are using the following system spec.: Serverinformation Linux #1 SMP Debian 4.19.67-2+deb10u1 (2019-09-20) x86_64 Serversoftwarens version: Apache PHP-version: 7.3.11-1~deb10u1 MySQL-version: 10.3.17-MariaDB-0+deb10u1 How to resolve this issue?
ebbesmoeller commented 4 years ago

The browser console errors do not explain the underlying problem that Prestashop throws an error on. Please provide some errorlog from the webserver, in relation to the error that prestashop produces, in order to help us understand what actually goes wrong.

zyberland commented 4 years ago

Here is the Onpay log information. We also forgot to mention that the shop we are making is a multistore solution with two stores and we are getting errors in both stores. We get the same "500 Internal Server Error" in both stores, but primary store shows a incomplete page with the order information whereas the other only show the actual error message.

Website access.log output: 192.168.11.111 - - [21/Jan/2020:11:00:42 +0100] "POST /admin/ajax-tab.php HTTP/1.1" 200 351 "https://test.site.dk/admin/index.php?controller=AdminOrders&token=8846334da35f6e4e247a6250f182f8b6" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0" 192.168.11.111 - - [21/Jan/2020:11:00:42 +0100] "GET /modules/gamification/views/img/trophy.png HTTP/1.1" 200 1052 "https://test.site.dk/admin/index.php?controller=AdminOrders&token=8846334da35f6e4e247a6250f182f8b6" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0" 192.168.11.111 - - [21/Jan/2020:11:00:42 +0100] "GET /modules/gamification/views/img/badges/47_1.png HTTP/1.1" 200 7190 "https://test.site.dk/admin/index.php?controller=AdminOrders&token=8846334da35f6e4e247a6250f182f8b6" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0" 192.168.11.111 - - [21/Jan/2020:11:00:42 +0100] "GET /modules/gamification/views/img/badges/48_0.png HTTP/1.1" 200 5672 "https://test.site.dk/admin/index.php?controller=AdminOrders&token=8846334da35f6e4e247a6250f182f8b6" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0" 192.168.11.111 - - [21/Jan/2020:11:00:42 +0100] "GET /admin/themes/default/js/vendor/enquire.min.js HTTP/1.1" 200 1406 "https://test.site.dk/admin/index.php?controller=AdminOrders&token=8846334da35f6e4e247a6250f182f8b6" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0" 192.168.11.111 - - [21/Jan/2020:11:00:42 +0100] "GET /admin/themes/default/js/admin-theme.js HTTP/1.1" 200 4510 "https://test.site.dk/admin/index.php?controller=AdminOrders&token=8846334da35f6e4e247a6250f182f8b6" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0" 192.168.11.111 - - [21/Jan/2020:11:00:42 +0100] "GET /img/app_icon.png HTTP/1.1" 404 178969 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0" 192.168.11.111 - - [21/Jan/2020:11:01:07 +0100] "GET /admin/index.php?controller=AdminOrders&id_order=37&token=8846334da35f6e4e247a6250f182f8b6&vieworder=1 HTTP/1.1" 500 32101 "https://test.site.dk/admin/index.php?controller=AdminOrders&token=8846334da35f6e4e247a6250f182f8b6" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0" 192.168.11.111 - - [21/Jan/2020:11:01:07 +0100] "GET /img/os/3.gif HTTP/1.1" 200 1401 "https://test.site.dk/admin/index.php?controller=AdminOrders&id_order=37&token=8846334da35f6e4e247a6250f182f8b6&vieworder=1" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0" ... 192.168.11.111 - - [21/Jan/2020:11:08:36 +0100] "GET /admin/index.php?controller=AdminOrders&id_order=37&token=8846334da35f6e4e247a6250f182f8b6&vieworder=1 HTTP/1.1" 500 32101 "https://test.site.dk/admin/index.php?controller=AdminOrders&token=8846334da35f6e4e247a6250f182f8b6" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0" 192.168.11.111 - - [21/Jan/2020:11:08:37 +0100] "GET /img/os/3.gif HTTP/1.1" 200 1401 "https://test.site.dk/admin/index.php?controller=AdminOrders&id_order=37&token=8846334da35f6e4e247a6250f182f8b6&vieworder=1" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0"

Website error.log output: [Tue Jan 21 11:01:07.845301 2020] [proxy_fcgi:error] [pid 22288] [client 192.168.11.111:51516] AH01071: Got error 'PHP message: PHP Notice: Undefined index: history in /var/www/clients/client888/web9999/web/prestashop/modules/onpay/vendor/onpayio/php-sdk/src/API/Transaction/DetailedTransaction.php on line 24PHP message: PHP Warning: Invalid argument supplied for foreach() in /var/www/clients/client888/web9999/web/prestashop/modules/onpay/vendor/onpayio/php-sdk/src/API/Transaction/DetailedTransaction.php on line 24PHP message: PHP Notice: Undefined index: links in /var/www/clients/client888/web9999/web/prestashop/modules/onpay/vendor/onpayio/php-sdk/src/API/TransactionService.php on line 34', referer: https://test.site.dk/admin/index.php?controller=AdminOrders&token=8846334da35f6e4e247a6250f182f8b6 [Tue Jan 21 11:08:37.078981 2020] [proxy_fcgi:error] [pid 22070] [client 192.168.11.111:51536] AH01071: Got error 'PHP message: PHP Notice: Undefined index: history in /var/www/clients/client888/web9999/web/prestashop/modules/onpay/vendor/onpayio/php-sdk/src/API/Transaction/DetailedTransaction.php on line 24PHP message: PHP Warning: Invalid argument supplied for foreach() in /var/www/clients/client888/web9999/web/prestashop/modules/onpay/vendor/onpayio/php-sdk/src/API/Transaction/DetailedTransaction.php on line 24PHP message: PHP Notice: Undefined index: links in /var/www/clients/client888/web9999/web/prestashop/modules/onpay/vendor/onpayio/php-sdk/src/API/TransactionService.php on line 34', referer: https://test.site.dk/admin/index.php?controller=AdminOrders&token=8846334da35f6e4e247a6250f182f8b6

Output from /prestashop/var/logs/prod.log: [2020-01-21 11:01:07] request.CRITICAL: Uncaught PHP Exception Symfony\Component\Debug\Exception\FatalThrowableError: "Type error: Argument 1 passed to OnPay\API\Transaction\SimpleTransaction::setLinks() must be of the type array, null given, called in /var/www/clients/client888/web9999/web/prestashop/modules/onpay/vendor/onpayio/php-sdk/src/API/TransactionService.php on line 34" at /var/www/clients/client888/web9999/web/prestashop/modules/onpay/vendor/onpayio/php-sdk/src/API/Transaction/SimpleTransaction.php line 38 {"exception":"[object] (Symfony\Component\Debug\Exception\FatalThrowableError(code: 0): Type error: Argument 1 passed to OnPay\API\Transaction\SimpleTransaction::setLinks() must be of the type array, null given, called in /var/www/clients/client888/web9999/web/prestashop/modules/onpay/vendor/onpayio/php-sdk/src/API/TransactionService.php on line 34 at /var/www/clients/client888/web9999/web/prestashop/modules/onpay/vendor/onpayio/php-sdk/src/API/Transaction/SimpleTransaction.php:38)"} [] [2020-01-21 11:08:37] request.CRITICAL: Uncaught PHP Exception Symfony\Component\Debug\Exception\FatalThrowableError: "Type error: Argument 1 passed to OnPay\API\Transaction\SimpleTransaction::setLinks() must be of the type array, null given, called in /var/www/clients/client888/web9999/web/prestashop/modules/onpay/vendor/onpayio/php-sdk/src/API/TransactionService.php on line 34" at /var/www/clients/client888/web9999/web/prestashop/modules/onpay/vendor/onpayio/php-sdk/src/API/Transaction/SimpleTransaction.php line 38 {"exception":"[object] (Symfony\Component\Debug\Exception\FatalThrowableError(code: 0): Type error: Argument 1 passed to OnPay\API\Transaction\SimpleTransaction::setLinks() must be of the type array, null given, called in /var/www/clients/client888/web9999/web/prestashop/modules/onpay/vendor/onpayio/php-sdk/src/API/TransactionService.php on line 34 at /var/www/clients/client888/web9999/web/prestashop/modules/onpay/vendor/onpayio/php-sdk/src/API/Transaction/SimpleTransaction.php:38)"} []

After enabling DEBUG mode in Prestashop and trying again, the following errors were shown on the page in the browser: Exceptions Type error: Argument 1 passed to OnPay\API\Transaction\SimpleTransaction::setLinks() must be of the type array, null given, called in /var/www/clients/client888/web9999/web/prestashop/modules/onpay/vendor/onpayio/php-sdk/src/API/TransactionService.php on line 34

Exception Stack Trace 

Symfony\Component\Debug\Exception\ FatalThrowableError in modules/onpay/vendor/onpayio/php-sdk/src/API/Transaction/SimpleTransaction.php (line 38)

    /**
     * @internal Shall not be used outside the library
     * @param array $links
     */
    public function setLinks(array $links) {
        foreach ($links as $rel => $link) {
            $linkItem = new Link($rel, $link);
            $this->links[] = $linkItem;
        }
    }

[-] SimpleTransaction->setLinks(null) in modules/onpay/vendor/onpayio/php-sdk/src/API/TransactionService.php (line 34)

     */
    public function getTransaction($identifier) {
        $result = $this->api->get('transaction/' . urlencode($identifier));
        $detailedTransaction = new DetailedTransaction($result['data']);
        $detailedTransaction->setLinks($result['links']);
        return $detailedTransaction;
    }
    /**
     * @param null $page

[-] TransactionService->getTransaction('') in modules/onpay/onpay.php (line 304)

        $details = [];
        try {
            foreach ($payments as $payment) {
                $onpayInfo = $onPayAPI->transaction()->getTransaction($payment->transaction_id);
                $amount  = $this->currencyHelper->minorToMajor($onpayInfo->amount, $onpayInfo->currencyCode, ',');
                $chargable = $onpayInfo->amount - $onpayInfo->charged;
                $chargable = $this->currencyHelper->minorToMajor($chargable, $onpayInfo->currencyCode, ',');
                $refunded = $this->currencyHelper->minorToMajor($onpayInfo->refunded, $onpayInfo->currencyCode, ',');
                $charged = $this->currencyHelper->minorToMajor($onpayInfo->charged, $onpayInfo->currencyCode, ',');

[-] onpay->hookAdminOrder(array('id_order' => 37, 'smarty' => object(Smarty_Internal_Template), 'cookie' => object(Cookie), 'cart' => object(Cart), 'altern' => 4)) in classes/Hook.php (line 970)

        return $output;
    }
    public static function coreCallHook($module, $method, $params)
    {
        return $module->{$method}($params);
    }
    public static function coreRenderWidget($module, $hook_name, $params)
    {
        return $module->renderWidget($hook_name, $params);

[-] HookCore::coreCallHook(object(onpay), 'hookadminOrder', array('id_order' => 37, 'smarty' => object(Smarty_Internal_Template), 'cookie' => object(Cookie), 'cart' => object(Cart), 'altern' => 4)) in classes/Hook.php (line 359)

        if (is_callable(array($module, 'hook' . $hookName))) {
            return Hook::coreCallHook($module, 'hook' . $hookName, $hookArgs);
        }
        foreach (Hook::getHookAliasesFor($hookName) as $hook) {
            if (is_callable(array($module, 'hook' . $hook))) {
                return Hook::coreCallHook($module, 'hook' . $hook, $hookArgs);
            }
        }
        return '';
    }

[-] HookCore::callHookOn(object(onpay), 'displayAdminOrder', array('id_order' => 37, 'smarty' => object(Smarty_Internal_Template), 'cookie' => object(Cookie), 'cart' => object(Cart), 'altern' => 4)) in classes/Hook.php (line 907)

                if (0 !== $key && true === $chain) {
                    $hook_args = $output;
                }
                $display = Hook::callHookOn($moduleInstance, $hook_name, $hook_args);
                if ($array_return) {
                    $output[$moduleInstance->name] = $display;
                } else {
                    if (true === $chain) {

[-] HookCore::exec('displayAdminOrder', array('id_order' => 37, 'smarty' => object(Smarty_Internal_Template), 'cookie' => object(Cookie), 'cart' => object(Cart), 'altern' => 4), null) in config/smarty.config.inc.php (line 167)

        return $result;
    }
    unset($hook_params['h']);
    return Hook::exec($params['h'], $hook_params, $id_module);
}
function smartyCleanHtml($data)
{
    // Prevent xss injection.

[-] smartyHook(array('h' => 'displayAdminOrder', 'id_order' => 37), object(Smarty_Internal_Template)) in classes/Smarty/SmartyLazyRegister.php (line 83)

                } else {
                    $args[] = &$arguments[$a];
                }
            }
            return call_user_func_array($item, $args);
        }
    }
    public static function getInstance($smarty)
    {

[+] SmartyLazyRegister->__call('smartyHook', array(array('h' => 'displayAdminOrder', 'id_order' => 37), object(Smarty_Internal_Template))) in vendor/smarty/smarty/libs/sysplugins/smarty_template_compiled.php(252) : eval()'d code (line 1320) [+] Block_21026576765e26e05d314b77_88711714->callBlock(object(Smarty_Internal_Template)) in vendor/smarty/smarty/libs/sysplugins/smarty_internal_runtime_inheritance.php (line 248) [+] Smarty_Internal_Runtime_Inheritance->callBlock(object(Block_21026576765e26e05d314b77_88711714), object(Smarty_Internal_Template)) in vendor/smarty/smarty/libs/sysplugins/smarty_internal_runtime_inheritance.php (line 184) [+] Smarty_Internal_Runtime_Inheritance->process(object(Smarty_Internal_Template), object(Block_21026576765e26e05d314b77_88711714), object(Block_3122268585e26e05d3c9989_47796978)) in vendor/smarty/smarty/libs/sysplugins/smarty_internal_runtime_inheritance.php (line 186) [+] Smarty_Internal_Runtime_Inheritance->process(object(Smarty_Internal_Template), object(Block_3122268585e26e05d3c9989_47796978)) in vendor/smarty/smarty/libs/sysplugins/smarty_internal_runtime_inheritance.php (line 156) [+] Smarty_Internal_Runtime_Inheritance->instanceBlock(object(Smarty_Internal_Template), 'Block_3122268585e26e05d3c9989_47796978', 'override_tpl') in vendor/smarty/smarty/libs/sysplugins/smarty_template_compiled.php(252) : eval()'d code (line 34) [+] content_5e26e05d3cc0b9_71673503(object(Smarty_Internal_Template)) in vendor/smarty/smarty/libs/sysplugins/smarty_template_resource_base.php (line 123) [+] Smarty_Template_Resource_Base->getRenderedTemplateCode(object(Smarty_Internal_Template)) in vendor/smarty/smarty/libs/sysplugins/smarty_template_compiled.php (line 114) [+] Smarty_Template_Compiled->render(object(Smarty_Internal_Template)) in vendor/smarty/smarty/libs/sysplugins/smarty_internal_template.php (line 216) [+] Smarty_Internal_Template->render() in vendor/smarty/smarty/libs/sysplugins/smarty_internal_template.php (line 385) [+] Smarty_Internal_Template->_subTemplateRender('helpers/view/view.tpl', null, null, 0, 3600, array(), 2, false, null, null) in vendor/smarty/smarty/libs/sysplugins/smarty_internal_runtime_inheritance.php (line 116) [+] Smarty_Internal_Runtime_Inheritance->endChild(object(Smarty_Internal_Template), 'helpers/view/view.tpl') in vendor/smarty/smarty/libs/sysplugins/smarty_template_compiled.php(252) : eval()'d code (line 40) [+] content_5e26e05d3beac2_69830227(object(Smarty_Internal_Template)) in vendor/smarty/smarty/libs/sysplugins/smarty_template_resource_base.php (line 123) [+] Smarty_Template_Resource_Base->getRenderedTemplateCode(object(Smarty_Internal_Template)) in vendor/smarty/smarty/libs/sysplugins/smarty_template_compiled.php (line 114) [+] Smarty_Template_Compiled->render(object(Smarty_Internal_Template)) in vendor/smarty/smarty/libs/sysplugins/smarty_internal_template.php (line 216) [+] Smarty_Internal_Template->render(false, 0) in vendor/smarty/smarty/libs/sysplugins/smarty_internal_templatebase.php (line 232) [+] Smarty_Internal_TemplateBase->_execute(object(Smarty_Internal_Template), null, null, null, 0) in vendor/smarty/smarty/libs/sysplugins/smarty_internal_templatebase.php (line 116) [+] Smarty_Internal_TemplateBase->fetch() in classes/helper/Helper.php (line 114) [+] HelperCore->generate() in classes/helper/HelperView.php (line 58) [+] HelperViewCore->generateView() in classes/controller/AdminController.php (line 2468) [+] AdminControllerCore->renderView() in controllers/admin/AdminOrdersController.php (line 1955) [+] AdminOrdersControllerCore->renderView() in classes/controller/AdminController.php (line 2114) [+] AdminControllerCore->initContent() in classes/controller/Controller.php (line 292) [+] ControllerCore->run() in classes/Dispatcher.php (line 515) [+] DispatcherCore->dispatch() in admin/index.php (line 97)

And under the errors tab was shown the following information: CRITICAL 12:28:30 php Type error: Argument 1 passed to OnPay\API\Transaction\SimpleTransaction::setLinks() must be of the type array, null given, called in /var/www/clients/client888/web9999/web/prestashop/modules/onpay/vendor/onpayio/php-sdk/src/API/TransactionService.php on line 34 Show context Hide trace

FatalThrowableError {#1 ▼

message: "Type error: Argument 1 passed to OnPay\API\Transaction\SimpleTransaction::setLinks() must be of the type array, null given, called in /var/www/clients/client888/web9999/web/prestashop/modules/onpay/vendor/onpayio/php-sdk/src/API/TransactionService.php on line 34"

code: 0

file: FatalThrowableError {#1}

line: 38

severity: FatalThrowableError {#1}

trace: FatalThrowableError {#1} }

CRITICAL 12:28:30 request Uncaught PHP Exception Symfony\Component\Debug\Exception\FatalThrowableError: "Type error: Argument 1 passed to OnPay\API\Transaction\SimpleTransaction::setLinks() must be of the type array, null given, called in /var/www/clients/client888/web9999/web/prestashop/modules/onpay/vendor/onpayio/php-sdk/src/API/TransactionService.php on line 34" at /var/www/clients/client888/web9999/web/prestashop/modules/onpay/vendor/onpayio/php-sdk/src/API/Transaction/SimpleTransaction.php line 38 Show context Hide trace

FatalThrowableError {#1 ▼

message: "Type error: Argument 1 passed to OnPay\API\Transaction\SimpleTransaction::setLinks() must be of the type array, null given, called in /var/www/clients/client888/web9999/web/prestashop/modules/onpay/vendor/onpayio/php-sdk/src/API/TransactionService.php on line 34"

code: 0

file: FatalThrowableError {#1}

line: 38

severity: FatalThrowableError {#1}

trace: FatalThrowableError {#1} }

Hope this helps to identify the problem.

ebbesmoeller commented 4 years ago

The bug has been identified, and we're working on a fix.

ebbesmoeller commented 4 years ago

The issue has been addressed in https://github.com/onpayio/prestashop/pull/2 New release available: https://github.com/onpayio/prestashop/releases/tag/1.0.1