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
6d154983
Commit
6d154983
authored
Aug 23, 2006
by
mkanat%bugzilla.org
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 349555: Move dependency validation from post_bug into Bugzilla::Bug
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=bkor, a=justdave
parent
363f5a4e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
21 deletions
+36
-21
Bug.pm
Bugzilla/Bug.pm
+33
-1
post_bug.cgi
post_bug.cgi
+3
-20
No files found.
Bugzilla/Bug.pm
View file @
6d154983
...
...
@@ -341,6 +341,35 @@ sub _check_component {
return
$obj
;
}
# Takes two comma/space-separated strings and returns arrayrefs
# of valid bug IDs.
sub
_check_dependencies
{
my
(
$depends_on
,
$blocks
)
=
@_
;
# Only editbugs users can set dependencies on bug entry.
return
(
[]
,
[]
)
unless
Bugzilla
->
user
->
in_group
(
'editbugs'
);
$depends_on
||=
''
;
$blocks
||=
''
;
# Make sure all the bug_ids are valid.
my
@results
;
foreach
my
$string
(
$depends_on
,
$blocks
)
{
my
@array
=
split
(
/[\s,]+/
,
$string
);
# Eliminate nulls
@array
=
grep
(
$_
,
@array
);
# $field is not passed to ValidateBugID to prevent adding new
# dependencies on inaccessible bugs.
ValidateBugID
(
$_
)
foreach
(
@array
);
push
(
@results
,
\
@array
);
}
# dependson blocks
my
%
deps
=
ValidateDependencies
(
$results
[
0
],
$results
[
1
]);
return
(
$deps
{
'dependson'
},
$deps
{
'blocked'
});
}
sub
_check_keywords
{
my
(
$keyword_string
)
=
@_
;
$keyword_string
=
trim
(
$keyword_string
);
...
...
@@ -1633,6 +1662,7 @@ sub ValidateBugAlias {
# Validate and return a hash of dependencies
sub
ValidateDependencies
{
my
$fields
=
{};
# These can be arrayrefs or they can be strings.
$fields
->
{
'dependson'
}
=
shift
;
$fields
->
{
'blocked'
}
=
shift
;
my
$id
=
shift
||
0
;
...
...
@@ -1653,7 +1683,9 @@ sub ValidateDependencies {
next
unless
$fields
->
{
$target
};
my
%
seen
;
foreach
my
$i
(
split
(
'[\s,]+'
,
$fields
->
{
$target
}))
{
my
$target_array
=
ref
(
$fields
->
{
$target
})
?
$fields
->
{
$target
}
:
[
split
(
/[\s,]+/
,
$fields
->
{
$target
})];
foreach
my
$i
(
@$target_array
)
{
if
(
$id
==
$i
)
{
ThrowUserError
(
"dependency_loop_single"
);
}
...
...
post_bug.cgi
View file @
6d154983
...
...
@@ -227,26 +227,8 @@ my @keyword_ids = @{Bugzilla::Bug::_check_keywords($cgi->param('keywords'))};
Bugzilla::Bug::
_check_strict_isolation
(
$product
,
$cc_ids
,
$cgi
->
param
(
'assigned_to'
),
$cgi
->
param
(
'qa_contact'
));
# Check for valid dependency info.
foreach
my
$field
(
"dependson"
,
"blocked"
)
{
if
(
UserInGroup
(
"editbugs"
)
&&
$cgi
->
param
(
$field
))
{
my
@validvalues
;
foreach
my
$id
(
split
(
/[\s,]+/
,
$cgi
->
param
(
$field
)))
{
next
unless
$id
;
# $field is not passed to ValidateBugID to prevent adding new
# dependencies on inaccessible bugs.
ValidateBugID
(
$id
);
push
(
@validvalues
,
$id
);
}
$cgi
->
param
(
-
name
=>
$field
,
-
value
=>
join
(
","
,
@validvalues
));
}
}
# Gather the dependency list, and make sure there are no circular refs
my
%
deps
;
if
(
UserInGroup
(
"editbugs"
))
{
%
deps
=
Bugzilla::Bug::
ValidateDependencies
(
scalar
(
$cgi
->
param
(
'dependson'
)),
scalar
(
$cgi
->
param
(
'blocked'
)));
}
my
(
$depends_on_ids
,
$blocks_ids
)
=
Bugzilla::Bug::
_check_dependencies
(
scalar
$cgi
->
param
(
'dependson'
),
scalar
$cgi
->
param
(
'blocked'
));
# get current time
my
$timestamp
=
$dbh
->
selectrow_array
(
q{SELECT NOW()}
);
...
...
@@ -415,6 +397,7 @@ if (UserInGroup("editbugs")) {
WHERE bug_id = ?}
,
undef
,
(
$timestamp
,
$kw_list
,
$id
));
}
if
(
$cgi
->
param
(
'dependson'
)
||
$cgi
->
param
(
'blocked'
))
{
my
%
deps
=
(
dependson
=>
$depends_on_ids
,
blocked
=>
$blocks_ids
);
foreach
my
$pair
([
"blocked"
,
"dependson"
],
[
"dependson"
,
"blocked"
])
{
my
(
$me
,
$target
)
=
@
{
$pair
};
my
$sth_dep
=
$dbh
->
prepare
(
qq{
...
...
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