Просмотр исходного кода

Ticket #3001 - Get rid of $bReturnCount.

AntonLV 6 лет назад
Родитель
Сommit
08ec535c00

+ 2 - 6
modules/base/notifications/classes/BxBaseModNotificationsDb.php

@@ -437,7 +437,7 @@ class BxBaseModNotificationsDb extends BxBaseModGeneralDb
         return $this->query($sSql);
         return $this->query($sSql);
     }
     }
 
 
-    public function getEvents($aParams, $bReturnCount = false)
+    public function getEvents($aParams)
     {
     {
         list($sMethod, $sSelectClause, $sJoinClause, $sWhereClause, $sOrderClause, $sLimitClause) = $this->_getSqlPartsEvents($aParams);
         list($sMethod, $sSelectClause, $sJoinClause, $sWhereClause, $sOrderClause, $sLimitClause) = $this->_getSqlPartsEvents($aParams);
 
 
@@ -446,11 +446,7 @@ class BxBaseModNotificationsDb extends BxBaseModGeneralDb
             LEFT JOIN `{$this->_sTableHandlers}` ON `{$this->_sTable}`.`type`=`{$this->_sTableHandlers}`.`alert_unit` AND `{$this->_sTable}`.`action`=`{$this->_sTableHandlers}`.`alert_action` " . $sJoinClause . "
             LEFT JOIN `{$this->_sTableHandlers}` ON `{$this->_sTable}`.`type`=`{$this->_sTableHandlers}`.`alert_unit` AND `{$this->_sTable}`.`action`=`{$this->_sTableHandlers}`.`alert_action` " . $sJoinClause . "
             WHERE 1 " . $sWhereClause . " {order} {limit}";
             WHERE 1 " . $sWhereClause . " {order} {limit}";
 
 
-        $aEntries = $this->$sMethod(str_replace(array('{select}', '{order}', '{limit}'), array($sSelectClause, $sOrderClause, $sLimitClause), $sSql));
-        if(!$bReturnCount)
-        	return $aEntries;
-
-        return array($aEntries, (int)$this->getOne(str_replace(array('{select}', '{order}', '{limit}'), array("COUNT(*)", "", ""), $sSql)));
+        return $this->$sMethod(str_replace(array('{select}', '{order}', '{limit}'), array($sSelectClause, $sOrderClause, $sLimitClause), $sSql));
     }
     }
 
 
     protected function _getSqlPartsEvents($aParams)
     protected function _getSqlPartsEvents($aParams)

+ 2 - 5
modules/boonex/notifications/classes/BxNtfsDb.php

@@ -61,7 +61,7 @@ class BxNtfsDb extends BxBaseModNotificationsDb
     public function getEvents($aParams, $bReturnCount = false)
     public function getEvents($aParams, $bReturnCount = false)
     {
     {
         if($aParams['browse'] != 'list' || $aParams['type'] != BX_NTFS_TYPE_OBJECT_OWNER_AND_CONNECTIONS)
         if($aParams['browse'] != 'list' || $aParams['type'] != BX_NTFS_TYPE_OBJECT_OWNER_AND_CONNECTIONS)
-            return parent::getEvents($aParams, $bReturnCount);
+            return parent::getEvents($aParams);
 
 
         $bCountOnly = !empty($aParams['count_only']);
         $bCountOnly = !empty($aParams['count_only']);
 
 
@@ -101,10 +101,7 @@ class BxNtfsDb extends BxBaseModNotificationsDb
         if($bCountOnly)
         if($bCountOnly)
             $aEntries = (int)array_sum($aEntries);
             $aEntries = (int)array_sum($aEntries);
 
 
-        if(!$bReturnCount)
-            return $aEntries;
-
-        return array($aEntries, (int)$this->getOne(str_replace(array('{select}', '{order}', '{limit}'), array("COUNT(*)", "", ""), $sQuery)));
+        return $aEntries;
     }
     }
 
 
     protected function _getSqlPartsEvents($aParams)
     protected function _getSqlPartsEvents($aParams)

+ 3 - 3
modules/boonex/notifications/classes/BxNtfsModule.php

@@ -244,14 +244,14 @@ class BxNtfsModule extends BxBaseModNotificationsModule
         if(!empty($aBrowseParams) && is_array($aBrowseParams))
         if(!empty($aBrowseParams) && is_array($aBrowseParams))
             $aParams = array_merge($aParams, $aBrowseParams);
             $aParams = array_merge($aParams, $aBrowseParams);
 
 
-        list($aEvent) = $this->_oDb->getEvents($aParams, true);
+        $aEvents = $this->_oDb->getEvents($aParams);
 
 
         // returns parsed content for React Jot
         // returns parsed content for React Jot
         if (!is_array($aBrowseParams) && $aBrowseParams === 'return_parsed_content')
         if (!is_array($aBrowseParams) && $aBrowseParams === 'return_parsed_content')
-            foreach ($aEvent as &$aContent)
+            foreach ($aEvents as &$aContent)
                 $this->_oTemplate->getPost($aContent, array('return_parsed_content'));
                 $this->_oTemplate->getPost($aContent, array('return_parsed_content'));
 
 
-        return $aEvent;
+        return $aEvents;
     }
     }
 
 
     /**
     /**

+ 3 - 20
modules/boonex/timeline/classes/BxTimelineDb.php

@@ -470,7 +470,7 @@ class BxTimelineDb extends BxBaseModNotificationsDb
         return call_user_func_array(array($this, $aMethod['name']), $aMethod['params']);
         return call_user_func_array(array($this, $aMethod['name']), $aMethod['params']);
     }
     }
 
 
-    public function getEvents($aParams, $bReturnCount = false)
+    public function getEvents($aParams)
     {
     {
         list($sMethod, $sSelectClause, $mixedJoinClause, $mixedWhereClause, $sOrderClause, $sLimitClause) = $this->_getSqlPartsEvents($aParams);
         list($sMethod, $sSelectClause, $mixedJoinClause, $mixedWhereClause, $sOrderClause, $sLimitClause) = $this->_getSqlPartsEvents($aParams);
 
 
@@ -511,13 +511,7 @@ class BxTimelineDb extends BxBaseModNotificationsDb
                 'limit' => $sLimitClause
                 'limit' => $sLimitClause
             );
             );
 
 
-            $aEntries = $this->$sMethod(bx_replace_markers($sSqlMask, $aSqlMarkers));
-
-            return !$bReturnCount ? $aEntries : array($aEntries, (int)$this->getOne(bx_replace_markers($sSqlMask, array_merge($aSqlMarkers, array(
-                'select' => 'COUNT(*)',
-                'order' => '',
-                'limit' => ''
-            )))));
+            return $this->$sMethod(bx_replace_markers($sSqlMask, $aSqlMarkers));
         }
         }
 
 
         $bJoinAsArray = !empty($mixedJoinClause) && is_array($mixedJoinClause);
         $bJoinAsArray = !empty($mixedJoinClause) && is_array($mixedJoinClause);
@@ -528,7 +522,6 @@ class BxTimelineDb extends BxBaseModNotificationsDb
             $sLimitSubclause = isset($aParams['per_page']) ? 'LIMIT 0, ' . ($aParams['start'] + $aParams['per_page']) : '';
             $sLimitSubclause = isset($aParams['per_page']) ? 'LIMIT 0, ' . ($aParams['start'] + $aParams['per_page']) : '';
         }
         }
 
 
-        $iEntries = 0;
         $aSqlParts = array();
         $aSqlParts = array();
         foreach($mixedWhereClause as $sKey => $sValue) {
         foreach($mixedWhereClause as $sKey => $sValue) {
             $aSqlMarkers = array(
             $aSqlMarkers = array(
@@ -541,22 +534,12 @@ class BxTimelineDb extends BxBaseModNotificationsDb
             $sSqlPart = bx_replace_markers($sSqlMask, $aSqlMarkers);
             $sSqlPart = bx_replace_markers($sSqlMask, $aSqlMarkers);
 
 
             $aSqlParts[] = !$bCount ? $sSqlPart : (int)$this->$sMethod($sSqlPart);
             $aSqlParts[] = !$bCount ? $sSqlPart : (int)$this->$sMethod($sSqlPart);
-            if(!$bReturnCount)
-                continue;
-
-            $iEntries += (int)$this->getOne(bx_replace_markers($sSqlMask, array_merge($aSqlMarkers, array(
-                'select' => 'COUNT(*)',
-                'order' => '',
-                'limit' => ''
-            ))));
         }
         }
 
 
-        $aEntries = $bCount ? array_sum($aSqlParts) : $this->$sMethod(bx_replace_markers('(' . implode(') UNION (', $aSqlParts) . ') {order} {limit}', array(
+        return $bCount ? array_sum($aSqlParts) : $this->$sMethod(bx_replace_markers('(' . implode(') UNION (', $aSqlParts) . ') {order} {limit}', array(
             'order' => str_replace('`' . $this->_sTable . '`.', '', $sOrderClause),
             'order' => str_replace('`' . $this->_sTable . '`.', '', $sOrderClause),
             'limit' => str_replace('`' . $this->_sTable . '`.', '', $sLimitClause),
             'limit' => str_replace('`' . $this->_sTable . '`.', '', $sLimitClause),
         )));
         )));
-
-        return !$bReturnCount ? $aEntries : array($aEntries, $iEntries);
     }
     }
 
 
     protected function _getFilterAddon($iOwnerId, $sFilter)
     protected function _getFilterAddon($iOwnerId, $sFilter)

+ 2 - 3
modules/boonex/timeline/classes/BxTimelineModule.php

@@ -4210,9 +4210,8 @@ class BxTimelineModule extends BxBaseModNotificationsModule implements iBxDolCon
         }
         }
 
 
         $aParams = $this->getParams($sView, $sType, $iProfileId, $iStart, $iPerPage, $sFilter, $aModules);
         $aParams = $this->getParams($sView, $sType, $iProfileId, $iStart, $iPerPage, $sFilter, $aModules);
-        $aData = $this->_oDb->getEvents($aParams, true);
-
-        list($aEvents, $iCount) = $aData;
+        $aEvents = $this->_oDb->getEvents($aParams);
+        $iCount = $this->_oDb->getEvents(array_merge($aParams, array('count' => true)));
 
 
         if(empty($aEvents) || !is_array($aEvents))
         if(empty($aEvents) || !is_array($aEvents))
             return array(
             return array(