Changeset 1561:9ab4292a9cb0
- Timestamp:
- 08/24/13 14:52:27 (11 years ago)
- Branch:
- 2.5
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inc/core/class.dc.blog.php
r1545 r1561 207 207 public function triggerComments($ids, $del=false, $affected_posts=null) 208 208 { 209 $co_ids = dcUtils::cleanIds($ids); 210 $a_ids = dcUtils::cleanIds($affected_posts); 211 $a_tbs = array(); 209 $comments_ids = dcUtils::cleanIds($ids); 210 $affected_posts_ids = dcUtils::cleanIds($affected_posts); 211 $affected_is_trackback = 212 $counted_posts_ids = 213 $counted_is_trackback = 214 $counted_nb_comments = array(); 212 215 213 216 # a) Retrieve posts affected by comments edition 214 if (empty($a _ids)) {217 if (empty($affected_posts_ids)) { 215 218 $strReq = 216 219 'SELECT post_id, comment_trackback '. 217 220 'FROM '.$this->prefix.'comment '. 218 'WHERE comment_id'.$this->con->in($co _ids).221 'WHERE comment_id'.$this->con->in($comments_ids). 219 222 'GROUP BY post_id,comment_trackback'; 220 223 … … 222 225 223 226 while ($rs->fetch()) { 224 $a _ids[] = (integer) $rs->post_id;225 $a _tbs[] = (integer) $rs->comment_trackback;227 $affected_posts_ids[] = (integer) $rs->post_id; 228 $affected_is_trackback[] = (boolean) $rs->comment_trackback; 226 229 } 227 230 } … … 233 236 'FROM '.$this->prefix.'comment '. 234 237 'WHERE comment_status = 1 '. 235 (count($a _ids) > 0 ? 'AND post_id'.$this->con->in($a_ids) : ' ');238 (count($affected_posts_ids) > 0 ? 'AND post_id'.$this->con->in($affected_posts_ids) : ' '); 236 239 237 240 if ($del) { 238 241 $strReq .= 239 'AND comment_id NOT'.$this->con->in($co _ids);242 'AND comment_id NOT'.$this->con->in($comments_ids); 240 243 } 241 244 … … 245 248 $rs = $this->con->select($strReq); 246 249 247 $b_ids = $b_tbs = $b_nbs = array();248 250 while ($rs->fetch()) { 249 $ b_ids[] = (integer) $rs->post_id;250 $ b_tbs[] = (integer) $rs->comment_trackback;251 $ b_nbs[] = (integer) $rs->nb_comment;251 $counted_posts_ids[] = (integer) $rs->post_id; 252 $counted_is_trackback[] = (boolean) $rs->comment_trackback; 253 $counted_nb_comments[] = (integer) $rs->nb_comment; 252 254 } 253 255 … … 256 258 $cur = $this->con->openCursor($this->prefix.'post'); 257 259 258 foreach($a_ids as $a_key => $a_id) 259 { 260 foreach($affected_posts_ids as $affected_key => $affected_post_id) 261 { 262 if (!array_key_exists($affected_key, $affected_is_trackback)) { 263 $affected_is_trackback[$affected_key] = false; 264 } 260 265 $nb_comment = $nb_trackback = 0; 261 //$cur->nb_comment = $nb_comment;262 foreach($ b_ids as $b_key => $b_id)266 267 foreach($counted_posts_ids as $counted_key => $counted_post_id) 263 268 { 264 if ($a_id != $b_id || $a_tbs[$a_key] != $b_tbs[$b_key]) { 269 if ($affected_post_id != $counted_post_id 270 || $affected_is_trackback[$affected_key] != $counted_is_trackback[$counted_key]) { 265 271 continue; 266 272 } 267 273 268 if ($ b_tbs[$b_key]) {269 $nb_trackback = $ b_nbs[$b_key];274 if ($counted_is_trackback[$counted_key]) { 275 $nb_trackback = $counted_nb_comments[$counted_key]; 270 276 } else { 271 $nb_comment = $ b_nbs[$b_key];277 $nb_comment = $counted_nb_comments[$counted_key]; 272 278 } 273 279 } 274 280 275 if ($a _tbs[$a_key]) {281 if ($affected_is_trackback[$affected_key]) { 276 282 $cur->nb_trackback = $nb_trackback; 277 283 } else { 278 284 $cur->nb_comment = $nb_comment; 279 285 } 280 $cur->update('WHERE post_id = '.$a_id); 286 287 $cur->update('WHERE post_id = '.$affected_post_id); 288 $cur->clean(); 281 289 } 282 290 }
Note: See TracChangeset
for help on using the changeset viewer.