original_string: public function GetCommentCounts() {
        $this->AllowJSONP(TRUE);
        
  		$vanilla_identifier = GetValue('vanilla_identifier', $_GET);
  		if (!is_array($vanilla_identifier))
  			$vanilla_identifier = array($vanilla_identifier);
           
        $vanilla_identifier = array_unique($vanilla_identifier);
        
        $FinalData = array_fill_keys($vanilla_identifier, 0);
        $Misses = array();
        $CacheKey = 'embed.comments.count.%s';
        $OriginalIDs = array();
        foreach ($vanilla_identifier as $ForeignID) {
           $HashedForeignID = ForeignIDHash($ForeignID);
           
           // Keep record of non-hashed identifiers for the reply
           $OriginalIDs[$HashedForeignID] = $ForeignID;
           
           $RealCacheKey = sprintf($CacheKey, $HashedForeignID);
           $Comments = Gdn::Cache()->Get($RealCacheKey);
           if ($Comments !== Gdn_Cache::CACHEOP_FAILURE)
              $FinalData[$ForeignID] = $Comments;
           else
              $Misses[] = $HashedForeignID;
        }
        
        if (sizeof($Misses)) {
           $CountData = Gdn::SQL()
              ->Select('ForeignID, CountComments')
              ->From('Discussion')
              ->Where('Type', 'page')
              ->WhereIn('ForeignID', $Misses)
              ->Get()->ResultArray();
           
           foreach ($CountData as $Row) {
              // Get original identifier to send back
              $ForeignID = $OriginalIDs[$Row['ForeignID']];
              $FinalData[$ForeignID] = $Row['CountComments'];
              
              // Cache using the hashed identifier
              $RealCacheKey = sprintf($CacheKey, $Row['ForeignID']);
              Gdn::Cache()->Store($RealCacheKey, $Row['CountComments'], array(
                 Gdn_Cache::FEATURE_EXPIRY     => 60
              ));
           }         
        }
        
  		$this->SetData('CountData', $FinalData);
  		$this->DeliveryMethod = DELIVERY_METHOD_JSON;
  		$this->DeliveryType = DELIVERY_TYPE_DATA;
  		$this->Render();
  	}
code: public function GetCommentCounts() {
        $this->AllowJSONP(TRUE);
        
  		$vanilla_identifier = GetValue('vanilla_identifier', $_GET);
  		if (!is_array($vanilla_identifier))
  			$vanilla_identifier = array($vanilla_identifier);
           
        $vanilla_identifier = array_unique($vanilla_identifier);
        
        $FinalData = array_fill_keys($vanilla_identifier, 0);
        $Misses = array();
        $CacheKey = 'embed.comments.count.%s';
        $OriginalIDs = array();
        foreach ($vanilla_identifier as $ForeignID) {
           $HashedForeignID = ForeignIDHash($ForeignID);
           
           // Keep record of non-hashed identifiers for the reply
           $OriginalIDs[$HashedForeignID] = $ForeignID;
           
           $RealCacheKey = sprintf($CacheKey, $HashedForeignID);
           $Comments = Gdn::Cache()->Get($RealCacheKey);
           if ($Comments !== Gdn_Cache::CACHEOP_FAILURE)
              $FinalData[$ForeignID] = $Comments;
           else
              $Misses[] = $HashedForeignID;
        }
        
        if (sizeof($Misses)) {
           $CountData = Gdn::SQL()
              ->Select('ForeignID, CountComments')
              ->From('Discussion')
              ->Where('Type', 'page')
              ->WhereIn('ForeignID', $Misses)
              ->Get()->ResultArray();
           
           foreach ($CountData as $Row) {
              // Get original identifier to send back
              $ForeignID = $OriginalIDs[$Row['ForeignID']];
              $FinalData[$ForeignID] = $Row['CountComments'];
              
              // Cache using the hashed identifier
              $RealCacheKey = sprintf($CacheKey, $Row['ForeignID']);
              Gdn::Cache()->Store($RealCacheKey, $Row['CountComments'], array(
                 Gdn_Cache::FEATURE_EXPIRY     => 60
              ));
           }         
        }
        
  		$this->SetData('CountData', $FinalData);
  		$this->DeliveryMethod = DELIVERY_METHOD_JSON;
  		$this->DeliveryType = DELIVERY_TYPE_DATA;
  		$this->Render();
  	}
code_tokens: public function GetCommentCounts ( ) { $ this -> AllowJSONP ( TRUE ) ; $ vanilla_identifier = GetValue ( 'vanilla_identifier' , $ _GET ) ; if ( ! is_array ( $ vanilla_identifier ) ) $ vanilla_identifier = array ( $ vanilla_identifier ) ; $ vanilla_identifier = array_unique ( $ vanilla_identifier ) ; $ FinalData = array_fill_keys ( $ vanilla_identifier , 0 ) ; $ Misses = array ( ) ; $ CacheKey = 'embed.comments.count.%s' ; $ OriginalIDs = array ( ) ; foreach ( $ vanilla_identifier as $ ForeignID ) { $ HashedForeignID = ForeignIDHash ( $ ForeignID ) ; // Keep record of non-hashed identifiers for the reply $ OriginalIDs [ $ HashedForeignID ] = $ ForeignID ; $ RealCacheKey = sprintf ( $ CacheKey , $ HashedForeignID ) ; $ Comments = Gdn :: Cache ( ) -> Get ( $ RealCacheKey ) ; if ( $ Comments !== Gdn_Cache :: CACHEOP_FAILURE ) $ FinalData [ $ ForeignID ] = $ Comments ; else $ Misses [ ] = $ HashedForeignID ; } if ( sizeof ( $ Misses ) ) { $ CountData = Gdn :: SQL ( ) -> Select ( 'ForeignID, CountComments' ) -> From ( 'Discussion' ) -> Where ( 'Type' , 'page' ) -> WhereIn ( 'ForeignID' , $ Misses ) -> Get ( ) -> ResultArray ( ) ; foreach ( $ CountData as $ Row ) { // Get original identifier to send back $ ForeignID = $ OriginalIDs [ $ Row [ 'ForeignID' ] ] ; $ FinalData [ $ ForeignID ] = $ Row [ 'CountComments' ] ; // Cache using the hashed identifier $ RealCacheKey = sprintf ( $ CacheKey , $ Row [ 'ForeignID' ] ) ; Gdn :: Cache ( ) -> Store ( $ RealCacheKey , $ Row [ 'CountComments' ] , array ( Gdn_Cache :: FEATURE_EXPIRY => 60 ) ) ; } } $ this -> SetData ( 'CountData' , $ FinalData ) ; $ this -> DeliveryMethod = DELIVERY_METHOD_JSON ; $ this -> DeliveryType = DELIVERY_TYPE_DATA ; $ this -> Render ( ) ; }
docstring: Takes a set of discussion identifiers and returns their comment counts in the same order.
docstring_tokens: Takes a set of discussion identifiers and returns their comment counts in the same order .