svn: /web/php-bugs/trunk/include/ query.php

From: Date: Wed, 10 Nov 2010 10:31:03 +0000
Subject: svn: /web/php-bugs/trunk/include/ query.php
Groups: php.webmaster 
Request: Send a blank email to php-webmaster+get-9401@lists.php.net to get a copy of this message
aharvey Wed, 10 Nov 2010 10:31:03 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=305241 Log: Fix bug #52472 (Bug tracker relevance sort doesn't work). Based (loosely) on a patch by Ben Schmidt. Bug: http://bugs.php.net/52472 (Open) Bug tracker relevance sort doesn't work Changed paths: U web/php-bugs/trunk/include/query.php Modified: web/php-bugs/trunk/include/query.php =================================================================== --- web/php-bugs/trunk/include/query.php 2010-11-10 09:46:15 UTC (rev 305240) +++ web/php-bugs/trunk/include/query.php 2010-11-10 10:31:03 UTC (rev 305241) @@ -38,7 +38,7 @@ $limit = ($_GET['limit'] == 'All') ? 'All' : (($_GET['limit'] > 0) ? (int) $_GET['limit'] : $limit); } $direction = (!empty($_GET['direction']) && $_GET['direction'] != 'DESC') ? 'ASC' : 'DESC'; -$order_by = (!empty($_GET['order_by']) && array_key_exists($_GET['order_by'], $order_options)) ? $_GET['order_by'] : 'id'; +$order_by = (!empty($_GET['order_by']) && array_key_exists($_GET['order_by'], $order_options)) ? $_GET['order_by'] : ''; $reorder_by = (!empty($_GET['reorder_by']) && array_key_exists($_GET['reorder_by'], $order_options)) ? $_GET['reorder_by'] : ''; $assign = !empty($_GET['assign']) ? $_GET['assign'] : ''; $author_email = (!empty($_GET['author_email']) && is_valid_email($_GET['author_email'])) ? $_GET['author_email'] : ''; @@ -189,26 +189,33 @@ } } + $order_by_clauses = array(); if (in_array($order_by, array('votes_count', 'avg_score'))) { $query .= ' GROUP BY bugdb.id'; switch ($order_by) { case 'avg_score': - $query .= " ORDER BY IFNULL(AVG(v.score), 0)+3 $direction, COUNT(v.bug) DESC"; + $order_by_clauses = array( + "IFNULL(AVG(v.score), 0)+3 $direction", + "COUNT(v.bug) DESC" + ); break; case 'votes_count': - $query .= " ORDER BY COUNT(v.bug) $direction"; + $order_by_clauses = array("COUNT(v.bug) $direction"); break; } - } else { - $query .= " ORDER BY $order_by $direction"; + } elseif ($order_by != '') { + $order_by_clauses = array("$order_by $direction"); } - - // if status Feedback then sort also after last updated time. + if ($status == 'Feedback') { - $query .= ", bugdb.ts2 $direction"; + $order_by_clauses[] = "bugdb.ts2 $direction"; } + if (count($order_by_clauses)) { + $query .= ' ORDER BY ' . implode(', ', $order_by_clauses); + } + if ($limit != 'All' && $limit > 0) { $query .= " LIMIT $begin, $limit"; }

« previous php.webmaster (#9401) next »