View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0011916 | mantisbt | bugtracker | public | 2010-05-11 13:37 | 2014-09-23 18:05 |
| Reporter | japerez | Assigned To | dregad | ||
| Priority | normal | Severity | minor | Reproducibility | always |
| Status | closed | Resolution | fixed | ||
| Product Version | 1.2.1 | ||||
| Target Version | 1.2.9 | Fixed in Version | 1.2.9 | ||
| Summary | 0011916: List of user profiles not sorted alphabetically | ||||
| Description | There is another similar issue: 0010234 (http://www.mantisbt.org/bugs/view.php?id=10234) The issue was closed (0010234) work properly with global profiles, but when it comes to user profiles does not alphabetically. When is a comprehensive profile order is implemented by the sql statement, but when a user profile, the result is ordered by the PHP "asort ()" to merge the global profiles and user profiles. If we consider that the result is given by "select * from ..." the order applies depends on the first columns of the table (id, user_id, platform, ...). | ||||
| Steps To Reproduce |
| ||||
| Additional Information | Proposed solution: change the sql statement incorporating the most significant columns to sort the result at the beginning | ||||
| Tags | patch | ||||
| Attached Files | Fix-11916.patch (2,299 bytes)
From d28b1f731363df34596dd7ff3587aa88b498f9bd Mon Sep 17 00:00:00 2001
From: Damien Regad <damien.regad@merckgroup.com>
Date: Tue, 31 Jan 2012 16:05:48 +0100
Subject: [PATCH] Fix #11916: List of user profiles not sorted alphabetically
---
core/profile_api.php | 27 ++++++++++++++-------------
1 files changed, 14 insertions(+), 13 deletions(-)
diff --git a/core/profile_api.php b/core/profile_api.php
index f03e694..3faa3cb 100644
--- a/core/profile_api.php
+++ b/core/profile_api.php
@@ -68,7 +68,7 @@ function profile_create( $p_user_id, $p_platform, $p_os, $p_os_build, $p_descrip
return db_insert_id( $t_user_profile_table );
}
-/**
+/**
* Delete a profile for the user
*
* Note that although profile IDs are currently globally unique, the existing
@@ -190,18 +190,25 @@ function profile_get_row_direct( $p_profile_id ) {
/**
* Return an array containing all rows for a given user
* @param int $p_user_id
+ * @param bool $p_all_users Include profiles for all users
* @return array
*/
-function profile_get_all_rows( $p_user_id ) {
- $c_user_id = db_prepare_int( $p_user_id );
-
+function profile_get_all_rows( $p_user_id, $p_all_users = false ) {
$t_user_profile_table = db_get_table( 'mantis_user_profile_table' );
+ $query_where = 'user_id = ' . db_param();
+ $param[] = db_prepare_int( $p_user_id );
+
+ if( $p_all_users && ALL_USERS != $p_user_id ) {
+ $query_where .= ' OR user_id = ' . db_param();
+ $param[] = ALL_USERS;
+ }
+
$query = "SELECT *
FROM $t_user_profile_table
- WHERE user_id=" . db_param() . "
+ WHERE $query_where
ORDER BY platform, os, os_build";
- $result = db_query_bound( $query, Array( $c_user_id ) );
+ $result = db_query_bound( $query, $param );
$t_rows = array();
$t_row_count = db_num_rows( $result );
@@ -220,13 +227,7 @@ function profile_get_all_rows( $p_user_id ) {
* @return array
*/
function profile_get_all_for_user( $p_user_id ) {
- if( ALL_USERS == $p_user_id ) {
- return profile_get_all_rows( ALL_USERS );
- } else {
- $t_profiles_array = array_merge( profile_get_all_rows( ALL_USERS ), profile_get_all_rows( $p_user_id ) );
- asort( $t_profiles_array );
- return $t_profiles_array;
- }
+ return profile_get_all_rows( $p_user_id, $p_user_id != ALL_USERS );
}
/**
--
1.7.5.4
| ||||
|
one year later .... no comments ?? |
|
|
japerez, I apply your path. So, when I go to bug_report_page.php I get blank page. |
|
|
Please try attached patch |
|
|
Without feedback from you, I assume that you are satisfied with the fix. |
|
|
Marking as 'acknowledged' not resolved/closed to track that change gets ported to master-2.0.x branch |
|
|
MantisBT: master 6e1717a6 2012-01-31 02:05 Details Diff |
Fix 0011916: List of user profiles not sorted alphabetically A new, optional boolean parameter $p_all_users has been added to the profile_get_all_rows() function, to indicate whether it should return the list of profiles for the specified user only, or include also the profiles for all users. This allows simplification of profile_get_all_for_user() Conflicts: core/profile_api.php |
Affected Issues 0011916 |
|
| mod - core/profile_api.php | Diff File | ||
|
MantisBT: master-1.2.x 7caa1801 2012-01-31 02:05 Details Diff |
Fix 0011916: List of user profiles not sorted alphabetically A new, optional boolean parameter $p_all_users has been added to the profile_get_all_rows() function, to indicate whether it should return the list of profiles for the specified user only, or include also the profiles for all users. This allows simplification of profile_get_all_for_user() |
Affected Issues 0011916 |
|
| mod - core/profile_api.php | Diff File | ||