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
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
bugzilla
Commits
2883bee0
Commit
2883bee0
authored
Jan 23, 2009
by
mkanat%bugzilla.org
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 471943: Implement Bugzilla::Bug::match
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=dkl, a=mkanat
parent
2338c292
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
0 deletions
+60
-0
Bug.pm
Bugzilla/Bug.pm
+60
-0
No files found.
Bugzilla/Bug.pm
View file @
2883bee0
...
...
@@ -328,6 +328,66 @@ sub check_is_visible {
}
}
sub
match
{
my
$class
=
shift
;
my
(
$params
)
=
@_
;
# Allow matching certain fields by name (in addition to matching by ID).
my
%
translate_fields
=
(
assigned_to
=>
'Bugzilla::User'
,
qa_contact
=>
'Bugzilla::User'
,
reporter
=>
'Bugzilla::User'
,
product
=>
'Bugzilla::Product'
,
component
=>
'Bugzilla::Component'
,
);
my
%
translated
;
foreach
my
$field
(
keys
%
translate_fields
)
{
my
@ids
;
# Convert names to ids. We use "exists" everywhere since people can
# legally specify "undef" to mean IS NULL (even though most of these
# fields can't be NULL, people can still specify it...).
if
(
exists
$params
->
{
$field
})
{
my
$names
=
$params
->
{
$field
};
my
$type
=
$translate_fields
{
$field
};
my
$param
=
$type
eq
'Bugzilla::User'
?
'login_name'
:
'name'
;
# We call Bugzilla::Object::match directly to avoid the
# Bugzilla::User::match implementation which is different.
my
$objects
=
Bugzilla::Object::
match
(
$type
,
{
$param
=>
$names
});
push
(
@ids
,
map
{
$_
->
id
}
@$objects
);
}
# You can also specify ids directly as arguments to this function,
# so include them in the list if they have been specified.
if
(
exists
$params
->
{
"${field}_id"
})
{
my
$current_ids
=
$params
->
{
"${field}_id"
};
my
@id_array
=
ref
$current_ids
?
@$current_ids
:
(
$current_ids
);
push
(
@ids
,
@id_array
);
}
# We do this "or" instead of a "scalar(@ids)" to handle the case
# when people passed only invalid object names. Otherwise we'd
# end up with a SUPER::match call with zero criteria (which dies).
if
(
exists
$params
->
{
$field
}
or
exists
$params
->
{
"${field}_id"
})
{
$translated
{
$field
}
=
scalar
(
@ids
)
==
1
?
$ids
[
0
]
:
\
@ids
;
}
}
# The user fields don't have an _id on the end of them in the database,
# but the product & component fields do, so we have to have separate
# code to deal with the different sets of fields here.
foreach
my
$field
(
qw(assigned_to qa_contact reporter)
)
{
delete
$params
->
{
"${field}_id"
};
$params
->
{
$field
}
=
$translated
{
$field
}
if
exists
$translated
{
$field
};
}
foreach
my
$field
(
qw(product component)
)
{
delete
$params
->
{
$field
};
$params
->
{
"${field}_id"
}
=
$translated
{
$field
}
if
exists
$translated
{
$field
};
}
return
$class
->
SUPER::
match
(
@_
);
}
# Docs for create() (there's no POD in this file yet, but we very
# much need this documented right now):
#
...
...
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