После обновления вылезли ошибки, нужна помощь

Помогите пожалуйста убрать ошибки, вчера обновился и в одном плагине вылезли ошибки, разработчик видать забил уже давно и не выходит на связь.

В админке появились вот такие ошибки

Notice: Trying to access array offset on value of type null in /home/stroy-vibor.ru/public_html/wa-apps/shop/plugins/fastreg/lib/classes/shopFastregHelper.class.php on line 83

именно на эту строку ругается, если ее закомментировать то пропадает

return md5(wa()->getRouting()->getDomain(null, true) . '/' . $route['url']);

вот код этого файла

<?php

class shopFastregHelper
{

    static $settings;

    public static function setPassword($length, $charlist = 0, $case = 0)
    {
        $ch_list   = '';
        $ch_low    = 'abcdefghijklmnopqrstuvwxyz';
        $ch_up     = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
        $ch_digits = '0123456789';

        switch ((int)$case) {
            case 1:
                $ch_list = $ch_up;
                break;
            case 2:
                $ch_list = $ch_low . (!$charlist ? $ch_digits : '');
                break;
            case 0:
            default:
                $ch_list = $ch_up . (!$charlist ? $ch_digits : '') . $ch_low;
        }

        switch ($charlist) {
            case 1:
                $charlist = $ch_list;
                break;

            case 2:
                $charlist = $ch_digits;
                break;

            case 0:
            default:
                $charlist = $ch_list;
        }

        $pass        = '';
        $length      = !$length || !is_numeric($length) ? 5 : (int)$length;
        $max         = mb_strlen($charlist, '8bit') - 1;
        $method_name = function_exists('random_int') ? 'random_int' : 'rand';
        for ($i = 0; $i < $length; ++$i) {
            $char_id = $method_name(0, $max);
            $pass    .= $charlist[$char_id];
        }

        return $pass;
    }

    public static function send($contact, $login, $password)
    {
        $transport      = ['email', 'sms'];
        $route_hash     = shopFastregHelper::getCurrentRouteHash();
        $plugin         = wa()->getPlugin('fastreg');
        self::$settings = $plugin->getSettings($route_hash);
        if (!self::$settings) {
            self::$settings = $plugin->getSettings('default');
        }

        foreach ($transport as $type) {
            try {
                if (empty(self::$settings[$type])) {
                    continue;
                }

                $method = 'send' . ucfirst(strtolower($type));
                $class  = get_called_class();
                if (method_exists($class, $method)) {
                    call_user_func([$class, $method], $contact, $login, $password);
                }
            } catch (waException $e) {
                waLog::log($e->getMessage(), 'fastreg.log');
            }
        }
    }

    public static function getCurrentRouteHash()
    {
        $route = wa()->getRouting()->getRoute();
        return md5(wa()->getRouting()->getDomain(null, true) . '/' . $route['url']);
    }

    public static function sendEmail($contact, $login, $password, $send_to = null)
    {
        $settings = wa('shop')->getConfig()->getGeneralSettings();

        if (is_null($login)) {
            $login = $contact['login'];
        }

        $route_hash     = shopFastregHelper::getCurrentRouteHash();
        $plugin         = wa()->getPlugin('fastreg');
        self::$settings = $plugin->getSettings($route_hash);
        if (!self::$settings) {
            self::$settings = $plugin->getSettings('default');
        }

        $body  = self::$settings['email_template'];
        $email = !$send_to ? $contact->get('email', 'default') : $send_to;
        if ($email && $body && !empty($settings['email'])) {
            $subject = ifempty(self::$settings['subject'], 'Для Вас создан аккаунт');
            $view    = wa()->getView();
            $view->assign(['contact' => $contact, 'login' => $login, 'password' => $password]);

            $body = $view->fetch('string:' . $body);
            $mail = new waMailMessage($subject, $body);
            $mail->setTo($email, $contact->getName());
            $mail->setFrom($settings['email'], $settings['name']);
            return $mail->send();
        }
        return false;
    }

    public static function sendSms($contact, $login, $password, $phone = null)
    {
        $route_hash = shopFastregHelper::getCurrentRouteHash();
        $plugin     = wa()->getPlugin('fastreg');

        if (!$login) {
            $login = $contact['login'];
        }

        self::$settings = $plugin->getSettings($route_hash);
        if (!self::$settings) {
            self::$settings = $plugin->getSettings('default');
        }

        $sms_template = self::$settings['sms_template'];
        $sms_body     = '';

        if ($sms_template && $login && $password) {
            $assigns = ['contact' => $contact, 'login' => $login, 'password' => $password];
            $view    = wa()->getView();
            $view->assign($assigns);
            $sms_body = $view->fetch('string:' . $sms_template);
        }

        $to = !$phone ? $contact->get('phone', 'default') : $phone;
        if ($to && $sms_body) {
            $sms = new waSMS();
            return $sms->send($to, $sms_body, !empty(self::$settings['gateway']) ? self::$settings['gateway'] : null);
        }

        return false;
    }

    public static function cleanUpPhone($phone)
    {
        return preg_replace('/(\d)\s+(\d)/i', '$1$2', str_replace(str_split('+-()'), '', $phone));
    }

    public static function getStorefronts()
    {
        $result        = [];
        $routing       = wa()->getRouting();
        $domain_routes = $routing->getByApp('shop');
        foreach ($domain_routes as $domain => $routes) {
            foreach ($routes as $route) {
                $route_url          = $domain . '/' . $route['url'];
                $result[$route_url] = md5($route_url);
            }
        }
        return $result;
    }

    public static function attachOrder()
    {
        setcookie('attach_order', '1', time() + 60 * 60 * 24 * 30, '/');
        wa()->getStorage()->write('attach_order', 1);
    }

    public static function detachOrder($preserve_flags = false)
    {
        if (!$preserve_flags) {
            setcookie('attach_order', '', time() - 3600, '/');
            wa()->getStorage()->remove('attach_order');
        }

        $user = wa()->getUser();
        if ($user->getId()) {
            $user->logout();
        }
    }

    public static function addToCategory($contact_id, $category_id)
    {
        if ($contact_id && $category_id) {
            $model = new waContactCategoriesModel();
            return $model->add($contact_id, $category_id);
        }

        return false;
    }

    public static function orderAttached()
    {
        return (waRequest::cookie('attach_order', 0) || wa()->getStorage()->read('attach_order'));
    }

    public static function searchContact($customer)
    {
        $plugin     = wa()->getPlugin('fastreg');
        $route_hash = shopFastregHelper::getCurrentRouteHash();
        $settings   = $plugin->getSettings($route_hash);

        if (!$settings) {
            $settings = $plugin->getSettings('default');
        }

        if (empty($settings['status'])) {
            return false;
        }

        $contact              = [];
        $login_source         = $settings['login'];
        $reserve_login_source = $login_source === 'email' ? 'phone' : 'email';
        $sources              = [$login_source, $reserve_login_source];
        $checker              = new shopFastregPluginFrontendCheckController();

        foreach ($sources as $source){
            if (!empty($customer[$source])) {
                foreach ([true, false] as $bool){
                    if ($contact = $checker->getContact(
                        $source,
                        $customer[$source],
                        $bool
                    )){
                        break 2;
                    }
                }
            }
        }

        return $contact ? $contact['id'] : false;
    }
}

Так же появилось в каждой карточке клиента в поле Заметка о клиенте вот такой код

Notice: Trying to access array offset on value of type null in /home/stroy-vibor.ru/public_html/wa-cache/764ab8/apps/shop/templates/compiled/shop_ru_RU/f4/52/6a/f4526a30af53c1416e3eb68c33c2c23ef6646e55.file.info_section.html.php on line 292


Чистил кэш появляется другой код в другой папке сейчас /764ab8/


Обращался в поддержку webasyst там как всегда, сам дурак иди на форум, мы здесь не виноваты, прошу помочь убрать эти ошибки


2 ответа

  • 1

    Самый быстрый и простой способ — запретить вывод ошибок на экран :)

    Вернее не ошибок, а Notice/

    Пусть они в лог только пишутся

    В файл wa-config/SystemConfig.class.php в самый низ добавить строку

    @ini_set('display_errors', 0);

    • +1
      Leva Leva 18 ноября 2022 16:54 #

      Добавил, все равно есть эти ошибки

Добавить ответ

Чтобы добавить комментарий, зарегистрируйтесь или войдите