diff options
author | mkanat%bugzilla.org <> | 2008-09-06 06:01:18 +0200 |
---|---|---|
committer | mkanat%bugzilla.org <> | 2008-09-06 06:01:18 +0200 |
commit | 28618aea558de167f80674a9bf65f865f63e0887 (patch) | |
tree | e2e90ca594b269f5be0e16224cb1c56711d29db3 /Bugzilla/User | |
parent | 6780793ba0102441cda056c0a6c9dcfbc3867d6d (diff) | |
download | bugzilla-28618aea558de167f80674a9bf65f865f63e0887.tar.gz bugzilla-28618aea558de167f80674a9bf65f865f63e0887.tar.xz |
Bug 364161: Inefficient SQL: Selecting subclass from setting table
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=LpSolit, a=LpSolit
Diffstat (limited to 'Bugzilla/User')
-rw-r--r-- | Bugzilla/User/Setting.pm | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/Bugzilla/User/Setting.pm b/Bugzilla/User/Setting.pm index f13bfe972..7a6c72fd3 100644 --- a/Bugzilla/User/Setting.pm +++ b/Bugzilla/User/Setting.pm @@ -99,15 +99,12 @@ sub new { } } else { - ($subclass) = $dbh->selectrow_array( - q{SELECT subclass FROM setting WHERE name = ?}, - undef, - $setting_name); # If the values were passed in, simply assign them and return. $self->{'is_enabled'} = shift; $self->{'default_value'} = shift; $self->{'value'} = shift; $self->{'is_default'} = shift; + $subclass = shift; } if ($subclass) { eval('require ' . $class . '::' . $subclass); @@ -172,7 +169,7 @@ sub get_all_settings { my $dbh = Bugzilla->dbh; my $sth = $dbh->prepare( - q{SELECT name, default_value, is_enabled, setting_value + q{SELECT name, default_value, is_enabled, setting_value, subclass FROM setting LEFT JOIN profile_setting ON setting.name = profile_setting.setting_name @@ -180,8 +177,9 @@ sub get_all_settings { ORDER BY name}); $sth->execute($user_id); - while (my ($name, $default_value, $is_enabled, $value) - = $sth->fetchrow_array()) { + while (my ($name, $default_value, $is_enabled, $value, $subclass) + = $sth->fetchrow_array()) + { my $is_default; @@ -194,7 +192,7 @@ sub get_all_settings { $settings->{$name} = new Bugzilla::User::Setting( $name, $user_id, $is_enabled, - $default_value, $value, $is_default); + $default_value, $value, $is_default, $subclass); } return $settings; @@ -207,14 +205,17 @@ sub get_defaults { $user_id ||= 0; - my $sth = $dbh->prepare(q{SELECT name, default_value, is_enabled + 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) = $sth->fetchrow_array()) { + while (my ($name, $default_value, $is_enabled, $subclass) + = $sth->fetchrow_array()) + { $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, + $subclass); } return $default_settings; |