original_string: public function podiumMoveTo($target = null)
      {
          $newParent = Forum::find()->where(['id' => $target])->limit(1)->one();
          if (empty($newParent)) {
              Log::error('No parent forum of given ID found', $this->id, __METHOD__);
              return false;
          }
  
          $postsCount = $this->postsCount;
          $transaction = Forum::getDb()->beginTransaction();
          try {
              $this->forum->updateCounters(['threads' => -1, 'posts' => -$postsCount]);
              $newParent->updateCounters(['threads' => 1, 'posts' => $postsCount]);
              $this->forum_id = $newParent->id;
              $this->category_id = $newParent->category_id;
              if (!$this->save()) {
                  throw new Exception('Thread saving error!');
              }
              Post::updateAll(['forum_id' => $newParent->id], ['thread_id' => $this->id]);
              $transaction->commit();
              PodiumCache::clearAfter('threadMove');
              Log::info('Thread moved', $this->id, __METHOD__);
              return true;
          } catch (Exception $e) {
              $transaction->rollBack();
              Log::error($e->getMessage(), null, __METHOD__);
          }
          return false;
      }
code: public function podiumMoveTo($target = null)
      {
          $newParent = Forum::find()->where(['id' => $target])->limit(1)->one();
          if (empty($newParent)) {
              Log::error('No parent forum of given ID found', $this->id, __METHOD__);
              return false;
          }
  
          $postsCount = $this->postsCount;
          $transaction = Forum::getDb()->beginTransaction();
          try {
              $this->forum->updateCounters(['threads' => -1, 'posts' => -$postsCount]);
              $newParent->updateCounters(['threads' => 1, 'posts' => $postsCount]);
              $this->forum_id = $newParent->id;
              $this->category_id = $newParent->category_id;
              if (!$this->save()) {
                  throw new Exception('Thread saving error!');
              }
              Post::updateAll(['forum_id' => $newParent->id], ['thread_id' => $this->id]);
              $transaction->commit();
              PodiumCache::clearAfter('threadMove');
              Log::info('Thread moved', $this->id, __METHOD__);
              return true;
          } catch (Exception $e) {
              $transaction->rollBack();
              Log::error($e->getMessage(), null, __METHOD__);
          }
          return false;
      }
code_tokens: public function podiumMoveTo ( $ target = null ) { $ newParent = Forum :: find ( ) -> where ( [ 'id' => $ target ] ) -> limit ( 1 ) -> one ( ) ; if ( empty ( $ newParent ) ) { Log :: error ( 'No parent forum of given ID found' , $ this -> id , __METHOD__ ) ; return false ; } $ postsCount = $ this -> postsCount ; $ transaction = Forum :: getDb ( ) -> beginTransaction ( ) ; try { $ this -> forum -> updateCounters ( [ 'threads' => - 1 , 'posts' => - $ postsCount ] ) ; $ newParent -> updateCounters ( [ 'threads' => 1 , 'posts' => $ postsCount ] ) ; $ this -> forum_id = $ newParent -> id ; $ this -> category_id = $ newParent -> category_id ; if ( ! $ this -> save ( ) ) { throw new Exception ( 'Thread saving error!' ) ; } Post :: updateAll ( [ 'forum_id' => $ newParent -> id ] , [ 'thread_id' => $ this -> id ] ) ; $ transaction -> commit ( ) ; PodiumCache :: clearAfter ( 'threadMove' ) ; Log :: info ( 'Thread moved' , $ this -> id , __METHOD__ ) ; return true ; } catch ( Exception $ e ) { $ transaction -> rollBack ( ) ; Log :: error ( $ e -> getMessage ( ) , null , __METHOD__ ) ; } return false ; }
docstring: Performs thread move with counters update.
  @param int $target new parent forum's ID
  @return bool
  @since 0.2
docstring_tokens: Performs thread move with counters update .