Comment to 'UNA 14 Timeline Cleanup Script – Expert Review Requested'
  • @Michael Newton ..

    Sorry for the delayed response — things have been quite busy on our side. We’re in the process of procuring a VPS to replicate the live server (around 380–400GB). Since we don’t have a dedicated development server, this VPS will allow us to test safely outside of production. It’ll be a temporary setup, just for thorough testing and validation.

    As per your request, I extracted the Delete Function from the BxTimelineModule.php file :

    public function deleteEvent($aEvent)

      {

       if(empty($aEvent) || !is_array($aEvent) || !$this->_oDb->deleteEvent(array('id' => (int)$aEvent['id'])))

          return false;

        $this->onDelete($aEvent);

        return true;

      }

      public function getFormPost($aParams = [])

      {     

        $CNF = &$this->_oConfig->CNF;

        $iUserId = $this->getUserId();

        $oForm = $this->getFormPostObject($aParams);

        $aFormInitCheckerParams = [];

        $bValues = !empty($aParams['values']) && is_array($aParams['values']);

        if($bValues) {

          $this->_prepareFormForAutoSubmit($oForm, $aParams['values']);

          $aFormInitCheckerParams = [[], $aParams['values']];

          unset($aParams['values']);

        }

        call_user_func_array([$oForm, 'initChecker'], $aFormInitCheckerParams);

        $bAjaxMode = $oForm->isAjaxMode();

        $bDynamicMode = $bAjaxMode;

    --

      public function deleteLinksUnused($iProfileId)

      {

        $aLinks = $this->_oDb->getUnusedLinks($iProfileId);

        if(empty($aLinks) || !is_array($aLinks))

          return;

        $oStorage = BxDolStorage::getObjectInstance($this->_oConfig->getObject('storage_photos'));

        foreach($aLinks as $aLink)

          if(!empty($aLink['media_id']))

            $oStorage->deleteFile($aLink['media_id']);

        $this->_oDb->deleteUnusedLinks($iProfileId);

      }

      public function deleteCacheItem($iEventId)

      {

        //--- Delete own item cache.

        $oCacheItem = $this->getCacheItemObject();

        $aCacheKeys = $this->_oConfig->getCacheItemKeys($iEventId);

        foreach($aCacheKeys as $sCacheKey)

          $oCacheItem->delData($sCacheKey);

        //--- Delete item cache for reposts.

        $aReposts = $this->_oDb->getReposts($iEventId);

        foreach($aReposts as $aRepost)

          $this->deleteCacheItem($aRepost['event_id']);

      }

      public function rebuildSlice()

      {

        if(!$this->_oConfig->isCacheTable())

          return;

        $this->_oDb->rebuildSlice();

      }

      /**

       * Protected Methods 

       */

      protected function _serviceGetBlockView($iProfileId = 0, $aBrowseParams = array())

      {

        if(empty($iProfileId) && bx_get('profile_id') !== false)

          $iProfileId = bx_process_input(bx_get('profile_id'), BX_DATA_INT);