Changeset 6602


Ignore:
Timestamp:
06/24/10 22:35:46 (8 years ago)
Author:
nikrou
Message:

Bug 1735 fixed : merge from trunk
Comment page is not PostgreSQL compatible
Fixed by adding all fields except category_id in group by clause
category_id is retrieved later in an another query (with permissions filter)

Fixed also problem of FROM_UNIXTIME function not POstgreSQL compatible

Location:
branches/2.1
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/2.1/comments.php

    r6364 r6602  
    360360 
    361361$query = ' 
    362 SELECT com.id AS comment_id 
    363      , com.image_id 
    364      , ic.category_id 
    365      , com.author 
    366      , com.author_id 
    367      , com.date 
    368      , com.content 
    369      , com.validated 
     362SELECT com.id AS comment_id, 
     363       com.image_id, 
     364       com.author, 
     365       com.author_id, 
     366       com.date, 
     367       com.content, 
     368       com.validated 
    370369  FROM '.IMAGE_CATEGORY_TABLE.' AS ic 
    371370    INNER JOIN '.COMMENTS_TABLE.' AS com 
     
    375374  WHERE '.implode(' 
    376375    AND ', $page['where_clauses']).' 
    377   GROUP BY comment_id 
     376  GROUP BY comment_id, 
     377       com.image_id, 
     378       com.author, 
     379       com.author_id, 
     380       com.date, 
     381       com.content, 
     382       com.validated 
    378383  ORDER BY '.$page['sort_by'].' '.$page['sort_order']; 
    379384if ('all' != $page['items_number']) 
     
    389394  array_push($comments, $row); 
    390395  array_push($element_ids, $row['image_id']); 
    391   array_push($category_ids, $row['category_id']); 
    392396} 
    393397 
     
    409413  // retrieving category informations 
    410414  $query = ' 
    411 SELECT id, name, permalink, uppercats 
    412   FROM '.CATEGORIES_TABLE.' 
    413   WHERE id IN ('.implode(',', $category_ids).') 
     415SELECT c.id, name, permalink, uppercats, com.id as comment_id 
     416  FROM '.CATEGORIES_TABLE.' AS c 
     417  LEFT JOIN '.IMAGE_CATEGORY_TABLE.' AS ic 
     418  ON c.id=ic.category_id 
     419  LEFT JOIN '.COMMENTS_TABLE.' AS com 
     420  ON ic.image_id=com.image_id 
     421  '.get_sql_condition_FandF 
     422    ( 
     423      array 
     424      ( 
     425        'forbidden_categories' => 'c.id', 
     426        'visible_categories' => 'c.id' 
     427       ), 
     428      'WHERE' 
     429     ).' 
    414430;'; 
    415   $categories = hash_from_query($query, 'id'); 
     431  $categories = hash_from_query($query, 'comment_id'); 
    416432 
    417433  foreach ($comments as $comment) 
     
    432448    $url = make_picture_url( 
    433449      array( 
    434         'category' => $categories[ $comment['category_id'] ], 
     450        'category' => $categories[ $comment['comment_id'] ], 
    435451        'image_id' => $comment['image_id'], 
    436452        'image_file' => $elements[$comment['image_id']]['file'], 
  • branches/2.1/include/functions_comment.inc.php

    r6590 r6602  
    134134  if ($comment_action!='reject' and $conf['anti-flood_time']>0 ) 
    135135  { // anti-flood system 
    136     $reference_date = time() - $conf['anti-flood_time']; 
     136    $reference_date = date('c', time() - $conf['anti-flood_time']); 
    137137    $query = ' 
    138138SELECT id FROM '.COMMENTS_TABLE.' 
    139   WHERE date > FROM_UNIXTIME('.$reference_date.') 
     139  WHERE date > \''.$reference_date.'\' 
    140140    AND author_id = '.$comm['author_id']; 
    141141    if ( pwg_db_num_rows( pwg_query( $query ) ) > 0 ) 
Note: See TracChangeset for help on using the changeset viewer.