Opencart Uncaught Error:在null上调用成员函数get()

时间:2018-05-20 21:19:09

标签: php web-services opencart nusoap

我将Opencart 1.5.x API连接到移动应用程序,移动应用程序返回错误

 Fatal error:  Uncaught Error: Call to a member function get()
 on null in /var/www/vhosts/example.com/httpdocs/api/wk_index.php:109

 Stack trace:
 0 [internal function]: error_handler(2, 'Cannot modify h...', '/var/www/vhosts...', 4389, Array)
 1 /var/www/vhosts/example.com/httpdocs/api/lib/nusoap.php(4389): header('Server: NuSOAP ...', false)
 2 /var/www/vhosts/example.com/httpdocs/api/lib/nusoap.php(3829): nusoap_server->send_response()
 3 /var/www/vhosts/example.com/httpdocs/api/appserver.php(1776): nusoap_server->service('<?xml version="...')
 4 {main}   thrown in <b>/var/www/vhosts/example.com/httpdocs/api/wk_index.php</b> on line
 109

 Error example=NSXMLParserErrorexample Code=76 "(null)"
 UserInfo={NSXMLParserErrorColumn=8, NSXMLParserErrorLineNumber=137,
 NSXMLParserErrorMessage=Opening and ending tag mismatch: link line 0
 and head }

wk_index.php中的第109行

if ($config->get('config_error_display')) {
    echo '<b>' . $error . '</b>: ' . $errstr . ' in <b>' . $errfile . '</b> on line <b>' . $errline . '</b>';
}

完整的wk_index.php文件信息

<?php
// Version
define('VERSION', '1.5.2.1');

// Configuration
require_once('../config.php');


require_once(DIR_SYSTEM . 'library/pagecache.php');             //PAGECACHE
$pagecache = new PageCache();                                   //PAGECACHE
if ($pagecache->ServeFromCache()) {                             //PAGECACHE
    // exit here if we served this page from the cache          //PAGECACHE
    return;                                                     //PAGECACHE
}                                                               //PAGECACHE

// Install

    // Startup
    require_once(DIR_SYSTEM . 'startup.php');

    // Application Classes
    require_once(DIR_SYSTEM . 'library/customer.php');
    require_once(DIR_SYSTEM . 'library/affiliate.php');
    require_once(DIR_SYSTEM . 'library/currency.php');
    require_once(DIR_SYSTEM . 'library/tax.php');
    require_once(DIR_SYSTEM . 'library/weight.php');
    require_once(DIR_SYSTEM . 'library/length.php');
    require_once(DIR_SYSTEM . 'library/cart.php');
    require_once(DIR_SYSTEM . 'library/user.php');

//to detect admin
//require_once($vqmod->modCheck(DIR_SYSTEM . 'library/user.php'));

// Registry
$registry = new Registry();

// Loader
$loader = new Loader($registry);
$registry->set('load', $loader);

// Config
$config = new Config();
$registry->set('config', $config);

// Database 
$db = new DB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE);
$registry->set('db', $db);

// Store
if (isset($_SERVER['HTTPS']) && (($_SERVER['HTTPS'] == 'on') || ($_SERVER['HTTPS'] == '1'))) {
    $store_query = $db->query("SELECT * FROM " . DB_PREFIX . "store WHERE REPLACE(`ssl`, 'www.', '') = '" . $db->escape('https://' . str_replace('www.', '', $_SERVER['HTTP_HOST']) . rtrim(dirname($_SERVER['PHP_SELF']), '/.\\') . '/') . "'");
} else {
    $store_query = $db->query("SELECT * FROM " . DB_PREFIX . "store WHERE REPLACE(`url`, 'www.', '') = '" . $db->escape('http://' . str_replace('www.', '', $_SERVER['HTTP_HOST']) . rtrim(dirname($_SERVER['PHP_SELF']), '/.\\') . '/') . "'");
}

if ($store_query->num_rows) {
    $config->set('config_store_id', $store_query->row['store_id']);
} else {
    $config->set('config_store_id', 0);
}

// Settings
//$query = $db->query("SELECT * FROM " . DB_PREFIX . "setting WHERE store_id = '0' OR store_id = '" . (int)$config->get('config_store_id') . "' ORDER BY store_id ASC");

$query = $db->query("SELECT * FROM " . DB_PREFIX . "setting WHERE store_id = '0'  ORDER BY store_id ASC");

foreach ($query->rows as $setting) {
    if (!$setting['serialized']) {
        $config->set($setting['key'], $setting['value']);
    } else {
        $config->set($setting['key'], unserialize($setting['value']));
    }
}

if (!$store_query->num_rows) {
    $config->set('config_url', HTTP_SERVER);
    $config->set('config_ssl', HTTPS_SERVER);
}

// Url
$url = new Url($config->get('config_url'), $config->get('config_use_ssl') ? $config->get('config_ssl') : $config->get('config_url'));
$registry->set('url', $url);

// Log
$log = new Log($config->get('config_error_filename'));
$registry->set('log', $log);

function error_handler($errno, $errstr, $errfile, $errline) {
    global $log, $config;

    switch ($errno) {
        case E_NOTICE:
        case E_USER_NOTICE:
            $error = 'Notice';
            break;
        case E_WARNING:
        case E_USER_WARNING:
            $error = 'Warning';
            break;
        case E_ERROR:
        case E_USER_ERROR:
            $error = 'Fatal Error';
            break;
        default:
            $error = 'Unknown';
            break;
    }

    if ($config->get('config_error_display')) {
        echo '<b>' . $error . '</b>: ' . $errstr . ' in <b>' . $errfile . '</b> on line <b>' . $errline . '</b>';
    }

    if ($config->get('config_error_log')) {
        $log->write('PHP ' . $error . ':  ' . $errstr . ' in ' . $errfile . ' on line ' . $errline);
    }

    return true;
}

// Error Handler
set_error_handler('error_handler');

// Request
$request = new Request();
$registry->set('request', $request);

// Response
$response = new Response();
$response->addHeader('Content-Type: text/html; charset=utf-8');
$response->setCompression($config->get('config_compression'));
$registry->set('response', $response);

// Cache
$cache = new Cache();
$registry->set('cache', $cache);

// Session
$session = new Session();
$registry->set('session', $session);

// Language Detection
$languages = array();

$query = $db->query("SELECT * FROM " . DB_PREFIX . "language WHERE status = '1'"); 

foreach ($query->rows as $result) {
    $languages[$result['code']] = $result;
}

$detect = '';

if (isset($request->server['HTTP_ACCEPT_LANGUAGE']) && ($request->server['HTTP_ACCEPT_LANGUAGE'])) { 
    $browser_languages = explode(',', $request->server['HTTP_ACCEPT_LANGUAGE']);

    foreach ($browser_languages as $browser_language) {
        foreach ($languages as $key => $value) {
            if ($value['status']) {
                $locale = explode(',', $value['locale']);

                if (in_array($browser_language, $locale)) {
                    $detect = $key;
                }
            }
        }
    }
}

if (isset($session->data['language']) && array_key_exists($session->data['language'], $languages) && $languages[$session->data['language']]['status']) {
    $code = $session->data['language'];
} elseif (isset($request->cookie['language']) && array_key_exists($request->cookie['language'], $languages) && $languages[$request->cookie['language']]['status']) {
    $code = $request->cookie['language'];
} elseif ($detect) {
    $code = $detect;
} else {
    $code = $config->get('config_language');
}

if (!isset($session->data['language']) || $session->data['language'] != $code) {
    $session->data['language'] = $code;
}

if (!isset($request->cookie['language']) || $request->cookie['language'] != $code) {
    setcookie('language', $code, time() + 60 * 60 * 24 * 30, '/', $request->server['HTTP_HOST']);
}

$config->set('config_language_id', $languages[$code]['language_id']);
$config->set('config_language', $languages[$code]['code']);

// Language
$language = new Language($languages[$code]['directory']);
$language->load($languages[$code]['directory']);
$registry->set('language', $language);

// Document
$registry->set('document', new Document());

// Customer
$registry->set('customer', new Customer($registry));

// Affiliate
$registry->set('affiliate', new Affiliate($registry));

//user

$registry->set('user', new User($registry));

if (isset($request->get['tracking']) && !isset($request->cookie['tracking'])) {
    setcookie('tracking', $request->get['tracking'], time() + 3600 * 24 * 1000, '/');
}

// Currency
$registry->set('currency', new Currency($registry));

// Tax
$registry->set('tax', new Tax($registry));

// Weight
$registry->set('weight', new Weight($registry));

// Length
$registry->set('length', new Length($registry));

// Cart
$registry->set('cart', new Cart($registry));

//  Encryption
$registry->set('encryption', new Encryption($config->get('config_encryption')));

// Front Controller 
$controller = new Front($registry);

// Maintenance Mode
$controller->addPreAction(new Action('common/maintenance'));

// SEO URL's
$controller->addPreAction(new Action('common/seo_url'));    

// Router
if (isset($request->get['route'])) {
    $action = new Action($request->get['route']);
} else {
    $action = new Action('common/home');
}

// Dispatch
$controller->dispatch($action, new Action('error/not_found'));

// Output
$response->output();


if ($pagecache->OkToCache()) {                                  //PAGECACHE
    $pagecache->CachePage($response);                           //PAGECACHE
}                                                               //PAGECACHE 

?>

这是完整的config.php文件

<?php
// HTTP
define('HTTP_SERVER', 'http://www.example.com/');

//define('HTTP_IMAGE', 'http://www.example.com/image/');
define('HTTP_IMAGE', 'http://wwwexamplecom-cdn.com/image/');

define('HTTP_ADMIN', 'http://www.example.com/admin/');
define('HTTPS_CATALOG', 'https://www.example.com/');
define('HTTP_CATALOG', 'http://www.example.com/');

// HTTPS
define('HTTPS_SERVER', 'https://www.example.com/');
define('HTTPS_IMAGE', 'https://www.example.com/image/');

// DIR
define('DIR_APPLICATION', '/var/www/vhosts/example.com/httpdocs/catalog/');
define('DIR_SYSTEM', '/var/www/vhosts/example.com/httpdocs/system/');
define('DIR_DATABASE', '/var/www/vhosts/example.com/httpdocs/system/database/');
define('DIR_LANGUAGE', '/var/www/vhosts/example.com/httpdocs/catalog/language/');
define('DIR_TEMPLATE', '/var/www/vhosts/example.com/httpdocs/catalog/view/theme/');
//define('DIR_DEFAULT_TEMPLATE', '/var/www/vhosts/example.com/httpdocs/catalog/view/theme/');
define('DIR_CONFIG', '/var/www/vhosts/example.com/httpdocs/system/config/');
define('DIR_IMAGE', '/var/www/vhosts/example.com/httpdocs/image/');
define('DIR_CACHE', '/var/www/vhosts/example.com/httpdocs/system/cache/');
define('DIR_DOWNLOAD', '/var/www/vhosts/example.com/httpdocs/download/');
define('DIR_LOGS', '/var/www/vhosts/example.com/httpdocs/system/logs/');

// DB
define('DB_DRIVER', 'mysqliz');
define('DB_HOSTNAME', 'IP Address');
define('DB_USERNAME', 'USER');
define('DB_PASSWORD', 'PASSWORD');
define('DB_DATABASE', 'example');
define('DB_PREFIX', '');
?>

我尝试了所有可行的方法,但他们正在解决我的问题。应用程序没有运行,我误会了10天,请帮忙。

先谢谢你了!

编辑:问题原因估计: 经过深入挖掘和数周之后,我发现服务器正在接收SOAP 1.2 / 2.0请求,而我需要将其强制转换为SOAP 1.1

因此,我应该更改代码以接受1.2 / 2.0 SOAP或强制将请求作为SOAP 1.1发送,请帮忙吗?

编辑:05/07/2018
PHP-FPM会影响SOAP响应吗?请帮助您解决此问题

cURL配置:
卷曲
启用cURL支持
cURL信息7.35.0
3岁 特点
AsynchDNS是
CharConv没有
调试号 GSS-谈判是
IDN是
IPv6是
krb4没有
Largefile是
libz是
NTLM是
NTLMWB是
SPNEGO没有
SSL是
SSPI没有 TLS-SRP是
HTTP2否
协议dict,文件,ftp,ftps,gopher,http,https,imap,imaps,ldap,ldaps,pop3,pop3s,rtmp,rtsp,smtp,smtps,telnet,tftp
主机x86_64-pc-linux-gnu
SSL版本OpenSSL / 1.0.1f
ZLib版本1.2.8

0 个答案:

没有答案