Przeglądaj źródła

Ticket #4166 - Bug in live_updates.php for anonymus.

AntonLV 3 lat temu
rodzic
commit
a8d9dbc10f

+ 3 - 0
inc/classes/BxDolLiveUpdates.php

@@ -84,6 +84,9 @@ class BxDolLiveUpdates extends BxDolFactory implements iBxDolSingleton
      */
     public static function getInstance()
     {
+        if(!isLogged())
+            return false;
+
         if(!isset($GLOBALS['bxDolClasses'][__CLASS__]))
             $GLOBALS['bxDolClasses'][__CLASS__] = new BxTemplLiveUpdates();
 

+ 2 - 2
modules/boonex/timeline/classes/BxTimelineTemplate.php

@@ -350,8 +350,8 @@ class BxTimelineTemplate extends BxBaseModNotificationsTemplate
             'override_result' => &$sLiveUpdateCode,
         ));
 
-        if($sLiveUpdateCode === null)
-            $sLiveUpdateCode = call_user_func_array(array(BxDolLiveUpdates::getInstance(), 'add'), $aLiveUpdateParams);
+        if($sLiveUpdateCode === null && ($oLiveUpdates = BxDolLiveUpdates::getInstance()) !== false)
+            $sLiveUpdateCode = call_user_func_array([$oLiveUpdates, 'add'], $aLiveUpdateParams);
         //--- Add live update
 
         $sContentBefore = '';

+ 4 - 2
template/scripts/BxBaseCmts.php

@@ -184,8 +184,10 @@ class BxBaseCmts extends BxDolCmts
         //add live update
         $this->actionResumeLiveUpdate();
 
-        $sServiceCall = BxDolService::getSerializedService('system', 'get_live_update', [$this->_sSystem, $this->_iId, $this->_getAuthorId(), '{count}'], 'TemplCmtsServices');
-        BxDolLiveUpdates::getInstance()->add($this->_sSystem . '_live_updates_cmts_' . $this->_iId, 1, $sServiceCall);
+        if(($oLiveUpdates = BxDolLiveUpdates::getInstance())!== false) {
+            $sServiceCall = BxDolService::getSerializedService('system', 'get_live_update', [$this->_sSystem, $this->_iId, $this->_getAuthorId(), '{count}'], 'TemplCmtsServices');
+            $oLiveUpdates->add($this->_sSystem . '_live_updates_cmts_' . $this->_iId, 1, $sServiceCall);
+        }
         //add live update
 
         $sComments = $this->getComments($aBp, $aDp);

+ 7 - 2
template/scripts/BxBaseFunctions.php

@@ -763,9 +763,14 @@ class BxBaseFunctions extends BxDolFactory implements iBxDolSingleton
 
     protected function getInjHeadLiveUpdates() 
     {
-        return BxDolLiveUpdates::getInstance()->init();
+        $sContent = '';
+
+        if(($oLiveUpdates = BxDolLiveUpdates::getInstance()) !== false)
+            $sContent .= $oLiveUpdates->init();
+
+        return $sContent;
     }
-    
+
     protected function getInjHeaderPushNotifications() 
     {
         $iProfileId = bx_get_logged_profile_id();

+ 6 - 1
template/scripts/BxBaseLiveUpdatesServices.php

@@ -19,7 +19,12 @@ class BxBaseLiveUpdatesServices extends BxDol
 
     public function serviceInit()
     {
-        return BxDolLiveUpdates::getInstance()->init();
+        $sContent = '';
+
+        if(($oLiveUpdates = BxDolLiveUpdates::getInstance()) !== false)
+            $sContent .= $oLiveUpdates->init();
+
+        return $sContent;
     }
 }