summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Search
diff options
context:
space:
mode:
authorDave Lawrence <dlawrence@mozilla.com>2012-01-09 21:56:14 +0100
committerDave Lawrence <dlawrence@mozilla.com>2012-01-09 21:56:14 +0100
commit0c449e2d96804f6e48d3812b42ccf407fbbeb747 (patch)
treedfdd8c56789ff02c925b5b55e11faf890f1ecd98 /Bugzilla/Search
parentddf1fb2abb2a6266ce5a9cc525c84563c154df52 (diff)
parenta7785661b8e7dcb7a6914eebf1a11fd99f1cf037 (diff)
downloadbugzilla-0c449e2d96804f6e48d3812b42ccf407fbbeb747.tar.gz
bugzilla-0c449e2d96804f6e48d3812b42ccf407fbbeb747.tar.xz
merge with bugzilla/4.2
Diffstat (limited to 'Bugzilla/Search')
-rw-r--r--Bugzilla/Search/Recent.pm14
1 files changed, 8 insertions, 6 deletions
diff --git a/Bugzilla/Search/Recent.pm b/Bugzilla/Search/Recent.pm
index 89d9cf6ff..ccd4a0f09 100644
--- a/Bugzilla/Search/Recent.pm
+++ b/Bugzilla/Search/Recent.pm
@@ -57,14 +57,16 @@ sub create {
my $class = shift;
my $dbh = Bugzilla->dbh;
$dbh->bz_start_transaction();
- my $search = $class->SUPER::create(@_);
+ my $search = $class->SUPER::create(@_);
+ my $user_id = $search->user_id;
# Enforce there only being SAVE_NUM_SEARCHES per user.
- my ($num_searches, $min_id) = $dbh->selectrow_array(
- 'SELECT COUNT(*), MIN(id) FROM profile_search WHERE user_id = ?',
- undef, $search->user_id);
- if ($num_searches > SAVE_NUM_SEARCHES) {
- $dbh->do('DELETE FROM profile_search WHERE id = ?', undef, $min_id);
+ my $min_id = $dbh->selectrow_array(
+ 'SELECT id FROM profile_search WHERE user_id = ? ORDER BY id DESC '
+ . $dbh->sql_limit(1, SAVE_NUM_SEARCHES), undef, $user_id);
+ if ($min_id) {
+ $dbh->do('DELETE FROM profile_search WHERE user_id = ? AND id <= ?',
+ undef, ($user_id, $min_id));
}
$dbh->bz_commit_transaction();
return $search;