Changeset 6596


Ignore:
Timestamp:
Jun 24, 2010, 8:36:24 PM (14 years ago)
Author:
nikrou
Message:

Bug 1735 fixed : 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.

Fixed also problem of FROM_UNIXTIME function not POstgreSQL compatible.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/comments.php

    r6363 r6596  
    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
    371     INNER JOIN '.COMMENTS_TABLE.' AS com
     370    LEFT JOIN '.COMMENTS_TABLE.' AS com
    372371    ON ic.image_id = com.image_id
    373372    LEFT JOIN '.USERS_TABLE.' As u
     
    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
    414421;';
    415   $categories = hash_from_query($query, 'id');
     422  $categories = hash_from_query($query, 'comment_id');
    416423
    417424  foreach ($comments as $comment)
     
    432439    $url = make_picture_url(
    433440      array(
    434         'category' => $categories[ $comment['category_id'] ],
     441        'category' => $categories[ $comment['comment_id'] ],
    435442        'image_id' => $comment['image_id'],
    436443        'image_file' => $elements[$comment['image_id']]['file'],
  • trunk/include/functions_comment.inc.php

    r6589 r6596  
    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.