Неустранимая ошибка в CodeIgniter из плагина QuickBooks PHP DevKit - PullRequest
0 голосов
/ 10 октября 2019

После перехода на PHP 7.3.4 с 5.3.3 наше приложение CodeIgniter приводит к фатальной ошибке при загрузке страницы, которая не является страницей индекса. Причина кроется в плагине QuickBooks PHP DevKit, но он не уверен, что это связано с проблемой совместимости mysqli или с чем-то еще.

Неустранимая ошибка: необработанная ошибка: вызов функции-члена initialized () для null в / var/www/html/pay/plugins/QuickBooks/Utilities.php:630 Трассировка стека: # 0 /var/www/html/pay/plugins/quickbooks_config.php(68): QuickBooks_Utilities :: initialized ('mysql: // myfc_v2)... ') # 1 /var/www/html/pay/application/administration/models/invoice_model.php(21): require (' / var / www / html / p ... ') # 2 / var /www / html / pay / system / core / Loader.php (303): Invoice_model -> __ construct () # 3 /var/www/html/pay/application/administration/controllers/invoice_cc_pay.php(18): CI_Loader->модель ('Invoice_model') # 4 /var/www/html/pay/system/core/CodeIgniter.php(308): Invoice_CC_Pay -> __ construct () # 5 /var/www/html/pay/index.php(208): require_once ('/ var / www / html / p ...') # 6 {main} добавляется в /var/www/html/pay/plugins/QuickBooks/Utilities.php в строке 630

Utilities.php - Строки 626-631

static public function initialized($dsn, $driver_options = array())
{
    $Driver = QuickBooks_Utilities::driverFactory($dsn, $driver_options);

    ##### Where the error appears #####
    return $Driver->initialized();
}

static public function driverFactory($dsn_or_conn, $config = array(), $hooks = array(), $log_level = QUICKBOOKS_LOG_NORMAL)
{
    return QuickBooks_Driver_Factory::create($dsn_or_conn, $config, $hooks, $log_level);
}

Factory.php

class QuickBooks_Driver_Factory
{

static public function create($dsn_or_conn, $config = array(), $hooks = array(), $log_level = QUICKBOOKS_LOG_NORMAL)
{
    static $instances = array();

    if (!is_array($hooks))
    {
        $hooks = array();
    }

    // Do not serialize the $hooks because they might contain non-serializeable objects
    if (is_object($dsn_or_conn))
    {
        $key = get_class($dsn_or_conn) . serialize($config) . $log_level;
    }
    else
    {
        $key = (string) $dsn_or_conn . serialize($config) . $log_level;
    }

    if (!isset($instances[$key]))
    {
        if (is_resource($dsn_or_conn))
        {
            $scheme = current(explode(' ', get_resource_type($dsn_or_conn)));
        }
        elseif (is_object($dsn_or_conn))
        {
            $scheme = get_class($dsn_or_conn);
        }
        else
        {
            $scheme = QuickBooks_Utilities::parseDSN($dsn_or_conn, array(), 'scheme');
        }

        if (false !== strpos($scheme, 'sql'))       // SQL drivers are subclassed... change class/scheme name
        {
            $scheme = 'Sql_' . ucfirst(strtolower($scheme));
        }
        else
        {
            $scheme = ucfirst(strtolower($scheme));
        }

        $class = 'QuickBooks_Driver_' . $scheme;
        $file = '/QuickBooks/Driver/' . str_replace(' ', '/', ucwords(str_replace('_', ' ', strtolower($scheme)))) . '.php';

        if (strstr($file, 'Driver/.php')) {
            $file = str_replace('Driver/.php', 'Driver.php', $file);
        }

        //print('class: ' . $class . "\n");
        //print('file: ' . $file . "\n");

        QuickBooks_Loader::load($file);

        if (class_exists($class))
        {
            $Driver = new $class($dsn_or_conn, $config);
            $Driver->registerHooks($hooks);
            $Driver->setLogLevel($log_level);

            /*
            static $static = 0;
            $static++;
            print('Constructed new instance ' . $static . ' [' . $key . ']' . "\n");
            mysql_query("INSERT INTO quickbooks_log ( msg, log_datetime ) VALUES ( 'Here is my " . $static . " key: " . $key . "', NOW() )");
            //print_r($hooks);
            */

            // @todo Ugh this is really ugly... maybe have $log_level passed in as a parameter? Not really a driver option at all?
            //if (isset($config['log_level']))
            //{
            //  $driver->setLogLevel($config['log_level']);
            //}

            $instances[$key] = $Driver;
        }
        else
        {
            $instances[$key] = null;
        }
    }

    return $instances[$key];
}   

}
...