Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
bugzilla
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ivan Ivlev
bugzilla
Commits
3941c84b
Commit
3941c84b
authored
May 14, 2007
by
lpsolit%gmail.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 379918: Replace ListIDsForEmail() with subselect - Patch by Joel Peshkin…
Bug 379918: Replace ListIDsForEmail() with subselect - Patch by Joel Peshkin <bugreport@peshkin.net> r/a=mkanat
parent
abe6664a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
109 deletions
+18
-109
Search.pm
Bugzilla/Search.pm
+18
-109
No files found.
Bugzilla/Search.pm
View file @
3941c84b
...
@@ -451,14 +451,11 @@ sub init {
...
@@ -451,14 +451,11 @@ sub init {
$term
=
"bugs.$f <> "
.
pronoun
(
$1
,
$user
);
$term
=
"bugs.$f <> "
.
pronoun
(
$1
,
$user
);
},
},
"^(assigned_to|reporter),(?!changed)"
=>
sub
{
"^(assigned_to|reporter),(?!changed)"
=>
sub
{
my
$list
=
$self
->
ListIDsForEmail
(
$t
,
$v
);
my
$real_f
=
$f
;
if
(
$list
)
{
$f
=
"login_name"
;
$term
=
"bugs.$f IN ($list)"
;
$ff
=
"profiles.login_name"
;
}
else
{
$funcsbykey
{
",$t"
}
->
();
push
(
@supptables
,
"INNER JOIN profiles AS map_$f "
.
$term
=
"bugs.$real_f IN (SELECT userid FROM profiles WHERE $term)"
;
"ON bugs.$f = map_$f.userid"
);
$f
=
"map_$f.login_name"
;
}
},
},
"^qa_contact,(?!changed)"
=>
sub
{
"^qa_contact,(?!changed)"
=>
sub
{
push
(
@supptables
,
"LEFT JOIN profiles AS map_qa_contact "
.
push
(
@supptables
,
"LEFT JOIN profiles AS map_qa_contact "
.
...
@@ -518,49 +515,21 @@ sub init {
...
@@ -518,49 +515,21 @@ sub init {
"AND cc_$chartseq.who = $match"
);
"AND cc_$chartseq.who = $match"
);
$term
=
"cc_$chartseq.who IS NULL"
;
$term
=
"cc_$chartseq.who IS NULL"
;
},
},
"^cc,(anyexact|substring|regexp)"
=>
sub
{
my
$list
;
$list
=
$self
->
ListIDsForEmail
(
$t
,
$v
);
my
$chartseq
=
$chartid
;
if
(
$chartid
eq
""
)
{
$chartseq
=
"CC$sequence"
;
$sequence
++
;
}
if
(
$list
)
{
push
(
@supptables
,
"LEFT JOIN cc AS cc_$chartseq "
.
"ON bugs.bug_id = cc_$chartseq.bug_id "
.
"AND cc_$chartseq.who IN($list)"
);
$term
=
"cc_$chartseq.who IS NOT NULL"
;
}
else
{
push
(
@supptables
,
"LEFT JOIN cc AS cc_$chartseq "
.
"ON bugs.bug_id = cc_$chartseq.bug_id"
);
push
(
@supptables
,
"LEFT JOIN profiles AS map_cc_$chartseq "
.
"ON cc_$chartseq.who = map_cc_$chartseq.userid"
);
$ff
=
$f
=
"map_cc_$chartseq.login_name"
;
my
$ref
=
$funcsbykey
{
",$t"
};
&
$ref
;
}
},
"^cc,(?!changed)"
=>
sub
{
"^cc,(?!changed)"
=>
sub
{
my
$chartseq
=
$chartid
;
my
$chartseq
=
$chartid
;
if
(
$chartid
eq
""
)
{
if
(
$chartid
eq
""
)
{
$chartseq
=
"CC$sequence"
;
$chartseq
=
"CC$sequence"
;
$sequence
++
;
$sequence
++
;
}
}
$f
=
"login_name"
;
$ff
=
"profiles.login_name"
;
$funcsbykey
{
",$t"
}
->
();
push
(
@supptables
,
"LEFT JOIN cc AS cc_$chartseq "
.
push
(
@supptables
,
"LEFT JOIN cc AS cc_$chartseq "
.
"ON bugs.bug_id = cc_$chartseq.bug_id"
);
"ON bugs.bug_id = cc_$chartseq.bug_id "
.
"AND cc_$chartseq.who IN"
.
$ff
=
$f
=
"map_cc_$chartseq.login_name"
;
"(SELECT userid FROM profiles WHERE $term)"
my
$ref
=
$funcsbykey
{
",$t"
};
&
$ref
;
push
(
@supptables
,
"LEFT JOIN profiles AS map_cc_$chartseq "
.
"ON (cc_$chartseq.who = map_cc_$chartseq.userid "
.
"AND ($term))"
);
);
$term
=
"$f
IS NOT NULL"
;
$term
=
"cc_$chartseq.who
IS NOT NULL"
;
},
},
"^long_?desc,changedby"
=>
sub
{
"^long_?desc,changedby"
=>
sub
{
...
@@ -668,8 +637,6 @@ sub init {
...
@@ -668,8 +637,6 @@ sub init {
},
},
"^commenter,"
=>
sub
{
"^commenter,"
=>
sub
{
my
$chartseq
=
$chartid
;
my
$chartseq
=
$chartid
;
my
$list
;
$list
=
$self
->
ListIDsForEmail
(
$t
,
$v
);
if
(
$chartid
eq
""
)
{
if
(
$chartid
eq
""
)
{
$chartseq
=
"LD$sequence"
;
$chartseq
=
"LD$sequence"
;
$sequence
++
;
$sequence
++
;
...
@@ -681,20 +648,15 @@ sub init {
...
@@ -681,20 +648,15 @@ sub init {
{
{
$extra
=
"AND $table.isprivate < 1"
;
$extra
=
"AND $table.isprivate < 1"
;
}
}
if
(
$list
)
{
$f
=
"login_name"
;
$ff
=
"profiles.login_name"
;
$funcsbykey
{
",$t"
}
->
();
push
(
@supptables
,
"LEFT JOIN longdescs AS $table "
.
push
(
@supptables
,
"LEFT JOIN longdescs AS $table "
.
"ON $table.bug_id = bugs.bug_id $extra "
.
"ON $table.bug_id = bugs.bug_id $extra "
.
"AND $table.who IN ($list)"
);
"AND $table.who IN"
.
"(SELECT userid FROM profiles WHERE $term)"
);
$term
=
"$table.who IS NOT NULL"
;
$term
=
"$table.who IS NOT NULL"
;
}
else
{
push
(
@supptables
,
"LEFT JOIN longdescs AS $table "
.
"ON $table.bug_id = bugs.bug_id $extra"
);
push
(
@supptables
,
"LEFT JOIN profiles AS map_$table "
.
"ON $table.who = map_$table.userid"
);
$ff
=
$f
=
"map_$table.login_name"
;
my
$ref
=
$funcsbykey
{
",$t"
};
&
$ref
;
}
},
},
"^long_?desc,"
=>
sub
{
"^long_?desc,"
=>
sub
{
my
$table
=
"longdescs_$chartid"
;
my
$table
=
"longdescs_$chartid"
;
...
@@ -1551,59 +1513,6 @@ sub SqlifyDate {
...
@@ -1551,59 +1513,6 @@ sub SqlifyDate {
return
time2str
(
"%Y-%m-%d %H:%M:%S"
,
$date
);
return
time2str
(
"%Y-%m-%d %H:%M:%S"
,
$date
);
}
}
# ListIDsForEmail returns a string with a comma-joined list
# of userids matching email addresses
# according to the type specified.
# Currently, this only supports regexp, exact, anyexact, and substring matches.
# Matches will return up to 50 matching userids
# If a match type is unsupported or returns too many matches,
# ListIDsForEmail returns an undef.
sub
ListIDsForEmail
{
my
(
$self
,
$type
,
$email
)
=
(
@_
);
my
$old
=
$self
->
{
"emailcache"
}{
"$type,$email"
};
return
undef
if
(
$old
&&
$old
eq
"---"
);
return
$old
if
$old
;
my
$dbh
=
Bugzilla
->
dbh
;
my
@list
=
();
my
$list
=
"---"
;
if
(
$type
eq
'anyexact'
)
{
foreach
my
$w
(
split
(
/,/
,
$email
))
{
$w
=
trim
(
$w
);
my
$id
=
login_to_id
(
$w
);
if
(
$id
>
0
)
{
push
(
@list
,
$id
)
}
}
$list
=
join
(
','
,
@list
);
}
elsif
(
$type
eq
'substring'
)
{
my
$sql_email
=
$dbh
->
quote
(
$email
);
trick_taint
(
$sql_email
);
my
$result
=
$dbh
->
selectcol_arrayref
(
q{SELECT userid FROM profiles WHERE }
.
$dbh
->
sql_position
(
lc
(
$sql_email
),
q{LOWER(login_name)}
)
.
q{ > 0 }
.
$dbh
->
sql_limit
(
51
));
@list
=
@
{
$result
};
if
(
scalar
(
@list
)
<
50
)
{
$list
=
join
(
','
,
@list
);
}
}
elsif
(
$type
eq
'regexp'
)
{
my
$sql_email
=
$dbh
->
quote
(
$email
);
trick_taint
(
$sql_email
);
my
$result
=
$dbh
->
selectcol_arrayref
(
qq{SELECT userid FROM profiles WHERE }
.
$dbh
->
sql_regexp
(
"login_name"
,
$sql_email
)
.
q{ }
.
$dbh
->
sql_limit
(
51
));
@list
=
@
{
$result
};
if
(
scalar
(
@list
)
<
50
)
{
$list
=
join
(
','
,
@list
);
}
}
$self
->
{
"emailcache"
}{
"$type,$email"
}
=
$list
;
return
undef
if
(
$list
eq
"---"
);
return
$list
;
}
sub
build_subselect
{
sub
build_subselect
{
my
(
$outer
,
$inner
,
$table
,
$cond
)
=
@_
;
my
(
$outer
,
$inner
,
$table
,
$cond
)
=
@_
;
my
$q
=
"SELECT $inner FROM $table WHERE $cond"
;
my
$q
=
"SELECT $inner FROM $table WHERE $cond"
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment