summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKoosha Khajeh Moogahi <koosha.khajeh@gmail.com>2012-07-30 02:57:50 +0200
committerFrédéric Buclin <LpSolit@gmail.com>2012-07-30 02:57:50 +0200
commit4e1e44eab9604fd0d981758b44dc0a8f31ba7b88 (patch)
tree7e0ae83ec8b6d766b748494c0da2fadade23a570
parent2e617ed0f590e428991f4bdbdb1acc2da468fe98 (diff)
downloadbugzilla-4e1e44eab9604fd0d981758b44dc0a8f31ba7b88.tar.gz
bugzilla-4e1e44eab9604fd0d981758b44dc0a8f31ba7b88.tar.xz
Bug 498890: Bugzilla::User::Setting doesn't need to sort DB results
r/a=LpSolit
-rw-r--r--Bugzilla/User/Setting.pm25
1 files changed, 10 insertions, 15 deletions
diff --git a/Bugzilla/User/Setting.pm b/Bugzilla/User/Setting.pm
index 2f5870d69..6fadfb352 100644
--- a/Bugzilla/User/Setting.pm
+++ b/Bugzilla/User/Setting.pm
@@ -154,21 +154,18 @@ sub add_setting {
sub get_all_settings {
my ($user_id) = @_;
- my $settings = get_defaults($user_id); # first get the defaults
+ my $settings = {};
my $dbh = Bugzilla->dbh;
- my $sth = $dbh->prepare(
+ my $rows = $dbh->selectall_arrayref(
q{SELECT name, default_value, is_enabled, setting_value, subclass
FROM setting
LEFT JOIN profile_setting
ON setting.name = profile_setting.setting_name
- WHERE profile_setting.user_id = ?
- ORDER BY name});
+ AND profile_setting.user_id = ?}, undef, ($user_id));
- $sth->execute($user_id);
- while (my ($name, $default_value, $is_enabled, $value, $subclass)
- = $sth->fetchrow_array())
- {
+ foreach my $row (@$rows) {
+ my ($name, $default_value, $is_enabled, $value, $subclass) = @$row;
my $is_default;
@@ -194,13 +191,11 @@ sub get_defaults {
$user_id ||= 0;
- my $sth = $dbh->prepare(q{SELECT name, default_value, is_enabled, subclass
- FROM setting
- ORDER BY name});
- $sth->execute();
- while (my ($name, $default_value, $is_enabled, $subclass)
- = $sth->fetchrow_array())
- {
+ my $rows = $dbh->selectall_arrayref(q{SELECT name, default_value, is_enabled, subclass
+ FROM setting});
+
+ foreach my $row (@$rows) {
+ my ($name, $default_value, $is_enabled, $subclass) = @$row;
$default_settings->{$name} = new Bugzilla::User::Setting(
$name, $user_id, $is_enabled, $default_value, $default_value, 1,