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
e68208dd
Commit
e68208dd
authored
Aug 04, 2006
by
mkanat%bugzilla.org
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 347116: Move field-definition code from checksetup.pl into a module
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> (module owner) a=myk
parent
4883aac1
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
161 additions
and
145 deletions
+161
-145
Field.pm
Bugzilla/Field.pm
+159
-1
DB.pm
Bugzilla/Install/DB.pm
+1
-7
checksetup.pl
checksetup.pl
+1
-137
No files found.
Bugzilla/Field.pm
View file @
e68208dd
...
...
@@ -80,6 +80,10 @@ use Bugzilla::Util;
use
Bugzilla::
Constants
;
use
Bugzilla::
Error
;
###############################
#### Initialization ####
###############################
use
constant
DB_TABLE
=>
'fielddefs'
;
use
constant
LIST_ORDER
=>
'sortkey, name'
;
...
...
@@ -100,6 +104,66 @@ use constant SQL_DEFINITIONS => {
FIELD_TYPE_FREETEXT
,
{
TYPE
=>
'varchar(255)'
},
};
# Field definitions for the fields that ship with Bugzilla.
# These are used by populate_field_definitions to populate
# the fielddefs table.
use
constant
DEFAULT_FIELDS
=>
(
{
name
=>
'bug_id'
,
desc
=>
'Bug #'
,
in_new_bugmail
=>
1
},
{
name
=>
'short_desc'
,
desc
=>
'Summary'
,
in_new_bugmail
=>
1
},
{
name
=>
'classification'
,
desc
=>
'Classification'
,
in_new_bugmail
=>
1
},
{
name
=>
'product'
,
desc
=>
'Product'
,
in_new_bugmail
=>
1
},
{
name
=>
'version'
,
desc
=>
'Version'
,
in_new_bugmail
=>
1
},
{
name
=>
'rep_platform'
,
desc
=>
'Platform'
,
in_new_bugmail
=>
1
},
{
name
=>
'bug_file_loc'
,
desc
=>
'URL'
,
in_new_bugmail
=>
1
},
{
name
=>
'op_sys'
,
desc
=>
'OS/Version'
,
in_new_bugmail
=>
1
},
{
name
=>
'bug_status'
,
desc
=>
'Status'
,
in_new_bugmail
=>
1
},
{
name
=>
'status_whiteboard'
,
desc
=>
'Status Whiteboard'
,
in_new_bugmail
=>
1
},
{
name
=>
'keywords'
,
desc
=>
'Keywords'
,
in_new_bugmail
=>
1
},
{
name
=>
'resolution'
,
desc
=>
'Resolution'
},
{
name
=>
'bug_severity'
,
desc
=>
'Severity'
,
in_new_bugmail
=>
1
},
{
name
=>
'priority'
,
desc
=>
'Priority'
,
in_new_bugmail
=>
1
},
{
name
=>
'component'
,
desc
=>
'Component'
,
in_new_bugmail
=>
1
},
{
name
=>
'assigned_to'
,
desc
=>
'AssignedTo'
,
in_new_bugmail
=>
1
},
{
name
=>
'reporter'
,
desc
=>
'ReportedBy'
,
in_new_bugmail
=>
1
},
{
name
=>
'votes'
,
desc
=>
'Votes'
},
{
name
=>
'qa_contact'
,
desc
=>
'QAContact'
,
in_new_bugmail
=>
1
},
{
name
=>
'cc'
,
desc
=>
'CC'
,
in_new_bugmail
=>
1
},
{
name
=>
'dependson'
,
desc
=>
'BugsThisDependsOn'
,
in_new_bugmail
=>
1
},
{
name
=>
'blocked'
,
desc
=>
'OtherBugsDependingOnThis'
,
in_new_bugmail
=>
1
},
{
name
=>
'attachments.description'
,
desc
=>
'Attachment description'
},
{
name
=>
'attachments.filename'
,
desc
=>
'Attachment filename'
},
{
name
=>
'attachments.mimetype'
,
desc
=>
'Attachment mime type'
},
{
name
=>
'attachments.ispatch'
,
desc
=>
'Attachment is patch'
},
{
name
=>
'attachments.isobsolete'
,
desc
=>
'Attachment is obsolete'
},
{
name
=>
'attachments.isprivate'
,
desc
=>
'Attachment is private'
},
{
name
=>
'target_milestone'
,
desc
=>
'Target Milestone'
},
{
name
=>
'creation_ts'
,
desc
=>
'Creation date'
,
in_new_bugmail
=>
1
},
{
name
=>
'delta_ts'
,
desc
=>
'Last changed date'
,
in_new_bugmail
=>
1
},
{
name
=>
'longdesc'
,
desc
=>
'Comment'
},
{
name
=>
'alias'
,
desc
=>
'Alias'
},
{
name
=>
'everconfirmed'
,
desc
=>
'Ever Confirmed'
},
{
name
=>
'reporter_accessible'
,
desc
=>
'Reporter Accessible'
},
{
name
=>
'cclist_accessible'
,
desc
=>
'CC Accessible'
},
{
name
=>
'bug_group'
,
desc
=>
'Group'
},
{
name
=>
'estimated_time'
,
desc
=>
'Estimated Hours'
,
in_new_bugmail
=>
1
},
{
name
=>
'remaining_time'
,
desc
=>
'Remaining Hours'
},
{
name
=>
'deadline'
,
desc
=>
'Deadline'
,
in_new_bugmail
=>
1
},
{
name
=>
'commenter'
,
desc
=>
'Commenter'
},
{
name
=>
'flagtypes.name'
,
desc
=>
'Flag'
},
{
name
=>
'requestees.login_name'
,
desc
=>
'Flag Requestee'
},
{
name
=>
'setters.login_name'
,
desc
=>
'Flag Setter'
},
{
name
=>
'work_time'
,
desc
=>
'Hours Worked'
},
{
name
=>
'percentage_complete'
,
desc
=>
'Percentage Complete'
},
{
name
=>
'content'
,
desc
=>
'Content'
},
{
name
=>
'attach_data.thedata'
,
desc
=>
'Attachment data'
},
{
name
=>
'attachments.isurl'
,
desc
=>
'Attachment is a URL'
},
{
name
=>
"owner_idle_time"
,
desc
=>
"Time Since Assignee Touched"
},
);
=pod
=head2 Instance Properties
...
...
@@ -318,8 +382,102 @@ sub get_legal_field_values {
return
$result_ref
;
}
=item C<populate_field_definitions()>
Description: Populates the fielddefs table during an installation
or upgrade.
Params: none
Returns: nothing
=cut
sub
populate_field_definitions
{
my
$dbh
=
Bugzilla
->
dbh
;
# ADD and UPDATE field definitions
foreach
my
$definition
(
DEFAULT_FIELDS
)
{
create_or_update
(
$definition
);
}
# DELETE fields which were added only accidentally, or which
# were never tracked in bugs_activity. Note that you can never
# delete fields which are used by bugs_activity.
# Oops. Bug 163299
$dbh
->
do
(
"DELETE FROM fielddefs WHERE name='cc_accessible'"
);
# Oops. Bug 215319
$dbh
->
do
(
"DELETE FROM fielddefs WHERE name='requesters.login_name'"
);
# This field was never tracked in bugs_activity, so it's safe to delete.
$dbh
->
do
(
"DELETE FROM fielddefs WHERE name='attachments.thedata'"
);
# MODIFY old field definitions
# 2005-11-13 LpSolit@gmail.com - Bug 302599
# One of the field names was a fragment of SQL code, which is DB dependent.
# We have to rename it to a real name, which is DB independent.
my
$new_field_name
=
'days_elapsed'
;
my
$field_description
=
'Days since bug changed'
;
my
(
$old_field_id
,
$old_field_name
)
=
$dbh
->
selectrow_array
(
'SELECT id, name FROM fielddefs
WHERE description = ?'
,
undef
,
$field_description
);
if
(
$old_field_id
&&
(
$old_field_name
ne
$new_field_name
))
{
print
"SQL fragment found in the 'fielddefs' table...\n"
;
print
"Old field name: "
.
$old_field_name
.
"\n"
;
# We have to fix saved searches first. Queries have been escaped
# before being saved. We have to do the same here to find them.
$old_field_name
=
url_quote
(
$old_field_name
);
my
$broken_named_queries
=
$dbh
->
selectall_arrayref
(
'SELECT userid, name, query
FROM namedqueries WHERE '
.
$dbh
->
sql_istrcmp
(
'query'
,
'?'
,
'LIKE'
),
undef
,
"%=$old_field_name%"
);
my
$sth_UpdateQueries
=
$dbh
->
prepare
(
'UPDATE namedqueries SET query = ?
WHERE userid = ? AND name = ?'
);
print
"Fixing saved searches...\n"
if
scalar
(
@$broken_named_queries
);
foreach
my
$named_query
(
@$broken_named_queries
)
{
my
(
$userid
,
$name
,
$query
)
=
@$named_query
;
$query
=~
s/=\Q$old_field_name\E(&|$)/=$new_field_name$1/gi
;
$sth_UpdateQueries
->
execute
(
$query
,
$userid
,
$name
);
}
# We now do the same with saved chart series.
my
$broken_series
=
$dbh
->
selectall_arrayref
(
'SELECT series_id, query
FROM series WHERE '
.
$dbh
->
sql_istrcmp
(
'query'
,
'?'
,
'LIKE'
),
undef
,
"%=$old_field_name%"
);
my
$sth_UpdateSeries
=
$dbh
->
prepare
(
'UPDATE series SET query = ?
WHERE series_id = ?'
);
print
"Fixing saved chart series...\n"
if
scalar
(
@$broken_series
);
foreach
my
$series
(
@$broken_series
)
{
my
(
$series_id
,
$query
)
=
@$series
;
$query
=~
s/=\Q$old_field_name\E(&|$)/=$new_field_name$1/gi
;
$sth_UpdateSeries
->
execute
(
$query
,
$series_id
);
}
# Now that saved searches have been fixed, we can fix the field name.
print
"Fixing the 'fielddefs' table...\n"
;
print
"New field name: "
.
$new_field_name
.
"\n"
;
$dbh
->
do
(
'UPDATE fielddefs SET name = ? WHERE id = ?'
,
undef
,
(
$new_field_name
,
$old_field_id
));
}
# This field has to be created separately, or the above upgrade code
# might not run properly.
Bugzilla::Field::
create_or_update
(
{
name
=>
$new_field_name
,
desc
=>
$field_description
});
}
=pod
=head2 Data Validation
...
...
Bugzilla/Install/DB.pm
View file @
e68208dd
...
...
@@ -23,7 +23,6 @@ use strict;
use
Bugzilla::
Bug
qw(is_open_state)
;
use
Bugzilla::
Constants
;
use
Bugzilla::
Field
;
use
Bugzilla::
Util
;
use
Bugzilla::
Series
;
...
...
@@ -280,9 +279,6 @@ sub update_table_definitions {
_remove_user_series_map
();
_copy_old_charts_into_database
();
Bugzilla::Field::
create_or_update
(
{
name
=>
"owner_idle_time"
,
desc
=>
"Time Since Assignee Touched"
});
_add_user_group_map_grant_type
();
_add_group_group_map_grant_type
();
...
...
@@ -1376,9 +1372,7 @@ sub _convert_groups_system_from_groupset {
}
}
# Replace old activity log groupset records with lists of names
# of groups. Start by defining the bug_group field and getting its id.
Bugzilla::Field::
create_or_update
(
{
name
=>
"bug_group"
,
desc
=>
"Group"
});
# of groups.
$sth
=
$dbh
->
prepare
(
"SELECT id FROM fielddefs
WHERE name = "
.
$dbh
->
quote
(
'bug_group'
));
$sth
->
execute
();
...
...
checksetup.pl
View file @
e68208dd
...
...
@@ -455,71 +455,6 @@ sub AddGroup {
return
$last
;
}
###########################################################################
# The list of fields.
###########################################################################
# NOTE: All of these entries are unconditional, from when get_field_id
# used to create an entry if it wasn't found. New fielddef columns should
# be created with their associated schema change.
use
constant
OLD_FIELD_DEFS
=>
(
{
name
=>
'bug_id'
,
desc
=>
'Bug #'
,
in_new_bugmail
=>
1
},
{
name
=>
'short_desc'
,
desc
=>
'Summary'
,
in_new_bugmail
=>
1
},
{
name
=>
'classification'
,
desc
=>
'Classification'
,
in_new_bugmail
=>
1
},
{
name
=>
'product'
,
desc
=>
'Product'
,
in_new_bugmail
=>
1
},
{
name
=>
'version'
,
desc
=>
'Version'
,
in_new_bugmail
=>
1
},
{
name
=>
'rep_platform'
,
desc
=>
'Platform'
,
in_new_bugmail
=>
1
},
{
name
=>
'bug_file_loc'
,
desc
=>
'URL'
,
in_new_bugmail
=>
1
},
{
name
=>
'op_sys'
,
desc
=>
'OS/Version'
,
in_new_bugmail
=>
1
},
{
name
=>
'bug_status'
,
desc
=>
'Status'
,
in_new_bugmail
=>
1
},
{
name
=>
'status_whiteboard'
,
desc
=>
'Status Whiteboard'
,
in_new_bugmail
=>
1
},
{
name
=>
'keywords'
,
desc
=>
'Keywords'
,
in_new_bugmail
=>
1
},
{
name
=>
'resolution'
,
desc
=>
'Resolution'
},
{
name
=>
'bug_severity'
,
desc
=>
'Severity'
,
in_new_bugmail
=>
1
},
{
name
=>
'priority'
,
desc
=>
'Priority'
,
in_new_bugmail
=>
1
},
{
name
=>
'component'
,
desc
=>
'Component'
,
in_new_bugmail
=>
1
},
{
name
=>
'assigned_to'
,
desc
=>
'AssignedTo'
,
in_new_bugmail
=>
1
},
{
name
=>
'reporter'
,
desc
=>
'ReportedBy'
,
in_new_bugmail
=>
1
},
{
name
=>
'votes'
,
desc
=>
'Votes'
},
{
name
=>
'qa_contact'
,
desc
=>
'QAContact'
,
in_new_bugmail
=>
1
},
{
name
=>
'cc'
,
desc
=>
'CC'
,
in_new_bugmail
=>
1
},
{
name
=>
'dependson'
,
desc
=>
'BugsThisDependsOn'
,
in_new_bugmail
=>
1
},
{
name
=>
'blocked'
,
desc
=>
'OtherBugsDependingOnThis'
,
in_new_bugmail
=>
1
},
{
name
=>
'attachments.description'
,
desc
=>
'Attachment description'
},
{
name
=>
'attachments.filename'
,
desc
=>
'Attachment filename'
},
{
name
=>
'attachments.mimetype'
,
desc
=>
'Attachment mime type'
},
{
name
=>
'attachments.ispatch'
,
desc
=>
'Attachment is patch'
},
{
name
=>
'attachments.isobsolete'
,
desc
=>
'Attachment is obsolete'
},
{
name
=>
'attachments.isprivate'
,
desc
=>
'Attachment is private'
},
{
name
=>
'target_milestone'
,
desc
=>
'Target Milestone'
},
{
name
=>
'creation_ts'
,
desc
=>
'Creation date'
,
in_new_bugmail
=>
1
},
{
name
=>
'delta_ts'
,
desc
=>
'Last changed date'
,
in_new_bugmail
=>
1
},
{
name
=>
'longdesc'
,
desc
=>
'Comment'
},
{
name
=>
'alias'
,
desc
=>
'Alias'
},
{
name
=>
'everconfirmed'
,
desc
=>
'Ever Confirmed'
},
{
name
=>
'reporter_accessible'
,
desc
=>
'Reporter Accessible'
},
{
name
=>
'cclist_accessible'
,
desc
=>
'CC Accessible'
},
{
name
=>
'bug_group'
,
desc
=>
'Group'
},
{
name
=>
'estimated_time'
,
desc
=>
'Estimated Hours'
,
in_new_bugmail
=>
1
},
{
name
=>
'remaining_time'
,
desc
=>
'Remaining Hours'
},
{
name
=>
'deadline'
,
desc
=>
'Deadline'
,
in_new_bugmail
=>
1
},
{
name
=>
'commenter'
,
desc
=>
'Commenter'
},
{
name
=>
'flagtypes.name'
,
desc
=>
'Flag'
},
{
name
=>
'requestees.login_name'
,
desc
=>
'Flag Requestee'
},
{
name
=>
'setters.login_name'
,
desc
=>
'Flag Setter'
},
{
name
=>
'work_time'
,
desc
=>
'Hours Worked'
},
{
name
=>
'percentage_complete'
,
desc
=>
'Percentage Complete'
},
{
name
=>
'content'
,
desc
=>
'Content'
},
{
name
=>
'attach_data.thedata'
,
desc
=>
'Attachment data'
},
{
name
=>
'attachments.isurl'
,
desc
=>
'Attachment is a URL'
}
);
# Please see comment above before adding any new values to this constant.
###########################################################################
# Changes to the fielddefs --TABLE--
###########################################################################
...
...
@@ -529,78 +464,7 @@ use constant OLD_FIELD_DEFS => (
# these particular schema changes before we make any other schema changes.
Bugzilla::Install::DB::
update_fielddefs_definition
();
# Create field definitions
foreach
my
$definition
(
OLD_FIELD_DEFS
)
{
Bugzilla::Field::
create_or_update
(
$definition
);
}
# Delete or adjust old field definitions.
# Oops. Bug 163299
$dbh
->
do
(
"DELETE FROM fielddefs WHERE name='cc_accessible'"
);
# Oops. Bug 215319
$dbh
->
do
(
"DELETE FROM fielddefs WHERE name='requesters.login_name'"
);
# This field was never tracked in bugs_activity, so it's safe to delete.
$dbh
->
do
(
"DELETE FROM fielddefs WHERE name='attachments.thedata'"
);
# 2005-11-13 LpSolit@gmail.com - Bug 302599
# One of the field names was a fragment of SQL code, which is DB dependent.
# We have to rename it to a real name, which is DB independent.
my
$new_field_name
=
'days_elapsed'
;
my
$field_description
=
'Days since bug changed'
;
my
(
$old_field_id
,
$old_field_name
)
=
$dbh
->
selectrow_array
(
'SELECT id, name
FROM fielddefs
WHERE description = ?'
,
undef
,
$field_description
);
if
(
$old_field_id
&&
(
$old_field_name
ne
$new_field_name
))
{
print
"SQL fragment found in the 'fielddefs' table...\n"
;
print
"Old field name: "
.
$old_field_name
.
"\n"
;
# We have to fix saved searches first. Queries have been escaped
# before being saved. We have to do the same here to find them.
$old_field_name
=
url_quote
(
$old_field_name
);
my
$broken_named_queries
=
$dbh
->
selectall_arrayref
(
'SELECT userid, name, query
FROM namedqueries WHERE '
.
$dbh
->
sql_istrcmp
(
'query'
,
'?'
,
'LIKE'
),
undef
,
"%=$old_field_name%"
);
my
$sth_UpdateQueries
=
$dbh
->
prepare
(
'UPDATE namedqueries SET query = ?
WHERE userid = ? AND name = ?'
);
print
"Fixing saved searches...\n"
if
scalar
(
@$broken_named_queries
);
foreach
my
$named_query
(
@$broken_named_queries
)
{
my
(
$userid
,
$name
,
$query
)
=
@$named_query
;
$query
=~
s/=\Q$old_field_name\E(&|$)/=$new_field_name$1/gi
;
$sth_UpdateQueries
->
execute
(
$query
,
$userid
,
$name
);
}
# We now do the same with saved chart series.
my
$broken_series
=
$dbh
->
selectall_arrayref
(
'SELECT series_id, query
FROM series WHERE '
.
$dbh
->
sql_istrcmp
(
'query'
,
'?'
,
'LIKE'
),
undef
,
"%=$old_field_name%"
);
my
$sth_UpdateSeries
=
$dbh
->
prepare
(
'UPDATE series SET query = ?
WHERE series_id = ?'
);
print
"Fixing saved chart series...\n"
if
scalar
(
@$broken_series
);
foreach
my
$series
(
@$broken_series
)
{
my
(
$series_id
,
$query
)
=
@$series
;
$query
=~
s/=\Q$old_field_name\E(&|$)/=$new_field_name$1/gi
;
$sth_UpdateSeries
->
execute
(
$query
,
$series_id
);
}
# Now that saved searches have been fixed, we can fix the field name.
print
"Fixing the 'fielddefs' table...\n"
;
print
"New field name: "
.
$new_field_name
.
"\n"
;
$dbh
->
do
(
'UPDATE fielddefs SET name = ? WHERE id = ?'
,
undef
,
(
$new_field_name
,
$old_field_id
));
}
Bugzilla::Field::
create_or_update
(
{
name
=>
$new_field_name
,
desc
=>
$field_description
});
Bugzilla::Field::
populate_field_definitions
();
###########################################################################
# Create initial test product if there are no products present.
...
...
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