Răsfoiți Sursa

#5017 Agents: problems with upgrade

Alex Trofimov 1 an în urmă
părinte
comite
20451f3073
2 a modificat fișierele cu 12 adăugiri și 9 ștergeri
  1. 3 2
      inc/classes/BxDolAI.php
  2. 9 7
      inc/classes/BxDolAlerts.php

+ 3 - 2
inc/classes/BxDolAI.php

@@ -63,8 +63,9 @@ class BxDolAI extends BxDolFactory implements iBxDolSingleton
      */
     public static function getInstance()
     {
-        if(!isset($GLOBALS['bxDolClasses'][__CLASS__]))
-            $GLOBALS['bxDolClasses'][__CLASS__] = new BxDolAI();
+        if (!isset($GLOBALS['bxDolClasses'][__CLASS__])) {
+            $GLOBALS['bxDolClasses'][__CLASS__] = BxDolDb::getInstance()->isTableExists('sys_agents_automators') ? new BxDolAI() : null;
+        }
 
         return $GLOBALS['bxDolClasses'][__CLASS__];
     }

+ 9 - 7
inc/classes/BxDolAlerts.php

@@ -146,13 +146,15 @@ class BxDolAlerts extends BxDol
 
         // call automators
         $oAi = BxDolAI::getInstance();
-
-        $aAutomators = $oAi->getAutomatorsEvent($this->sUnit, $this->sAction);
-        foreach($aAutomators as $aAutomator)
-            $oAi->callAutomator(BX_DOL_AI_AUTOMATOR_EVENT, [
-                'automator' => $aAutomator,
-                'alert' => $this
-            ]);
+        if ($oAi) {
+            $aAutomators = $oAi->getAutomatorsEvent($this->sUnit, $this->sAction);
+            foreach($aAutomators as $aAutomator) {
+                $oAi->callAutomator(BX_DOL_AI_AUTOMATOR_EVENT, [
+                    'automator' => $aAutomator,
+                    'alert' => $this
+                ]);
+            }
+        }
     }
 
     /**