Dotclear

Changeset 1262:ec1e7bef6c1f


Ignore:
Timestamp:
08/03/13 15:04:24 (11 years ago)
Author:
Denis Jean-Christian <contact@…>
Branch:
2.5
Children:
1263:c4b456fb9af8, 1265:15b5a80a48a1, 1441:fb59f706335a, 1542:2de80618299a
Message:

Fix post comments number on comments deletion, fixes #1401, thanks sogos/sogox for patch and tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inc/core/class.dc.blog.php

    r1261 r1262  
    203203     @param    ids       <b>mixed</b>        Comment(s) ID(s) 
    204204     @param    del       <b>boolean</b>      If comment is delete, set this to true 
    205      */ 
    206      public function triggerComments($ids,$del=false) 
     205     @param    affected_posts      <b>mixed</b>        Posts(s) ID(s) 
     206     */ 
     207     public function triggerComments($ids, $del=false, $affected_posts=null) 
    207208     { 
    208209          $co_ids = dcUtils::cleanIds($ids); 
     210          $a_ids = dcUtils::cleanIds($affected_posts); 
     211          $a_tbs = array(); 
    209212           
    210213          # a) Retrieve posts affected by comments edition 
    211           $strReq =  
    212                'SELECT post_id, comment_trackback '. 
    213                'FROM '.$this->prefix.'comment '. 
    214                'WHERE comment_id'.$this->con->in($co_ids). 
    215                'GROUP BY post_id,comment_trackback'; 
    216            
    217           $rs = $this->con->select($strReq); 
    218            
    219           $a_ids = $a_tbs = array(); 
    220           while ($rs->fetch()) { 
    221                $a_ids[] = (integer) $rs->post_id; 
    222                $a_tbs[] = (integer) $rs->comment_trackback; 
     214          if (empty($a_ids)) { 
     215               $strReq =  
     216                    'SELECT post_id, comment_trackback '. 
     217                    'FROM '.$this->prefix.'comment '. 
     218                    'WHERE comment_id'.$this->con->in($co_ids). 
     219                    'GROUP BY post_id,comment_trackback'; 
     220                
     221               $rs = $this->con->select($strReq); 
     222                
     223               while ($rs->fetch()) { 
     224                    $a_ids[] = (integer) $rs->post_id; 
     225                    $a_tbs[] = (integer) $rs->comment_trackback; 
     226               } 
    223227          } 
    224228           
     
    255259          { 
    256260               $nb_comment = $nb_trackback = 0; 
     261               //$cur->nb_comment = $nb_comment; 
    257262               foreach($b_ids as $b_key => $b_id) 
    258263               { 
     
    21872192          $co_ids = dcUtils::cleanIds($ids); 
    21882193           
    2189           if (empty($ids)) { 
     2194          if (empty($co_ids)) { 
    21902195               throw new Exception(__('No such comment ID')); 
     2196          } 
     2197           
     2198          # Retrieve posts affected by comments edition 
     2199          $affected_posts = array(); 
     2200          $strReq = 
     2201               'SELECT distinct(post_id) '. 
     2202               'FROM '.$this->prefix.'comment '. 
     2203               'WHERE comment_id'.$this->con->in($co_ids); 
     2204           
     2205          $rs = $this->con->select($strReq); 
     2206           
     2207          while ($rs->fetch()) { 
     2208               $affected_posts[] = (integer) $rs->post_id; 
    21912209          } 
    21922210           
     
    22182236           
    22192237          $this->con->execute($strReq); 
    2220           $this->triggerComments($co_ids,true); 
     2238          $this->triggerComments($co_ids, true, $affected_posts); 
    22212239          $this->triggerBlog(); 
    22222240     } 
Note: See TracChangeset for help on using the changeset viewer.

Sites map