Commit 4e1e44ea authored by Koosha Khajeh Moogahi's avatar Koosha Khajeh Moogahi Committed by Frédéric Buclin

Bug 498890: Bugzilla::User::Setting doesn't need to sort DB results

r/a=LpSolit
parent 2e617ed0
...@@ -154,21 +154,18 @@ sub add_setting { ...@@ -154,21 +154,18 @@ sub add_setting {
sub get_all_settings { sub get_all_settings {
my ($user_id) = @_; my ($user_id) = @_;
my $settings = get_defaults($user_id); # first get the defaults my $settings = {};
my $dbh = Bugzilla->dbh; my $dbh = Bugzilla->dbh;
my $sth = $dbh->prepare( my $rows = $dbh->selectall_arrayref(
q{SELECT name, default_value, is_enabled, setting_value, subclass q{SELECT name, default_value, is_enabled, setting_value, subclass
FROM setting FROM setting
LEFT JOIN profile_setting LEFT JOIN profile_setting
ON setting.name = profile_setting.setting_name ON setting.name = profile_setting.setting_name
WHERE profile_setting.user_id = ? AND profile_setting.user_id = ?}, undef, ($user_id));
ORDER BY name});
$sth->execute($user_id); foreach my $row (@$rows) {
while (my ($name, $default_value, $is_enabled, $value, $subclass) my ($name, $default_value, $is_enabled, $value, $subclass) = @$row;
= $sth->fetchrow_array())
{
my $is_default; my $is_default;
...@@ -194,13 +191,11 @@ sub get_defaults { ...@@ -194,13 +191,11 @@ sub get_defaults {
$user_id ||= 0; $user_id ||= 0;
my $sth = $dbh->prepare(q{SELECT name, default_value, is_enabled, subclass my $rows = $dbh->selectall_arrayref(q{SELECT name, default_value, is_enabled, subclass
FROM setting FROM setting});
ORDER BY name});
$sth->execute(); foreach my $row (@$rows) {
while (my ($name, $default_value, $is_enabled, $subclass) my ($name, $default_value, $is_enabled, $subclass) = @$row;
= $sth->fetchrow_array())
{
$default_settings->{$name} = new Bugzilla::User::Setting( $default_settings->{$name} = new Bugzilla::User::Setting(
$name, $user_id, $is_enabled, $default_value, $default_value, 1, $name, $user_id, $is_enabled, $default_value, $default_value, 1,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment