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
80130158
Commit
80130158
authored
May 14, 2010
by
Max Kanat-Alexander
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 556731 - Make Bugzilla::Milestone, Bugzilla::Version, and
Bugzilla::Component use VALIDATOR_DEPENDENCIES instead of UPDATE_VALIDATORS r=LpSolit, a=LpSolit
parent
8bc37c2d
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
38 additions
and
45 deletions
+38
-45
Component.pm
Bugzilla/Component.pm
+10
-15
Migrate.pm
Bugzilla/Migrate.pm
+3
-3
Milestone.pm
Bugzilla/Milestone.pm
+12
-13
Product.pm
Bugzilla/Product.pm
+2
-2
Version.pm
Bugzilla/Version.pm
+9
-10
editmilestones.cgi
editmilestones.cgi
+1
-1
editversions.cgi
editversions.cgi
+1
-1
No files found.
Bugzilla/Component.pm
View file @
80130158
...
@@ -28,6 +28,8 @@ use Bugzilla::User;
...
@@ -28,6 +28,8 @@ use Bugzilla::User;
use
Bugzilla::
FlagType
;
use
Bugzilla::
FlagType
;
use
Bugzilla::
Series
;
use
Bugzilla::
Series
;
use
Scalar::
Util
qw(blessed)
;
###############################
###############################
#### Initialization ####
#### Initialization ####
###############################
###############################
...
@@ -66,10 +68,11 @@ use constant VALIDATORS => {
...
@@ -66,10 +68,11 @@ use constant VALIDATORS => {
initialqacontact
=>
\&
_check_initialqacontact
,
initialqacontact
=>
\&
_check_initialqacontact
,
description
=>
\&
_check_description
,
description
=>
\&
_check_description
,
initial_cc
=>
\&
_check_cc_list
,
initial_cc
=>
\&
_check_cc_list
,
name
=>
\&
_check_name
,
};
};
use
constant
UPDATE_VALIDATOR
S
=>
{
use
constant
VALIDATOR_DEPENDENCIE
S
=>
{
name
=>
\&
_check_name
,
name
=>
[
'product'
]
,
};
};
###############################
###############################
...
@@ -116,8 +119,11 @@ sub create {
...
@@ -116,8 +119,11 @@ sub create {
my
$params
=
$class
->
run_create_validators
(
@_
);
my
$params
=
$class
->
run_create_validators
(
@_
);
my
$cc_list
=
delete
$params
->
{
initial_cc
};
my
$cc_list
=
delete
$params
->
{
initial_cc
};
my
$create_series
=
delete
$params
->
{
create_series
};
my
$create_series
=
delete
$params
->
{
create_series
};
my
$product
=
delete
$params
->
{
product
};
$params
->
{
product_id
}
=
$product
->
id
;
my
$component
=
$class
->
insert_create_data
(
$params
);
my
$component
=
$class
->
insert_create_data
(
$params
);
$component
->
{
product
}
=
$product
;
# We still have to fill the component_cc table.
# We still have to fill the component_cc table.
$component
->
_update_cc_list
(
$cc_list
)
if
$cc_list
;
$component
->
_update_cc_list
(
$cc_list
)
if
$cc_list
;
...
@@ -129,17 +135,6 @@ sub create {
...
@@ -129,17 +135,6 @@ sub create {
return
$component
;
return
$component
;
}
}
sub
run_create_validators
{
my
$class
=
shift
;
my
$params
=
$class
->
SUPER::
run_create_validators
(
@_
);
my
$product
=
delete
$params
->
{
product
};
$params
->
{
product_id
}
=
$product
->
id
;
$params
->
{
name
}
=
$class
->
_check_name
(
$params
->
{
name
},
$product
);
return
$params
;
}
sub
update
{
sub
update
{
my
$self
=
shift
;
my
$self
=
shift
;
my
$changes
=
$self
->
SUPER::
update
(
@_
);
my
$changes
=
$self
->
SUPER::
update
(
@_
);
...
@@ -190,7 +185,8 @@ sub remove_from_db {
...
@@ -190,7 +185,8 @@ sub remove_from_db {
################################
################################
sub
_check_name
{
sub
_check_name
{
my
(
$invocant
,
$name
,
$product
)
=
@_
;
my
(
$invocant
,
$name
,
undef
,
$params
)
=
@_
;
my
$product
=
blessed
(
$invocant
)
?
$invocant
->
product
:
$params
->
{
product
};
$name
=
trim
(
$name
);
$name
=
trim
(
$name
);
$name
||
ThrowUserError
(
'component_blank_name'
);
$name
||
ThrowUserError
(
'component_blank_name'
);
...
@@ -199,7 +195,6 @@ sub _check_name {
...
@@ -199,7 +195,6 @@ sub _check_name {
ThrowUserError
(
'component_name_too_long'
,
{
'name'
=>
$name
});
ThrowUserError
(
'component_name_too_long'
,
{
'name'
=>
$name
});
}
}
$product
=
$invocant
->
product
if
(
ref
$invocant
);
my
$component
=
new
Bugzilla::
Component
({
product
=>
$product
,
name
=>
$name
});
my
$component
=
new
Bugzilla::
Component
({
product
=>
$product
,
name
=>
$name
});
if
(
$component
&&
(
!
ref
$invocant
||
$component
->
id
!=
$invocant
->
id
))
{
if
(
$component
&&
(
!
ref
$invocant
||
$component
->
id
!=
$invocant
->
id
))
{
ThrowUserError
(
'component_already_exists'
,
{
name
=>
$component
->
name
,
ThrowUserError
(
'component_already_exists'
,
{
name
=>
$component
->
name
,
...
...
Bugzilla/Migrate.pm
View file @
80130158
...
@@ -654,7 +654,7 @@ sub create_legal_values {
...
@@ -654,7 +654,7 @@ sub create_legal_values {
next
if
new
Bugzilla::
Version
({
product
=>
$prod_obj
,
next
if
new
Bugzilla::
Version
({
product
=>
$prod_obj
,
name
=>
$version
});
name
=>
$version
});
my
$created
=
Bugzilla::
Version
->
create
({
product
=>
$prod_obj
,
my
$created
=
Bugzilla::
Version
->
create
({
product
=>
$prod_obj
,
name
=>
$version
});
value
=>
$version
});
my
$field
=
$self
->
bug_fields
->
{
version
};
my
$field
=
$self
->
bug_fields
->
{
version
};
print
get_text
(
'migrate_value_created'
,
{
product
=>
$prod_obj
,
print
get_text
(
'migrate_value_created'
,
{
product
=>
$prod_obj
,
field
=>
$field
,
field
=>
$field
,
...
@@ -663,8 +663,8 @@ sub create_legal_values {
...
@@ -663,8 +663,8 @@ sub create_legal_values {
foreach
my
$milestone
(
keys
%
{
$product_values
{
$product
}
->
{
target_milestone
}
})
{
foreach
my
$milestone
(
keys
%
{
$product_values
{
$product
}
->
{
target_milestone
}
})
{
next
if
new
Bugzilla::
Milestone
({
product
=>
$prod_obj
,
next
if
new
Bugzilla::
Milestone
({
product
=>
$prod_obj
,
name
=>
$milestone
});
name
=>
$milestone
});
my
$created
=
Bugzilla::
Milestone
->
create
(
{
product
=>
$prod_obj
,
my
$created
=
Bugzilla::
Milestone
->
create
(
nam
e
=>
$milestone
});
{
product
=>
$prod_obj
,
valu
e
=>
$milestone
});
my
$field
=
$self
->
bug_fields
->
{
target_milestone
};
my
$field
=
$self
->
bug_fields
->
{
target_milestone
};
print
get_text
(
'migrate_value_created'
,
{
product
=>
$prod_obj
,
print
get_text
(
'migrate_value_created'
,
{
product
=>
$prod_obj
,
field
=>
$field
,
field
=>
$field
,
...
...
Bugzilla/Milestone.pm
View file @
80130158
...
@@ -26,6 +26,8 @@ use Bugzilla::Constants;
...
@@ -26,6 +26,8 @@ use Bugzilla::Constants;
use
Bugzilla::
Util
;
use
Bugzilla::
Util
;
use
Bugzilla::
Error
;
use
Bugzilla::
Error
;
use
Scalar::
Util
qw(blessed)
;
################################
################################
##### Initialization #####
##### Initialization #####
################################
################################
...
@@ -44,7 +46,7 @@ use constant DB_COLUMNS => qw(
...
@@ -44,7 +46,7 @@ use constant DB_COLUMNS => qw(
)
;
)
;
use
constant
REQUIRED_CREATE_FIELDS
=>
qw(
use
constant
REQUIRED_CREATE_FIELDS
=>
qw(
nam
e
valu
e
product
product
)
;
)
;
...
@@ -56,10 +58,11 @@ use constant UPDATE_COLUMNS => qw(
...
@@ -56,10 +58,11 @@ use constant UPDATE_COLUMNS => qw(
use
constant
VALIDATORS
=>
{
use
constant
VALIDATORS
=>
{
product
=>
\&
_check_product
,
product
=>
\&
_check_product
,
sortkey
=>
\&
_check_sortkey
,
sortkey
=>
\&
_check_sortkey
,
value
=>
\&
_check_value
,
};
};
use
constant
UPDATE_VALIDATOR
S
=>
{
use
constant
VALIDATOR_DEPENDENCIE
S
=>
{
value
=>
\&
_check_value
,
value
=>
[
'product'
]
,
};
};
################################
################################
...
@@ -94,14 +97,10 @@ sub new {
...
@@ -94,14 +97,10 @@ sub new {
}
}
sub
run_create_validators
{
sub
run_create_validators
{
my
$class
=
shift
;
my
$class
=
shift
;
my
$params
=
$class
->
SUPER::
run_create_validators
(
@_
);
my
$params
=
$class
->
SUPER::
run_create_validators
(
@_
);
my
$product
=
delete
$params
->
{
product
};
my
$product
=
delete
$params
->
{
product
};
$params
->
{
product_id
}
=
$product
->
id
;
$params
->
{
product_id
}
=
$product
->
id
;
$params
->
{
value
}
=
$class
->
_check_value
(
$params
->
{
name
},
$product
);
delete
$params
->
{
name
};
return
$params
;
return
$params
;
}
}
...
@@ -165,7 +164,8 @@ sub remove_from_db {
...
@@ -165,7 +164,8 @@ sub remove_from_db {
################################
################################
sub
_check_value
{
sub
_check_value
{
my
(
$invocant
,
$name
,
$product
)
=
@_
;
my
(
$invocant
,
$name
,
undef
,
$params
)
=
@_
;
my
$product
=
blessed
(
$invocant
)
?
$invocant
->
product
:
$params
->
{
product
};
$name
=
trim
(
$name
);
$name
=
trim
(
$name
);
$name
||
ThrowUserError
(
'milestone_blank_name'
);
$name
||
ThrowUserError
(
'milestone_blank_name'
);
...
@@ -173,7 +173,6 @@ sub _check_value {
...
@@ -173,7 +173,6 @@ sub _check_value {
ThrowUserError
(
'milestone_name_too_long'
,
{
name
=>
$name
});
ThrowUserError
(
'milestone_name_too_long'
,
{
name
=>
$name
});
}
}
$product
=
$invocant
->
product
if
(
ref
$invocant
);
my
$milestone
=
new
Bugzilla::
Milestone
({
product
=>
$product
,
name
=>
$name
});
my
$milestone
=
new
Bugzilla::
Milestone
({
product
=>
$product
,
name
=>
$name
});
if
(
$milestone
&&
(
!
ref
$invocant
||
$milestone
->
id
!=
$invocant
->
id
))
{
if
(
$milestone
&&
(
!
ref
$invocant
||
$milestone
->
id
!=
$invocant
->
id
))
{
ThrowUserError
(
'milestone_already_exists'
,
{
name
=>
$milestone
->
name
,
ThrowUserError
(
'milestone_already_exists'
,
{
name
=>
$milestone
->
name
,
...
@@ -255,7 +254,7 @@ Bugzilla::Milestone - Bugzilla product milestone class.
...
@@ -255,7 +254,7 @@ Bugzilla::Milestone - Bugzilla product milestone class.
my $sortkey = $milestone->sortkey;
my $sortkey = $milestone->sortkey;
my $milestone = Bugzilla::Milestone->create(
my $milestone = Bugzilla::Milestone->create(
{
nam
e => $name, product => $product, sortkey => $sortkey });
{
valu
e => $name, product => $product, sortkey => $sortkey });
$milestone->set_name($new_name);
$milestone->set_name($new_name);
$milestone->set_sortkey($new_sortkey);
$milestone->set_sortkey($new_sortkey);
...
@@ -361,11 +360,11 @@ Milestone.pm represents a Product Milestone object.
...
@@ -361,11 +360,11 @@ Milestone.pm represents a Product Milestone object.
=over
=over
=item C<create({
name => $nam
e, product => $product, sortkey => $sortkey})>
=item C<create({
value => $valu
e, product => $product, sortkey => $sortkey})>
Description: Create a new milestone for the given product.
Description: Create a new milestone for the given product.
Params: $
name
- name of the new milestone (string). This name
Params: $
value
- name of the new milestone (string). This name
must be unique within the product.
must be unique within the product.
$product - a Bugzilla::Product object.
$product - a Bugzilla::Product object.
$sortkey - the sortkey of the new milestone (signed integer)
$sortkey - the sortkey of the new milestone (signed integer)
...
...
Bugzilla/Product.pm
View file @
80130158
...
@@ -101,8 +101,8 @@ sub create {
...
@@ -101,8 +101,8 @@ sub create {
Bugzilla
->
user
->
clear_product_cache
();
Bugzilla
->
user
->
clear_product_cache
();
# Add the new version and milestone into the DB as valid values.
# Add the new version and milestone into the DB as valid values.
Bugzilla::
Version
->
create
({
name
=>
$version
,
product
=>
$product
});
Bugzilla::
Version
->
create
({
value
=>
$version
,
product
=>
$product
});
Bugzilla::
Milestone
->
create
({
nam
e
=>
$product
->
default_milestone
,
Bugzilla::
Milestone
->
create
({
valu
e
=>
$product
->
default_milestone
,
product
=>
$product
});
product
=>
$product
});
# Create groups and series for the new product, if requested.
# Create groups and series for the new product, if requested.
...
...
Bugzilla/Version.pm
View file @
80130158
...
@@ -26,6 +26,8 @@ use Bugzilla::Install::Util qw(vers_cmp);
...
@@ -26,6 +26,8 @@ use Bugzilla::Install::Util qw(vers_cmp);
use
Bugzilla::
Util
;
use
Bugzilla::
Util
;
use
Bugzilla::
Error
;
use
Bugzilla::
Error
;
use
Scalar::
Util
qw(blessed)
;
################################
################################
##### Initialization #####
##### Initialization #####
################################
################################
...
@@ -45,7 +47,7 @@ use constant DB_COLUMNS => qw(
...
@@ -45,7 +47,7 @@ use constant DB_COLUMNS => qw(
)
;
)
;
use
constant
REQUIRED_CREATE_FIELDS
=>
qw(
use
constant
REQUIRED_CREATE_FIELDS
=>
qw(
nam
e
valu
e
product
product
)
;
)
;
...
@@ -55,10 +57,11 @@ use constant UPDATE_COLUMNS => qw(
...
@@ -55,10 +57,11 @@ use constant UPDATE_COLUMNS => qw(
use
constant
VALIDATORS
=>
{
use
constant
VALIDATORS
=>
{
product
=>
\&
_check_product
,
product
=>
\&
_check_product
,
value
=>
\&
_check_value
,
};
};
use
constant
UPDATE_VALIDATOR
S
=>
{
use
constant
VALIDATOR_DEPENDENCIE
S
=>
{
value
=>
\&
_check_value
,
value
=>
[
'product'
]
,
};
};
################################
################################
...
@@ -103,12 +106,8 @@ sub new_from_list {
...
@@ -103,12 +106,8 @@ sub new_from_list {
sub
run_create_validators
{
sub
run_create_validators
{
my
$class
=
shift
;
my
$class
=
shift
;
my
$params
=
$class
->
SUPER::
run_create_validators
(
@_
);
my
$params
=
$class
->
SUPER::
run_create_validators
(
@_
);
my
$product
=
delete
$params
->
{
product
};
my
$product
=
delete
$params
->
{
product
};
$params
->
{
product_id
}
=
$product
->
id
;
$params
->
{
product_id
}
=
$product
->
id
;
$params
->
{
value
}
=
$class
->
_check_value
(
$params
->
{
name
},
$product
);
delete
$params
->
{
name
};
return
$params
;
return
$params
;
}
}
...
@@ -171,14 +170,14 @@ sub product {
...
@@ -171,14 +170,14 @@ sub product {
sub
set_name
{
$_
[
0
]
->
set
(
'value'
,
$_
[
1
]);
}
sub
set_name
{
$_
[
0
]
->
set
(
'value'
,
$_
[
1
]);
}
sub
_check_value
{
sub
_check_value
{
my
(
$invocant
,
$name
,
$product
)
=
@_
;
my
(
$invocant
,
$name
,
undef
,
$params
)
=
@_
;
my
$product
=
blessed
(
$invocant
)
?
$invocant
->
product
:
$params
->
{
product
};
$name
=
trim
(
$name
);
$name
=
trim
(
$name
);
$name
||
ThrowUserError
(
'version_blank_name'
);
$name
||
ThrowUserError
(
'version_blank_name'
);
# Remove unprintable characters
# Remove unprintable characters
$name
=
clean_text
(
$name
);
$name
=
clean_text
(
$name
);
$product
=
$invocant
->
product
if
(
ref
$invocant
);
my
$version
=
new
Bugzilla::
Version
({
product
=>
$product
,
name
=>
$name
});
my
$version
=
new
Bugzilla::
Version
({
product
=>
$product
,
name
=>
$name
});
if
(
$version
&&
(
!
ref
$invocant
||
$version
->
id
!=
$invocant
->
id
))
{
if
(
$version
&&
(
!
ref
$invocant
||
$version
->
id
!=
$invocant
->
id
))
{
ThrowUserError
(
'version_already_exists'
,
{
name
=>
$version
->
name
,
ThrowUserError
(
'version_already_exists'
,
{
name
=>
$version
->
name
,
...
@@ -211,7 +210,7 @@ Bugzilla::Version - Bugzilla product version class.
...
@@ -211,7 +210,7 @@ Bugzilla::Version - Bugzilla product version class.
my $product = $version->product;
my $product = $version->product;
my $version = Bugzilla::Version->create(
my $version = Bugzilla::Version->create(
{
nam
e => $name, product => $product });
{
valu
e => $name, product => $product });
$version->set_name($new_name);
$version->set_name($new_name);
$version->update();
$version->update();
...
...
editmilestones.cgi
View file @
80130158
...
@@ -115,7 +115,7 @@ if ($action eq 'add') {
...
@@ -115,7 +115,7 @@ if ($action eq 'add') {
if
(
$action
eq
'new'
)
{
if
(
$action
eq
'new'
)
{
check_token_data
(
$token
,
'add_milestone'
);
check_token_data
(
$token
,
'add_milestone'
);
my
$milestone
=
Bugzilla::
Milestone
->
create
({
name
=>
$milestone_name
,
my
$milestone
=
Bugzilla::
Milestone
->
create
({
value
=>
$milestone_name
,
product
=>
$product
,
product
=>
$product
,
sortkey
=>
$sortkey
});
sortkey
=>
$sortkey
});
delete_token
(
$token
);
delete_token
(
$token
);
...
...
editversions.cgi
View file @
80130158
...
@@ -120,7 +120,7 @@ if ($action eq 'add') {
...
@@ -120,7 +120,7 @@ if ($action eq 'add') {
if
(
$action
eq
'new'
)
{
if
(
$action
eq
'new'
)
{
check_token_data
(
$token
,
'add_version'
);
check_token_data
(
$token
,
'add_version'
);
my
$version
=
Bugzilla::
Version
->
create
(
my
$version
=
Bugzilla::
Version
->
create
(
{
name
=>
$version_name
,
product
=>
$product
});
{
value
=>
$version_name
,
product
=>
$product
});
delete_token
(
$token
);
delete_token
(
$token
);
$vars
->
{
'message'
}
=
'version_created'
;
$vars
->
{
'message'
}
=
'version_created'
;
...
...
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