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
a1dfde52
Commit
a1dfde52
authored
Feb 25, 2005
by
travis%sedsystems.ca
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 172383 : checksetup.pl : spelling, wording, and whitespace fixes
Patch by travis & timeless r=timeless, travis a=myk
parent
fa9b63f5
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
284 additions
and
205 deletions
+284
-205
checksetup.pl
checksetup.pl
+284
-205
No files found.
checksetup.pl
View file @
a1dfde52
...
...
@@ -33,56 +33,52 @@
# Max Kanat-Alexander <mkanat@kerio.com>
#
#
# Direct any questions on this source code to
#
# Holger Schurig <holgerschurig@nikocity.de>
#
#
#
# Hey, what's this?
#
# 'checksetup.pl' is a script that is supposed to run during installation
# time and also after every upgrade.
#
# The goal of this script is to make the installation even
more easy
.
# It does
so
by doing things for you as well as testing for problems
#
early
.
# The goal of this script is to make the installation even
easier
.
# It does
this
by doing things for you as well as testing for problems
#
in advance
.
#
#
And you can re-run it whenever you want. Especially after Bugzilla
#
gets updated you SHOULD rerun it. Because then it may update your
#
SQL table definitions so that they are again in sync
with the code.
#
You can run the script whenever you like. You SHOULD run it after
#
you update Bugzilla, because it may then update your SQL table
#
definitions to resync them
with the code.
#
#
So, currently this module does
:
#
Currently, this module does the following
:
#
# - check for required perl modules
# - set defaults for local configuration variables
# - create and populate the data directory after installation
# - set the proper rights for the *.cgi, *.html
... etc
files
# -
check if
the code can access MySQL
# - creates the database 'bugs' if
the database
does not exist
# - set the proper rights for the *.cgi, *.html
, etc.
files
# -
verify that
the code can access MySQL
# - creates the database 'bugs' if
it
does not exist
# - creates the tables inside the database if they don't exist
# - automatically changes the table definitions
of older BugZilla
#
installations
# - automatically changes the table definitions
if they are from
#
an older version of Bugzilla
# - populates the groups
# - put the first user into all groups so that the system can
# be administrated
# - changes
already
existing SQL tables if you change your local
# - changes
pre
existing SQL tables if you change your local
# settings, e.g. when you add a new platform
# - ... and a whole lot more.
#
#
People that install this module locally are not supposed
to modify
# this script
. This is done by shifting the user settable stuff into
#
a local configuration file 'localconfig'. When this file get's
#
changed and 'checkconfig.pl' will be re-run, then the user
changes
#
There should be no need for Bugzilla Administrators
to modify
# this script
; all user-configurable stuff has been moved
#
into a local configuration file called 'localconfig'. When that file
#
in changed and 'checkconfig.pl' is run, then the user's
changes
# will be reflected back into the database.
#
# Developers
however
have to modify this file at various places. To
# make this easier,
I have added some special comments that one can
#
search for
.
# Developers
, however,
have to modify this file at various places. To
# make this easier,
there are some special tags for which one
#
can search
.
#
# To Search for
#
# add/delete local configuration variables --LOCAL--
# check for more
prerequired modules
--MODULES--
# check for more
required modules
--MODULES--
# change the defaults for local configuration vars --LOCAL--
# update the assigned file permissions --CHMOD--
# add more MySQL-related checks --MYSQL--
...
...
@@ -90,23 +86,24 @@
# add more groups --GROUPS--
# create initial administrator account --ADMIN--
#
# Note: sometimes those special comments occur more th
e
n once. For
# example, --LOCAL-- is at least 3 times in this code! --TABLE--
#
also is used more than once. So search for every occu
rence!
# Note: sometimes those special comments occur more th
a
n once. For
# example, --LOCAL-- is
used
at least 3 times in this code! --TABLE--
#
is also used more than once, so search for each and every occur
rence!
#
# To operate checksetup non-interactively, run it with a single argument
# specifying a filename with the information usually obtained by
# prompting the user or by editing localconfig. Only information
# superceding defaults from LocalVar() function calls needs to be
# specified.
# specifying a filename that contains the information usually obtained by
# prompting the user or by editing localconfig.
#
# The format of that file is
....
# The format of that file is
as follows:
#
# $answer{'db_host'} = '$db_host = "localhost";
# $db_driver = "mydbdriver";
#
# $answer{'db_host'} = q[
# $db_host = 'localhost';
# $db_driver = 'mydbdriver';
# $db_port = 3306;
# $db_name = "mydbname";
# $db_user = "mydbuser";';
# $db_name = 'mydbname';
# $db_user = 'mydbuser';
# ];
#
# $answer{'db_pass'} = q[$db_pass = 'mydbpass';];
#
...
...
@@ -116,6 +113,9 @@
# $answer{'ADMIN_REALNAME'} = 'Joel Peshkin';
#
#
# Note: Only information that supersedes defaults from LocalVar()
# function calls needs to be specified in this file.
#
use
strict
;
...
...
@@ -274,7 +274,7 @@ sub have_vers {
return
$vok
;
}
# Check versions of dependencies. 0 for version = any version accept
i
ble
# Check versions of dependencies. 0 for version = any version accept
a
ble
my
$modules
=
[
{
name
=>
'AppConfig'
,
...
...
@@ -377,15 +377,16 @@ if ($^O =~ /MSWin32/i && !$silent) {
if
((
!
$gd
||
!
$chartbase
)
&&
!
$silent
)
{
print
"If you you want to see graphical bug charts (plotting historical "
;
print
"data over \ntime), you should install libgd and the following Perl "
;
print
"modules:\n\n"
;
print
"data over \ntime), you should install libgd and the following Perl "
;
print
"modules:\n\n"
;
print
"GD: "
.
install_command
(
"GD"
)
.
"\n"
if
!
$gd
;
print
"Chart: "
.
install_command
(
"Chart::Base"
)
.
"\n"
if
!
$chartbase
;
print
"\n"
;
}
if
(
!
$xmlparser
&&
!
$silent
)
{
print
"If you want to use the bug import/export feature to move bugs to
or from
\n"
,
"other bugzilla installations, you will need to install the XML::Parser module by\n
"
,
"
running (as $::root):\n\n"
,
print
"If you want to use the bug import/export feature to move bugs to\n"
,
"or from other bugzilla installations, you will need to install\n
"
,
"the XML::Parser module by
running (as $::root):\n\n"
,
" "
.
install_command
(
"XML::Parser"
)
.
"\n\n"
;
}
if
((
!
$gd
||
!
$gdgraph
||
!
$gdtextalign
)
&&
!
$silent
)
{
...
...
@@ -407,8 +408,8 @@ if (!$patchreader && !$silent) {
if
(
%
missing
)
{
print
"\n\n"
;
print
"Bugzilla requires some Perl modules which are either missing from
your
\n"
,
"
system, or the version on your system is too old.\n"
,
print
"Bugzilla requires some Perl modules which are either missing from\n"
,
"your
system, or the version on your system is too old.\n"
,
"They can be installed by running (as $::root) the following:\n"
;
foreach
my
$module
(
keys
%
missing
)
{
print
" "
.
install_command
(
"$module"
)
.
"\n"
;
...
...
@@ -453,10 +454,10 @@ use Bugzilla::Config qw(:DEFAULT :admin :locations);
# This is quite tricky. But fun!
#
# First we read the file 'localconfig'. Then we check if the variables we
# need are defined. If not,
localconfig will be amended by the new settings
#
and the user informed to check this. The program then stops
.
# need are defined. If not,
we will append the new settings to
#
localconfig, instruct the user to check them, and stop
.
#
# Why do it this way
around
?
# Why do it this way?
#
# Assume we will enhance Bugzilla and eventually more local configuration
# stuff arises on the horizon.
...
...
@@ -523,13 +524,13 @@ LocalVar('index_html', <<'END');
# With the introduction of a configurable index page using the
# template toolkit, Bugzilla's main index page is now index.cgi.
# Most web servers will allow you to use index.cgi as a directory
# index
and many come preconfigured that way, however if yours
#
doesn't
you'll need an index.html file that provides redirection
# index
, and many come preconfigured that way, but if yours doesn't
#
then
you'll need an index.html file that provides redirection
# to index.cgi. Setting $index_html to 1 below will allow
# checksetup.pl to create one for you if it doesn't exist.
# NOTE: checksetup.pl will not replace an existing file, so if you
# wish to have checksetup.pl create one for you, you must
# make sure that
there isn't already an index.html
# make sure that
index.html doesn't already exist
$index_html
=
0
;
END
...
...
@@ -563,11 +564,12 @@ if (!LocalVarExists('interdiffbin')) {
my
$interdiff_executable
;
if
(
$^O
!~
/MSWin32/i
)
{
$interdiff_executable
=
`which interdiff`
;
if
(
$interdiff_executable
=~
/no interdiff/
||
$interdiff_executable
eq
''
)
{
if
(
$interdiff_executable
=~
/no interdiff/
||
$interdiff_executable
eq
''
)
{
if
(
!
$silent
)
{
print
"\nOPTIONAL NOTE: If you want to "
;
print
"
be able to use the\n 'difference between two patches'
"
;
print
"
feature
of Bugzilla (requires\n the PatchReader Perl module "
;
print
"\nOPTIONAL NOTE: If you want to
be able to
"
;
print
"
use the\n 'difference between two patches' feature
"
;
print
"of Bugzilla (requires\n the PatchReader Perl module "
;
print
"as well), you should install\n patchutils from "
;
print
"http://cyberelk.net/tim/patchutils/\n\n"
;
}
...
...
@@ -611,7 +613,7 @@ if (!LocalVarExists('diffpath')) {
#
# The interdiff feature needs diff, so we have to have that path.
# Please specify
only the directory name, with no
trailing slash.
# Please specify
the directory name only; do not use
trailing slash.
\
$diffpath
=
"$diff_binaries"
;
END
}
...
...
@@ -619,7 +621,7 @@ END
LocalVar
(
'create_htaccess'
,
<<
'END'
);
#
# If you are using Apache
for
your web server, Bugzilla can create .htaccess
# If you are using Apache
as
your web server, Bugzilla can create .htaccess
# files for you that will instruct Apache not to serve files that shouldn't
# be accessed from the web (like your local configuration data and non-cgi
# executable files). For this to work, the directory your Bugzilla
...
...
@@ -642,15 +644,15 @@ if ($^O !~ /MSWin32/i) {
LocalVar
(
'webservergroup'
,
<<
"END"
);
#
# This is the group your web server runs
on
.
# This is the group your web server runs
as
.
# If you have a windows box, ignore this setting.
# If you do not have access to the group your web server runs under,
# set this to "". If you do set this to "", then your Bugzilla installation
# will be _VERY_ insecure, because some files will be world readable/writable,
# and so anyone who can get local access to your machine can do whatever they
# want. You should only have this set to "" if this is a testing installation
# and you cannot set this up any other way. YOU HAVE BEEN WARNED
.
# If you set this to anything
besides
"", you will need to run checksetup.pl
# and you cannot set this up any other way. YOU HAVE BEEN WARNED
!
# If you set this to anything
other than
"", you will need to run checksetup.pl
# as $::root, or as a user who is a member of the specified group.
\
$webservergroup
=
"$webservergroup_default"
;
END
...
...
@@ -665,38 +667,39 @@ LocalVar('db_driver', '
#
$db_driver = "mysql";
'
);
LocalVar
(
'db_host'
,
'
LocalVar
(
'db_host'
,
q[
#
# How to access the SQL database:
#
$db_host =
"localhost"
; # where is the database?
$db_host =
'localhost'
; # where is the database?
$db_port = 3306; # which port to use
$db_name =
"bugs"
; # name of the MySQL database
$db_user =
"bugs"
; # user to attach to the MySQL database
'
);
LocalVar
(
'db_pass'
,
'
$db_name =
'bugs'
; # name of the MySQL database
$db_user =
'bugs'
; # user to attach to the MySQL database
]
);
LocalVar
(
'db_pass'
,
q[
#
# Enter your database password here. It
\
's normally advisable to specify
# Enter your database password here. It's normally advisable to specify
# a password for your bugzilla database user.
# If you use apostrophe (\') or a backslash (\\) in your password, you\'ll
# need to escape it by preceding it with a \\ character. (\\\') or (\\\\)
# If you use apostrophe (') or a backslash (\) in your password, you'll
# need to escape it by preceding it with a '\' character. (\') or (\\)
# (Far simpler just not to use those characters.)
#
$db_pass =
\'\
';
'
);
$db_pass =
'
';
]
);
LocalVar
(
'db_sock'
,
'
LocalVar
(
'db_sock'
,
q[
# Enter a path to the unix socket for mysql. If this is blank, then mysql\'s
# compiled-in default will be used. You probably want that.
$db_sock =
\'\
';
'
);
$db_sock =
'
';
]
);
LocalVar
(
'db_check'
,
'
LocalVar
(
'db_check'
,
q[
#
# Should checksetup.pl try to
check if
your MySQL setup is correct?
# (with some combinations of MySQL/Msql-mysql/Perl/moonphase this doesn
\
't work)
# Should checksetup.pl try to
verify that
your MySQL setup is correct?
# (with some combinations of MySQL/Msql-mysql/Perl/moonphase this doesn't work)
#
$db_check = 1;
'
);
]
);
my
@deprecatedvars
;
push
(
@deprecatedvars
,
'@severities'
)
if
(
LocalVarExists
(
'severities'
));
...
...
@@ -717,9 +720,9 @@ if (LocalVarExists('mysqlpath')) {
}
if
(
$newstuff
ne
""
)
{
print
"\nThis version of Bugzilla contains some variables that you may
want
\n"
,
"
to change and adapt to your local settings. Please edit the fil
e\n"
,
"'$localconfig' and rerun checksetup.pl\n\n"
,
print
"\nThis version of Bugzilla contains some variables that you may \n"
,
"
want to change and adapt to your local settings. Please edit th
e\n"
,
"
file
'$localconfig' and rerun checksetup.pl\n\n"
,
"The following variables are new to localconfig since you last ran\n"
,
"checksetup.pl: $newstuff\n\n"
;
exit
;
...
...
@@ -727,7 +730,7 @@ if ($newstuff ne "") {
# 2000-Dec-18 - justdave@syndicomm.com - see Bug 52921
# This is a hack to read in the values defined in localconfig without getting
# them
predeclar
ed at compile time if they're missing from localconfig.
# them
defin
ed at compile time if they're missing from localconfig.
# Ideas swiped from pp. 281-282, O'Reilly's "Programming Perl 2nd Edition"
# Note that we won't need to do this in globals.pl because globals.pl couldn't
# care less whether they were defined ahead of time or not.
...
...
@@ -790,7 +793,7 @@ EOF
}
}
else
{
# Theres no webservergroup, this is very very very very bad.
# There
'
s no webservergroup, this is very very very very bad.
# However, if we're being run on windows, then this option doesn't
# really make sense. Doesn't make it any more secure either, though,
# but don't print the message, since they can't do anything about it.
...
...
@@ -837,17 +840,17 @@ unless (-d $datadir && -e "$datadir/nomail") {
}
unless
(
-
d
$attachdir
)
{
unless
(
-
d
$attachdir
)
{
print
"Creating local attachments directory ...\n"
;
# permissions for non-webservergroup are fixed later on
mkdir
$attachdir
,
0770
;
}
}
# 2000-12-14 New graphing system requires a directory to put the graphs in
# This code copied from what happens for the data dir above.
# If the graphs dir is not present, we assume that they have been using
# a Bugzilla with the old data format, and
so
upgrade their data files.
# a Bugzilla with the old data format, and upgrade their data files.
# NB - the graphs dir isn't movable yet, unlike the datadir
unless
(
-
d
'graphs'
)
{
...
...
@@ -910,7 +913,8 @@ unless (-d 'graphs') {
}
}
else
{
print
"Oh dear, input line $. of $in_file had "
.
scalar
(
@data
)
.
" fields\n"
;
print
"Oh dear, input line $. of $in_file had "
.
scalar
(
@data
)
.
" fields\n"
;
print
"This was unexpected. You may want to check your data files.\n"
;
}
...
...
@@ -1032,7 +1036,7 @@ END
print
"Creating $attachdir/.htaccess...\n"
;
open
HTACCESS
,
">$attachdir/.htaccess"
;
print
HTACCESS
<<'END';
# nothing in this directory is retrievable unless overriden by an .htaccess
# nothing in this directory is retrievable unless overrid
d
en by an .htaccess
# in a subdirectory;
deny from all
END
...
...
@@ -1043,7 +1047,7 @@ END
print
"Creating Bugzilla/.htaccess...\n"
;
open
HTACCESS
,
'>'
,
'Bugzilla/.htaccess'
;
print
HTACCESS
<<'END';
# nothing in this directory is retrievable unless overriden by an .htaccess
# nothing in this directory is retrievable unless overrid
d
en by an .htaccess
# in a subdirectory
deny from all
END
...
...
@@ -1085,7 +1089,7 @@ END
open
HTACCESS
,
'>'
,
"$webdotdir/.htaccess"
;
print
HTACCESS
<<'END';
# Restrict access to .dot files to the public webdot server at research.att.com
# if research.att.com ever change
d
their IP, or if you use a different
# if research.att.com ever change
s
their IP, or if you use a different
# webdot server, you'll need to edit this
<FilesMatch \.dot$>
Allow from 192.20.225.10
...
...
@@ -1145,8 +1149,8 @@ unless ($switch{'no_templates'}) {
#Check that the directory was really removed
if
(
-
e
"$datadir/template"
)
{
print
"\n\n"
;
print
"The directory '$datadir/template' could not be removed.
Please
\n"
;
print
"remove it manually and rerun checksetup.pl.\n\n"
;
print
"The directory '$datadir/template' could not be removed.\n"
;
print
"
Please
remove it manually and rerun checksetup.pl.\n\n"
;
exit
;
}
}
...
...
@@ -1173,7 +1177,7 @@ unless ($switch{'no_templates'}) {
}
# Precompile stuff. This speeds up initial access (so the template isn't
# compiled multiple times simul
a
taneously by different servers), and helps
# compiled multiple times simultaneously by different servers), and helps
# to get the permissions right.
sub
compile
{
my
$name
=
$
File::Find::
name
;
...
...
@@ -1234,7 +1238,7 @@ unless ($switch{'no_templates'}) {
})
||
die
(
"Could not create Template Provider: "
.
Template::
Provider
->
error
()
.
"\n"
);
# Traverse the template hierachy.
# Traverse the template hiera
r
chy.
find
({
wanted
=>
\&
compile
,
no_chdir
=>
1
},
$::templatepath
);
}
}
...
...
@@ -1253,8 +1257,8 @@ if (@oldparams) {
||
die
"$0: Can't open old-params.txt for writing: $!\n"
;
print
"The following parameters are no longer used in Bugzilla, "
.
"and so have been\nremoved from your parameters file and
"
.
"appended
to old-params.txt:\n"
;
"and so have been\nmoved from your parameters file
"
.
"in
to old-params.txt:\n"
;
foreach
my
$p
(
@oldparams
)
{
my
(
$item
,
$value
)
=
@
{
$p
};
...
...
@@ -1278,7 +1282,7 @@ WriteParams();
#
# Here we use --CHMOD-- and friends to set the file permissions
#
# The rationale is that the web server generally runs as apache
and
so the cgi
# The rationale is that the web server generally runs as apache
,
so the cgi
# scripts should not be writable for apache, otherwise someone may be possible
# to change the cgi's when exploiting some security flaw somewhere (not
# necessarily in Bugzilla!)
...
...
@@ -1296,7 +1300,7 @@ WriteParams();
# Not all directories have permissions changed on them. i.e., changing ./CVS
# to be 0640 is bad.
#
# Fixed bug in chmod invo
k
ation. chmod (at least on my linux box running perl
# Fixed bug in chmod invo
c
ation. chmod (at least on my linux box running perl
# 5.005 needs a valid first argument, not 0.
#
# (end changes, 03/14/00 by SML)
...
...
@@ -1306,7 +1310,7 @@ WriteParams();
# Fix file permissions for non-webservergroup installations (see
# http://bugzilla.mozilla.org/show_bug.cgi?id=71555). I'm setting things
# by default to world readable/executable for all files, and
# world-writ
e
able (with sticky on) to data and graphs.
# world-writable (with sticky on) to data and graphs.
#
# These are the files which need to be marked executable
...
...
@@ -1360,7 +1364,8 @@ sub fixPerms {
#printf ("Changing $file to %o\n", $execperm);
chmod
$execperm
,
$file
;
fixPerms
(
"$file/.htaccess"
,
$owner
,
$group
,
$umask
,
$do_dirs
);
fixPerms
(
"$file/*"
,
$owner
,
$group
,
$umask
,
$do_dirs
);
# do the contents of the directory
# do the contents of the directory
fixPerms
(
"$file/*"
,
$owner
,
$group
,
$umask
,
$do_dirs
);
}
}
}
...
...
@@ -1372,8 +1377,8 @@ if ($^O !~ /MSWin32/i) {
my
$webservergid
=
getgrnam
(
$my_webservergroup
)
or
die
(
"no such group: $my_webservergroup"
);
# chown needs to be called with a valid uid, not 0. $< returns the
# caller's uid. Maybe there should be a $bugzillauid, and call
with that
# userid.
# caller's uid. Maybe there should be a $bugzillauid, and call
#
with that
userid.
fixPerms
(
'.htaccess'
,
$<
,
$webservergid
,
027
);
# glob('*') doesn't catch dotfiles
fixPerms
(
"$datadir/.htaccess"
,
$<
,
$webservergid
,
027
);
fixPerms
(
"$datadir/duplicates"
,
$<
,
$webservergid
,
027
,
1
);
...
...
@@ -1392,8 +1397,8 @@ if ($^O !~ /MSWin32/i) {
fixPerms
(
'js'
,
$<
,
$webservergid
,
027
,
1
);
chmod
0644
,
'globals.pl'
;
# Don't use fixPerms here, because it won't change perms
on the directory
#
unless it
s using recursion
# Don't use fixPerms here, because it won't change perms
#
on the directory unless it'
s using recursion
chown
$<
,
$webservergid
,
$datadir
;
chmod
0771
,
$datadir
;
chown
$<
,
$webservergid
,
'graphs'
;
...
...
@@ -1418,8 +1423,8 @@ if ($^O !~ /MSWin32/i) {
fixPerms
(
'skins'
,
$<
,
$gid
,
022
,
1
);
fixPerms
(
'js'
,
$<
,
$gid
,
022
,
1
);
# Don't use fixPerms here, because it won't change perms
on the directory
#
unless it
s using recursion
# Don't use fixPerms here, because it won't change perms
#
on the directory unless it'
s using recursion
chown
$<
,
$gid
,
$datadir
;
chmod
0777
,
$datadir
;
chown
$<
,
$gid
,
'graphs'
;
...
...
@@ -1522,7 +1527,7 @@ This might have several reasons:
* MySQL is running, but the rights are not set correct. Go and read the
Bugzilla Guide in the doc directory and all parts of the MySQL
documentation.
* There is a
n
subtle problem with Perl, DBI, DBD::mysql and MySQL. Make
* There is a subtle problem with Perl, DBI, DBD::mysql and MySQL. Make
sure all settings in '$localconfig' are correct. If all else fails, set
'\$db_check' to zero.\n
EOF
...
...
@@ -1571,7 +1576,7 @@ if( Param('webdotbase') && Param('webdotbase') !~ /^https?:/ ) {
open
HTACCESS
,
"$webdotdir/.htaccess"
;
if
(
!
grep
(
/png/
,
<
HTACCESS
>
))
{
print
"Dependency graph images are not accessible.\n"
;
print
"Delete $webdotdir/.htaccess and re-run checksetup.pl to rectify
.\n"
;
print
"delete $webdotdir/.htaccess and re-run checksetup.pl to fix
.\n"
;
}
close
HTACCESS
;
}
...
...
@@ -1598,9 +1603,10 @@ print "\n" unless $silent;
# mysql> exit;
# $ ./checksetup.pl
#
# If you change one of those field definitions, then also go below to the
# next occurence of the string --TABLE-- (near the end of this file) to
# add the code that updates older installations automatically.
# If you change one of the field definitions, then you must also go to the
# next occurrence of the string --TABLE-- (near the end of this file) and
# add in some conditional code that will automatically update an older
# installation.
#
...
...
@@ -1940,8 +1946,8 @@ $table{duplicates} =
dupe mediumint(9) not null primary key'
;
# 2001-06-21, myk@mozilla.org, bug 77473:
# Stores the tokens users receive when
they want to change their password
#
or email address
. Tokens provide an extra measure of security for these changes.
# Stores the tokens users receive when
a password or email change is
#
requested
. Tokens provide an extra measure of security for these changes.
$table
{
tokens
}
=
'userid mediumint not null ,
issuedate datetime not null ,
...
...
@@ -1991,8 +1997,6 @@ $table{bug_group_map} =
unique(bug_id, group_id),
index(group_id)'
;
# 2002-07-19, davef@tetsubo.com, bug 67950:
# 2005-02-20, LpSolit@gmail.com, bug 277504
# Store quips in the db.
$table
{
quips
}
=
'quipid mediumint not null auto_increment primary key,
...
...
@@ -2011,7 +2015,6 @@ $table{group_control_map} =
unique(product_id, group_id),
index(group_id)'
;
# 2003-06-26 gerv@gerv.net, bug 16009
# Generic charting over time of arbitrary queries.
# Queries are disabled when frequency == 0.
$table
{
series
}
=
...
...
@@ -2152,9 +2155,10 @@ while (my ($name, $type) = $sth->fetchrow_array) {
}
if
(
scalar
(
@isam_tables
))
{
print
"One or more of the tables in your existing MySQL database are of type ISAM.\n"
.
"ISAM tables are deprecated in MySQL 3.23 and don't support more than 16 indexes\n"
.
"per table, which Bugzilla needs. Converting your ISAM tables to type MyISAM:\n\n"
;
print
"One or more of the tables in your existing MySQL database are of\n"
.
"type ISAM. ISAM tables are deprecated in MySQL 3.23 and don't \n "
.
"support more than 16 indexes per table, which Bugzilla needs. \n"
.
"Converting your ISAM tables to type MyISAM:\n\n"
;
foreach
my
$table
(
@isam_tables
)
{
print
"Converting table $table... "
;
$dbh
->
do
(
"ALTER TABLE $table TYPE = MYISAM"
);
...
...
@@ -2175,7 +2179,8 @@ while (my ($tabname, $fielddef) = each %table) {
print
"Creating table $tabname ...\n"
;
$dbh
->
do
(
"CREATE TABLE $tabname (\n$fielddef\n) TYPE = MYISAM"
)
or
die
"Could not create table '$tabname'. Please check your '$my_db_driver' access.\n"
;
or
die
"Could not create table '$tabname'. "
.
"Please check your '$my_db_driver' access.\n"
;
}
###########################################################################
...
...
@@ -2195,8 +2200,8 @@ sub GroupDoesExist ($)
#
# This subroutine
checks if a group exist. If not, it will be automatically
#
created with
the next available groupid
# This subroutine
ensures that a group exists. If not, it will be created
#
automatically, and given
the next available groupid
#
sub
AddGroup
{
...
...
@@ -2238,8 +2243,10 @@ sub AddFDef ($$$) {
"(fieldid, name, description, mailhead, sortkey) VALUES "
.
"($fieldid, $name, $description, $mailhead, $headernum)"
);
}
else
{
$dbh
->
do
(
"UPDATE fielddefs SET name = $name, description = $description, "
.
"mailhead = $mailhead, sortkey = $headernum WHERE fieldid = $fieldid"
);
$dbh
->
do
(
"UPDATE fielddefs "
.
"SET name = $name, description = $description, "
.
"mailhead = $mailhead, sortkey = $headernum "
.
"WHERE fieldid = $fieldid"
);
}
$headernum
++
;
}
...
...
@@ -2379,9 +2386,7 @@ sub DropIndexes ($)
$dbh
->
do
(
"ALTER TABLE $table DROP INDEX $$ref[2]"
);
}
$SEEN
{
$$ref
[
2
]}
=
1
;
}
}
# mkanat@kerio.com - bug 17453
...
...
@@ -2453,8 +2458,9 @@ $sth = $dbh->prepare("SELECT description FROM products");
$sth
->
execute
;
unless
(
$sth
->
rows
)
{
print
"Creating initial dummy product 'TestProduct' ...\n"
;
$dbh
->
do
(
'INSERT INTO products(name, description, milestoneurl, disallownew, votesperuser, votestoconfirm) VALUES ("TestProduct",
"This is a test product. This ought to be blown away and '
.
$dbh
->
do
(
'INSERT INTO products(name, description, milestoneurl, disallownew, votesperuser, votestoconfirm) '
.
'VALUES ("TestProduct", '
.
'"This is a test product. This ought to be blown away and '
.
'replaced with real stuff in a finished installation of '
.
'bugzilla.", "", 0, 0, 0)'
);
# We could probably just assume that this is "1", but better
...
...
@@ -2464,8 +2470,9 @@ unless ($sth->rows) {
$dbh
->
do
(
qq{INSERT INTO versions (value, product_id) VALUES ("other", $product_id)}
);
# note: since admin user is not yet known, components gets a 0 for
# initialowner and this is fixed during final checks.
$dbh
->
do
(
"INSERT INTO components (name, product_id, description, initialowner, initialqacontact)
VALUES ("
.
$dbh
->
do
(
"INSERT INTO components (name, product_id, description, "
.
"initialowner, initialqacontact) "
.
"VALUES ("
.
"'TestComponent', $product_id, "
.
"'This is a test component in the test product database. "
.
"This ought to be blown away and replaced with real stuff in "
.
...
...
@@ -2798,7 +2805,8 @@ if (GetFieldDef('bugs', 'long_desc')) {
"(login_name, cryptpassword,"
.
" disabledtext) VALUES ("
.
$dbh
->
quote
(
$name
)
.
", "
.
$dbh
->
quote
(
bz_crypt
(
'okthen'
))
.
", "
.
", "
.
$dbh
->
quote
(
bz_crypt
(
'okthen'
))
.
", "
.
"'Account created only to maintain database integrity')"
);
$who
=
$dbh
->
bz_last_key
(
'profiles'
,
'userid'
);
}
...
...
@@ -2860,7 +2868,7 @@ if (GetFieldDef('bugs_activity', 'field')) {
# 2000-01-18 New email-notification scheme uses a new field in the bug to
# record when email notifications were last sent about this bug. Also,
# added
a user pref whether a user wants to use the brand new
experimental
# added
'newemailtech' field to record if user wants to use the
experimental
# stuff.
# 2001-04-29 jake@bugzilla.org - The newemailtech field is no longer needed
# http://bugzilla.mozilla.org/show_bugs.cgi?id=71552
...
...
@@ -2929,58 +2937,77 @@ AddField('profiles', 'mybugslink', 'tinyint not null default 1');
AddField
(
'namedqueries'
,
'linkinfooter'
,
'tinyint not null'
);
if
((
$_
=
GetFieldDef
(
'components'
,
'initialowner'
))
and
(
$_
->
[
1
]
eq
'tinytext'
))
{
$sth
=
$dbh
->
prepare
(
"SELECT program, value, initialowner, initialqacontact FROM components"
);
if
((
$_
=
GetFieldDef
(
'components'
,
'initialowner'
))
and
(
$_
->
[
1
]
eq
'tinytext'
))
{
$sth
=
$dbh
->
prepare
(
"SELECT program, value, initialowner, initialqacontact "
.
"FROM components"
);
$sth
->
execute
();
while
(
my
(
$program
,
$value
,
$initialowner
)
=
$sth
->
fetchrow_array
())
{
$initialowner
=~
s/([\\\'])/\\$1/g
;
$initialowner
=~
s/\0/\\0/g
;
$program
=~
s/([\\\'])/\\$1/g
;
$program
=~
s/\0/\\0/g
;
$value
=~
s/([\\\'])/\\$1/g
;
$value
=~
s/\0/\\0/g
;
my
$s2
=
$dbh
->
prepare
(
"SELECT userid FROM profiles WHERE login_name = '$initialowner'"
);
my
$s2
=
$dbh
->
prepare
(
"SELECT userid "
.
"FROM profiles "
.
"WHERE login_name = '$initialowner'"
);
$s2
->
execute
();
my
$initialownerid
=
$s2
->
fetchrow_array
();
unless
(
defined
$initialownerid
)
{
print
"Warning: You have an invalid initial owner '$initialowner' in program '$program', component '$value'!\n"
;
print
"Warning: You have an invalid initial owner '$initialowner'\n"
.
"in component '$value' of program '$program'. !\n"
;
$initialownerid
=
0
;
}
my
$update
=
"UPDATE components SET initialowner = $initialownerid "
.
"WHERE program = '$program' AND value = '$value'"
;
my
$s3
=
$dbh
->
prepare
(
"UPDATE components SET initialowner = $initialownerid "
.
"WHERE program = '$program' AND value = '$value';"
);
my
$update
=
"UPDATE components "
.
"SET initialowner = $initialownerid "
.
"WHERE program = '$program' "
.
"AND value = '$value'"
;
my
$s3
=
$dbh
->
prepare
(
"UPDATE components "
.
"SET initialowner = $initialownerid "
.
"WHERE program = '$program' "
.
"AND value = '$value';"
);
$s3
->
execute
();
}
ChangeFieldType
(
'components'
,
'initialowner'
,
'mediumint'
);
}
if
((
$_
=
GetFieldDef
(
'components'
,
'initialqacontact'
))
and
(
$_
->
[
1
]
eq
'tinytext'
))
{
$sth
=
$dbh
->
prepare
(
"SELECT program, value, initialqacontact, initialqacontact FROM components"
);
if
((
$_
=
GetFieldDef
(
'components'
,
'initialqacontact'
))
and
(
$_
->
[
1
]
eq
'tinytext'
))
{
$sth
=
$dbh
->
prepare
(
"SELECT program, value, initialqacontact, initialqacontact "
.
"FROM components"
);
$sth
->
execute
();
while
(
my
(
$program
,
$value
,
$initialqacontact
)
=
$sth
->
fetchrow_array
())
{
$initialqacontact
=~
s/([\\\'])/\\$1/g
;
$initialqacontact
=~
s/\0/\\0/g
;
$program
=~
s/([\\\'])/\\$1/g
;
$program
=~
s/\0/\\0/g
;
$value
=~
s/([\\\'])/\\$1/g
;
$value
=~
s/\0/\\0/g
;
my
$s2
=
$dbh
->
prepare
(
"SELECT userid FROM profiles WHERE login_name = '$initialqacontact'"
);
my
$s2
=
$dbh
->
prepare
(
"SELECT userid "
.
"FROM profiles "
.
"WHERE login_name = '$initialqacontact'"
);
$s2
->
execute
();
my
$initialqacontactid
=
$s2
->
fetchrow_array
();
unless
(
defined
$initialqacontactid
)
{
if
(
$initialqacontact
ne
''
)
{
print
"Warning: You have an invalid initial QA contact
'
$initialqacontact' in program '$program', component '$value'!\n"
;
print
"Warning: You have an invalid initial QA contact $initialqacontact' in program '$program', component '$value'!\n"
;
}
$initialqacontactid
=
0
;
}
my
$update
=
"UPDATE components SET initialqacontact = $initialqacontactid "
.
my
$update
=
"UPDATE components "
.
"SET initialqacontact = $initialqacontactid "
.
"WHERE program = '$program' AND value = '$value'"
;
my
$s3
=
$dbh
->
prepare
(
"UPDATE components SET initialqacontact = $initialqacontactid "
.
"WHERE program = '$program' AND value = '$value';"
);
my
$s3
=
$dbh
->
prepare
(
"UPDATE components "
.
"SET initialqacontact = $initialqacontactid "
.
"WHERE program = '$program' "
.
"AND value = '$value';"
);
$s3
->
execute
();
}
...
...
@@ -3004,9 +3031,11 @@ $sth = $dbh->prepare("SELECT count(*) from milestones");
$sth
->
execute
();
if
(
!
(
$sth
->
fetchrow_arrayref
()
->
[
0
]))
{
print
"Replacing blank milestones...\n"
;
$dbh
->
do
(
"UPDATE bugs SET target_milestone = '---', delta_ts=delta_ts WHERE target_milestone = ' '"
);
$dbh
->
do
(
"UPDATE bugs "
.
"SET target_milestone = '---', delta_ts=delta_ts "
.
"WHERE target_milestone = ' '"
);
# Populate
milestone table with all exisiting values in
database
# Populate
the milestone table with all existing values in the
database
$sth
=
$dbh
->
prepare
(
"SELECT DISTINCT target_milestone, product FROM bugs"
);
$sth
->
execute
();
...
...
@@ -3025,7 +3054,10 @@ if (!($sth->fetchrow_arrayref()->[0])) {
}
$value
=
$dbh
->
quote
(
$value
);
$product
=
$dbh
->
quote
(
$product
);
my
$s2
=
$dbh
->
prepare
(
"SELECT value FROM milestones WHERE value = $value AND product = $product"
);
my
$s2
=
$dbh
->
prepare
(
"SELECT value "
.
"FROM milestones "
.
"WHERE value = $value "
.
"AND product = $product"
);
$s2
->
execute
();
if
(
!
$s2
->
fetchrow_array
())
...
...
@@ -3103,9 +3135,13 @@ if (!($sth->fetchrow_arrayref()->[0])) {
# populate table
print
(
"Populating duplicates table...\n"
)
unless
$silent
;
$sth
=
$dbh
->
prepare
(
"SELECT longdescs.bug_id, thetext FROM longdescs left JOIN bugs using(bug_id) WHERE (thetext "
.
"regexp '[.*.]{3,3} This bug has been marked as a duplicate of [[:digit:]]{1,5} [.*.]{3,3}') AND (resolution = 'DUPLICATE') ORDER"
.
" BY longdescs.bug_when"
);
$sth
=
$dbh
->
prepare
(
"SELECT longdescs.bug_id, thetext "
.
"FROM longdescs "
.
"LEFT JOIN bugs using(bug_id) "
.
"WHERE (thetext regexp '[.*.]{3,3} This bug has been marked as a duplicate of [[:digit:]]{1,5} [.*.]{3,3}') "
.
"AND (resolution = 'DUPLICATE') "
.
"ORDER BY longdescs.bug_when"
);
$sth
->
execute
();
my
%
dupes
;
...
...
@@ -3117,8 +3153,7 @@ if (!($sth->fetchrow_arrayref()->[0])) {
$dupes
{
$dupe
}
=
$dupe_of
;
}
foreach
$key
(
keys
(
%
dupes
))
{
foreach
$key
(
keys
(
%
dupes
)){
$dupes
{
$key
}
=~
/^.*\*\*\* This bug has been marked as a duplicate of (\d+) \*\*\*$/ms
;
$dupes
{
$key
}
=
$1
;
$dbh
->
do
(
"INSERT INTO duplicates VALUES('$dupes{$key}', '$key')"
);
...
...
@@ -3210,7 +3245,9 @@ ENDTEXT
print
"Fixing password #1... "
;
while
(
my
(
$userid
,
$password
)
=
$sth
->
fetchrow_array
())
{
my
$cryptpassword
=
$dbh
->
quote
(
bz_crypt
(
$password
));
$dbh
->
do
(
"UPDATE profiles SET cryptpassword = $cryptpassword WHERE userid = $userid"
);
$dbh
->
do
(
"UPDATE profiles "
.
"SET cryptpassword = $cryptpassword "
.
"WHERE userid = $userid"
);
++
$i
;
# Let the user know where we are at every 500 records.
print
"$i... "
if
!
(
$i
%
500
);
...
...
@@ -3241,10 +3278,12 @@ if (GetFieldDef('bugs_activity', 'oldvalue')) {
AddField
(
"bugs_activity"
,
"removed"
,
"tinytext"
);
AddField
(
"bugs_activity"
,
"added"
,
"tinytext"
);
# Need to get fieldid's for the fields that have multip
u
le values
# Need to get fieldid's for the fields that have multiple values
my
@multi
=
();
foreach
my
$f
(
"cc"
,
"dependson"
,
"blocked"
,
"keywords"
)
{
my
$sth
=
$dbh
->
prepare
(
"SELECT fieldid FROM fielddefs WHERE name = '$f'"
);
my
$sth
=
$dbh
->
prepare
(
"SELECT fieldid "
.
"FROM fielddefs "
.
"WHERE name = '$f'"
);
$sth
->
execute
();
my
(
$fid
)
=
$sth
->
fetchrow_array
();
push
(
@multi
,
$fid
);
...
...
@@ -3257,7 +3296,8 @@ if (GetFieldDef('bugs_activity', 'oldvalue')) {
oldvalue, newvalue FROM bugs_activity"
);
$sth
->
execute
;
while
(
my
(
$bug_id
,
$who
,
$bug_when
,
$fieldid
,
$oldvalue
,
$newvalue
)
=
$sth
->
fetchrow_array
())
{
# print the iteration count every 500 records so the user knows we didn't die
# print the iteration count every 500 records
# so the user knows we didn't die
print
"$i..."
if
!
(
$i
++
%
500
);
# Make sure (old|new)value isn't null (to suppress warnings)
$oldvalue
||=
""
;
...
...
@@ -3288,7 +3328,7 @@ if (GetFieldDef('bugs_activity', 'oldvalue')) {
$added
=
"?"
;
$removed
=
"?"
;
}
# If the origi
an
l field (old|new)value was full, then this
# If the origi
na
l field (old|new)value was full, then this
# could be incomplete data.
if
(
length
(
$oldvalue
)
==
255
||
length
(
$newvalue
)
==
255
)
{
$added
=
"? $added"
;
...
...
@@ -3309,7 +3349,7 @@ if (GetFieldDef('bugs_activity', 'oldvalue')) {
DropField
(
"bugs_activity"
,
"newvalue"
);
}
# 2001-07-24 jake@bugzilla.org - disabledtext was being handled inconsi
ta
ntly
# 2001-07-24 jake@bugzilla.org - disabledtext was being handled inconsi
ste
ntly
# http://bugzilla.mozilla.org/show_bug.cgi?id=90933
ChangeFieldType
(
"profiles"
,
"disabledtext"
,
"mediumtext not null"
);
...
...
@@ -3324,7 +3364,7 @@ AddField("bugs", "reporter_accessible", "tinyint not null default 1");
AddField
(
"bugs"
,
"cclist_accessible"
,
"tinyint not null default 1"
);
# 2001-08-21 myk@mozilla.org bug84338:
# Add a field
for the attachment ID to the bugs_activity table
, so installations
# Add a field
to the bugs_activity table for the attachment ID
, so installations
# using the attachment manager can record changes to attachments.
AddField
(
"bugs_activity"
,
"attach_id"
,
"mediumint null"
);
...
...
@@ -3332,7 +3372,7 @@ AddField("bugs_activity", "attach_id", "mediumint null");
# Remove logincookies.cryptpassword, and delete entries which become
# invalid
if
(
GetFieldDef
(
"logincookies"
,
"cryptpassword"
))
{
# We need to delete any cookies which are invalid
,
before dropping the
# We need to delete any cookies which are invalid before dropping the
# column
print
"Removing invalid login cookies...\n"
;
...
...
@@ -3405,10 +3445,11 @@ if (-r "$datadir/comments" && -s "$datadir/comments"
$dbh
->
do
(
"INSERT INTO quips (quip) VALUES ("
.
$dbh
->
quote
(
$_
)
.
")"
);
}
print
"The $datadir/comments file (used to store quips) has been copied into\n"
.
"the database, and the $datadir/comments file moved to $datadir/comments.bak - \n"
.
"you can delete this fileonce you're satisfied the migration worked\n"
.
"correctly.\n\n"
;
print
"Quips are now stored in the database, rather than in an external file.\n"
.
"The quips previously stored in $datadir/comments have been copied into\n"
.
"the database, and that file has been renamed to $datadir/comments.bak\n"
.
"You may delete the renamed file once you have confirmed that all your \n"
.
"quips were moved successfully.\n\n"
;
close
COMMENTS
;
rename
(
"$datadir/comments"
,
"$datadir/comments.bak"
);
}
...
...
@@ -3539,14 +3580,16 @@ if (($fielddef = GetFieldDef("attachments", "creation_ts")) &&
# Restrict this as much as possible in order to avoid false positives, and
# keep the db search time down
my
$sth2
=
$dbh
->
prepare
(
"SELECT bug_when FROM longdescs
WHERE bug_id=? AND who=? AND thetext LIKE ?
ORDER BY bug_when "
.
$dbh
->
sql_limit
(
1
));
my
$sth2
=
$dbh
->
prepare
(
"SELECT bug_when FROM longdescs
"
.
"WHERE bug_id=? AND who=? AND thetext LIKE ? "
.
"
ORDER BY bug_when "
.
$dbh
->
sql_limit
(
1
));
while
(
my
(
$bug_id
,
$attach_id
,
$submitter_id
)
=
$sth
->
fetchrow_array
())
{
$sth2
->
execute
(
$bug_id
,
$submitter_id
,
"Created an attachment (id=$attach_id)%"
);
my
(
$when
)
=
$sth2
->
fetchrow_array
();
if
(
$when
)
{
$dbh
->
do
(
"UPDATE attachments SET creation_ts='$when' WHERE attach_id=$attach_id"
);
$dbh
->
do
(
"UPDATE attachments "
.
"SET creation_ts='$when' "
.
"WHERE attach_id=$attach_id"
);
}
else
{
print
"Warning - could not determine correct creation time for attachment $attach_id on bug $bug_id\n"
;
}
...
...
@@ -3659,11 +3702,15 @@ if (GetFieldDef("profiles", "groupset")) {
# Replace old activity log groupset records with lists of names of groups.
# Start by defining the bug_group field and getting its id.
AddFDef
(
"bug_group"
,
"Group"
,
0
);
$sth
=
$dbh
->
prepare
(
"SELECT fieldid FROM fielddefs WHERE name = "
.
$dbh
->
quote
(
'bug_group'
));
$sth
=
$dbh
->
prepare
(
"SELECT fieldid "
.
"FROM fielddefs "
.
"WHERE name = "
.
$dbh
->
quote
(
'bug_group'
));
$sth
->
execute
();
my
(
$bgfid
)
=
$sth
->
fetchrow_array
;
# Get the field id for the old groupset field
$sth
=
$dbh
->
prepare
(
"SELECT fieldid FROM fielddefs WHERE name = "
.
$dbh
->
quote
(
'groupset'
));
$sth
=
$dbh
->
prepare
(
"SELECT fieldid "
.
"FROM fielddefs "
.
"WHERE name = "
.
$dbh
->
quote
(
'groupset'
));
$sth
->
execute
();
my
(
$gsid
)
=
$sth
->
fetchrow_array
;
# Get all bugs_activity records from groupset changes
...
...
@@ -3675,14 +3722,20 @@ if (GetFieldDef("profiles", "groupset")) {
$added
||=
0
;
$removed
||=
0
;
# Get names of groups added.
my
$sth2
=
$dbh
->
prepare
(
"SELECT name FROM groups WHERE (bit & $added) != 0 AND (bit & $removed) = 0"
);
my
$sth2
=
$dbh
->
prepare
(
"SELECT name "
.
"FROM groups "
.
"WHERE (bit & $added) != 0 "
.
"AND (bit & $removed) = 0"
);
$sth2
->
execute
();
my
@logadd
=
();
while
(
my
(
$n
)
=
$sth2
->
fetchrow_array
)
{
push
@logadd
,
$n
;
}
# Get names of groups removed.
$sth2
=
$dbh
->
prepare
(
"SELECT name FROM groups WHERE (bit & $removed) != 0 AND (bit & $added) = 0"
);
$sth2
=
$dbh
->
prepare
(
"SELECT name "
.
"FROM groups "
.
"WHERE (bit & $removed) != 0 "
.
"AND (bit & $added) = 0"
);
$sth2
->
execute
();
my
@logrem
=
();
while
(
my
(
$n
)
=
$sth2
->
fetchrow_array
)
{
...
...
@@ -3712,27 +3765,36 @@ if (GetFieldDef("profiles", "groupset")) {
$dbh
->
do
(
"UPDATE bugs_activity SET fieldid = $bgfid, added = "
.
$dbh
->
quote
(
$loga
)
.
", removed = "
.
$dbh
->
quote
(
$logr
)
.
" WHERE bug_id = $bug_id AND bug_when = "
.
$dbh
->
quote
(
$bug_when
)
.
" WHERE bug_id = $bug_id AND bug_when = "
.
$dbh
->
quote
(
$bug_when
)
.
" AND who = $who AND fieldid = $gsid"
);
}
# Replace groupset changes with group name changes in profiles_activity.
# Get profiles_activity records for groupset.
$sth
=
$dbh
->
prepare
(
"SELECT userid, profiles_when, who, newvalue, oldvalue
FROM profiles_activity WHERE fieldid = $gsid"
);
$sth
=
$dbh
->
prepare
(
"SELECT userid, profiles_when, who, newvalue, oldvalue "
.
"FROM profiles_activity "
.
"WHERE fieldid = $gsid"
);
$sth
->
execute
();
while
(
my
(
$uid
,
$uwhen
,
$uwho
,
$added
,
$removed
)
=
$sth
->
fetchrow_array
)
{
$added
||=
0
;
$removed
||=
0
;
# Get names of groups added.
my
$sth2
=
$dbh
->
prepare
(
"SELECT name FROM groups WHERE (bit & $added) != 0 AND (bit & $removed) = 0"
);
my
$sth2
=
$dbh
->
prepare
(
"SELECT name "
.
"FROM groups "
.
"WHERE (bit & $added) != 0 "
.
"AND (bit & $removed) = 0"
);
$sth2
->
execute
();
my
@logadd
=
();
while
(
my
(
$n
)
=
$sth2
->
fetchrow_array
)
{
push
@logadd
,
$n
;
}
# Get names of groups removed.
$sth2
=
$dbh
->
prepare
(
"SELECT name FROM groups WHERE (bit & $removed) != 0 AND (bit & $added) = 0"
);
$sth2
=
$dbh
->
prepare
(
"SELECT name "
.
"FROM groups "
.
"WHERE (bit & $removed) != 0 "
.
"AND (bit & $added) = 0"
);
$sth2
->
execute
();
my
@logrem
=
();
while
(
my
(
$n
)
=
$sth2
->
fetchrow_array
)
{
...
...
@@ -3742,8 +3804,10 @@ if (GetFieldDef("profiles", "groupset")) {
my
$lrem
=
""
;
$ladd
=
join
(
", "
,
@logadd
)
.
'?'
if
@logadd
;
$lrem
=
join
(
", "
,
@logrem
)
.
'?'
if
@logrem
;
# Replace profiles_activity record for groupset change with group list.
$dbh
->
do
(
"UPDATE profiles_activity SET fieldid = $bgfid, newvalue = "
.
# Replace profiles_activity record for groupset change
# with group list.
$dbh
->
do
(
"UPDATE profiles_activity "
.
"SET fieldid = $bgfid, newvalue = "
.
$dbh
->
quote
(
$ladd
)
.
", oldvalue = "
.
$dbh
->
quote
(
$lrem
)
.
" WHERE userid = $uid AND profiles_when = "
.
...
...
@@ -3759,8 +3823,10 @@ if (GetFieldDef("profiles", "groupset")) {
my
(
$adminid
)
=
$sth
->
fetchrow_array
();
# find existing admins
# Don't lose admins from DBs where Bug 157704 applies
$sth
=
$dbh
->
prepare
(
"SELECT userid, (groupset & 65536), login_name FROM profiles
WHERE (groupset | 65536) = 9223372036854775807"
);
$sth
=
$dbh
->
prepare
(
"SELECT userid, (groupset & 65536), login_name "
.
"FROM profiles "
.
"WHERE (groupset | 65536) = 9223372036854775807"
);
$sth
->
execute
();
while
(
my
(
$userid
,
$iscomplete
,
$login_name
)
=
$sth
->
fetchrow_array
()
)
{
# existing administrators are made members of group "admin"
...
...
@@ -3830,7 +3896,8 @@ if (TableExists("attachstatuses") && TableExists("attachstatusdefs")) {
# from the status table and then, for each one, figure out who set it
# and when they set it from the bugs activity table.
my
$id
=
0
;
$sth
=
$dbh
->
prepare
(
"SELECT attachstatuses.attach_id, attachstatusdefs.id, "
.
$sth
=
$dbh
->
prepare
(
"SELECT attachstatuses.attach_id, attachstatusdefs.id, "
.
"attachstatusdefs.name, attachments.bug_id "
.
"FROM attachstatuses, attachstatusdefs, attachments "
.
"WHERE attachstatuses.statusid = attachstatusdefs.id "
.
...
...
@@ -3901,8 +3968,9 @@ if (TableExists("attachstatuses") && TableExists("attachstatusdefs")) {
print
"done.\n"
;
}
# 2004-12-13 Nick.Barnes@pobox.com bug 262268
# Check f
lag type names for spaces and commas, and
rename them.
# Check f
or spaces and commas in flag type names; if found,
rename them.
if
(
TableExists
(
"flagtypes"
))
{
# Get all names and IDs, to find broken ones and to
# check for collisions when renaming.
...
...
@@ -4156,7 +4224,8 @@ if (!$series_exists) {
"FROM series_categories "
.
"WHERE name = "
.
$dbh
->
quote
(
$product
));
my
$product_id
=
$dbh
->
selectrow_array
(
"SELECT id FROM products "
.
$dbh
->
selectrow_array
(
"SELECT id "
.
"FROM products "
.
"WHERE name = "
.
$dbh
->
quote
(
$product
));
if
(
defined
(
$category_id
)
&&
defined
(
$product_id
))
{
...
...
@@ -4254,7 +4323,7 @@ if (!GetFieldDef('longdescs', 'already_wrapped')) {
AND SUBSTRING(thetext FROM 1 FOR 80) LIKE '% %'}
);
}
# 2001-09-03 dkl@redhat.com bug 17453
# 2001-09-03
(landed 2005-02-24)
dkl@redhat.com bug 17453
# Moved enum types to separate tables so we need change the old enum types to
# standard varchars in the bugs table.
ChangeFieldType
(
'bugs'
,
'bug_status'
,
'varchar(64) not null'
);
...
...
@@ -4277,7 +4346,7 @@ if (!GetFieldDef('quips', 'userid')->[2]) {
# If you had to change the --TABLE-- definition in any way, then add your
# differential change code *** A B O V E *** this comment.
#
# That is: if you add a new field, you first search for the first occurence
# That is: if you add a new field, you first search for the first occur
r
ence
# of --TABLE-- and add your field to into the table hash. This new setting
# would be honored for every new installation. Then add your
# AddField/DropField/ChangeFieldType/RenameField code above. This would then
...
...
@@ -4356,7 +4425,7 @@ if (@admins) {
(user_id, group_id, isbless, grant_type)
VALUES ($userid, $adminid, 0, "
.
GRANT_DIRECT
.
")"
);
# Existing administrators are made blessers of group "admin"
# but only explitly defined blessers can bless group admin.
# but only expli
ci
tly defined blessers can bless group admin.
# Other groups can be blessed by any admin (by default) or additional
# defined blessers.
$dbh
->
do
(
"INSERT INTO user_group_map
...
...
@@ -4393,8 +4462,8 @@ while ( my @row = $sth->fetchrow_array() ) {
# Prompt the user for the email address and name of an administrator. Create
# that login, if it doesn't exist already, and make it a member of all groups.
$sth
=
$dbh
->
prepare
(
"SELECT user_id FROM groups, user_group_map"
.
"
WHERE name = 'admin' AND id = group_id"
);
$sth
=
$dbh
->
prepare
(
"SELECT user_id FROM groups, user_group_map
"
.
"
WHERE name = 'admin' AND id = group_id"
);
$sth
->
execute
;
# when we have no admin users, prompt for admin email address and password ...
if
(
$sth
->
rows
==
0
)
{
...
...
@@ -4422,9 +4491,9 @@ if ($sth->rows == 0) {
and at least one \'.\' after the @.'
;
}
print
"\nLooks like we don't have an administrator set up yet. Either this is your
\n"
;
print
"first time using Bugzilla, or your administrator's privileges might have accidently\n
"
;
print
"
been deleted.\n"
;
print
"\nLooks like we don't have an administrator set up yet.
\n"
;
print
"Either this is your first time using Bugzilla, or your\n
"
;
print
"administrator's privileges might have accidentally
been deleted.\n"
;
while
(
!
$admin_ok
)
{
while
(
$login
eq
""
)
{
print
"Enter the e-mail address of the administrator: "
;
...
...
@@ -4445,8 +4514,8 @@ if ($sth->rows == 0) {
}
}
$login
=
$dbh
->
quote
(
$login
);
$sth
=
$dbh
->
prepare
(
"SELECT login_name FROM profiles
"
.
"
WHERE login_name=$login"
);
$sth
=
$dbh
->
prepare
(
"SELECT login_name FROM profiles
"
.
"
WHERE login_name=$login"
);
$sth
->
execute
;
if
(
$sth
->
rows
>
0
)
{
print
"$login already has an account.\n"
;
...
...
@@ -4459,7 +4528,8 @@ if ($sth->rows == 0) {
$admin_ok
=
1
;
$admin_create
=
0
;
}
else
{
print
"OK, well, someone has to be the administrator. Try someone else.\n"
;
print
"OK, well, someone has to be the administrator.\n"
;
print
"Try someone else.\n"
;
$login
=
""
;
}
}
else
{
...
...
@@ -4543,11 +4613,15 @@ if ($sth->rows == 0) {
$cryptedpassword
=
$dbh
->
quote
(
$cryptedpassword
);
# Set default email flags for the Admin, same as for users
my
$defaultflagstring
=
$dbh
->
quote
(
Bugzilla::Constants::
DEFAULT_EMAIL_SETTINGS
);
my
$defaultflagstring
=
$dbh
->
quote
(
Bugzilla::Constants::
DEFAULT_EMAIL_SETTINGS
);
$dbh
->
do
(
"INSERT INTO profiles (login_name, realname, cryptpassword, emailflags) "
.
$dbh
->
do
(
"INSERT "
.
" INTO profiles (login_name, realname, cryptpassword, emailflags) "
.
"VALUES ($login, $realname, $cryptedpassword, $defaultflagstring)"
);
}
# Put the admin in each group if not already
my
$query
=
"select userid from profiles where login_name = $login"
;
$sth
=
$dbh
->
prepare
(
$query
);
...
...
@@ -4738,7 +4812,8 @@ if ($emptygroupid) {
$trycount
++
;
}
}
while
(
$trygroupsth
->
rows
>
0
);
$sth
=
$dbh
->
prepare
(
"UPDATE groups SET name = ? WHERE id = $emptygroupid"
);
$sth
=
$dbh
->
prepare
(
"UPDATE groups SET name = ? "
.
"WHERE id = $emptygroupid"
);
$sth
->
execute
(
$trygroupname
);
print
"Group $emptygroupid had an empty name; renamed as '$trygroupname'.\n"
;
}
...
...
@@ -4763,14 +4838,18 @@ if (!defined GetIndexDef('bugs_activity','who')) {
#
# Final checks...
$sth
=
$dbh
->
prepare
(
"SELECT user_id FROM groups, user_group_map"
.
" WHERE groups.name = 'admin'"
.
" AND groups.id = user_group_map.group_id"
);
$sth
=
$dbh
->
prepare
(
"SELECT user_id "
.
"FROM groups, user_group_map "
.
"WHERE groups.name = 'admin' "
.
"AND groups.id = user_group_map.group_id"
);
$sth
->
execute
;
my
(
$adminuid
)
=
$sth
->
fetchrow_array
;
if
(
!
$adminuid
)
{
die
"No administrator!"
}
# should never get here
# when test product was created, admin was unknown
$dbh
->
do
(
"UPDATE components SET initialowner = $adminuid WHERE initialowner = 0"
);
$dbh
->
do
(
"UPDATE components "
.
"SET initialowner = $adminuid "
.
"WHERE initialowner = 0"
);
unlink
"$datadir/versioncache"
;
################################################################################
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