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
3a92f2d1
Commit
3a92f2d1
authored
Mar 09, 2005
by
mkanat%kerio.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 283919: Move BugAliasToID out of CGI.pl into Bugzilla::Bug
Patch By Max Kanat-Alexander <mkanat@kerio.com> r=LpSolit, a=myk
parent
642af3b4
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
18 deletions
+18
-18
Bug.pm
Bugzilla/Bug.pm
+16
-1
CGI.pl
CGI.pl
+2
-17
No files found.
Bugzilla/Bug.pm
View file @
3a92f2d1
...
...
@@ -46,6 +46,7 @@ use Bugzilla::Error;
use
base
qw(Exporter)
;
@
Bugzilla::Bug::
EXPORT
=
qw(
bug_alias_to_id
ValidateComment
)
;
...
...
@@ -123,7 +124,7 @@ sub initBug {
my
$old_bug_id
=
$bug_id
;
# If the bug ID isn't numeric, it might be an alias, so try to convert it.
$bug_id
=
&::
BugAliasToID
(
$bug_id
)
if
$bug_id
!~
/^0*[1-9][0-9]*$/
;
$bug_id
=
bug_alias_to_id
(
$bug_id
)
if
$bug_id
!~
/^0*[1-9][0-9]*$/
;
if
((
!
defined
$bug_id
)
||
(
!
$bug_id
)
||
(
!
detaint_natural
(
$bug_id
)))
{
# no bug number given or the alias didn't match a bug
...
...
@@ -496,6 +497,20 @@ sub choices {
return
$self
->
{
'choices'
};
}
# Convenience Function. If you need speed, use this. If you need
# other Bug fields in addition to this, just create a new Bug with
# the alias.
# Queries the database for the bug with a given alias, and returns
# the ID of the bug if it exists or the undefined value if it doesn't.
sub
bug_alias_to_id
($)
{
my
(
$alias
)
=
@_
;
return
undef
unless
Param
(
"usebugaliases"
);
my
$dbh
=
Bugzilla
->
dbh
;
trick_taint
(
$alias
);
return
$dbh
->
selectrow_array
(
"SELECT bug_id FROM bugs WHERE alias = ?"
,
undef
,
$alias
);
}
sub
EmitDependList
{
my
(
$myfield
,
$targetfield
,
$bug_id
)
=
(
@_
);
my
$dbh
=
Bugzilla
->
dbh
;
...
...
CGI.pl
View file @
3a92f2d1
...
...
@@ -45,6 +45,7 @@ use Bugzilla::Config;
use
Bugzilla::
Constants
;
use
Bugzilla::
Error
;
use
Bugzilla::
BugMail
;
use
Bugzilla::
Bug
;
# Shut up misguided -w warnings about "used only once". For some reason,
# "use vars" chokes on me when I try it here.
...
...
@@ -127,22 +128,6 @@ sub CheckFormFieldDefined (\%$) {
}
}
sub
BugAliasToID
{
# Queries the database for the bug with a given alias, and returns
# the ID of the bug if it exists or the undefined value if it doesn't.
my
(
$alias
)
=
@_
;
return
undef
unless
Param
(
"usebugaliases"
);
PushGlobalSQLState
();
SendSQL
(
"SELECT bug_id FROM bugs WHERE alias = "
.
SqlQuote
(
$alias
));
my
$id
=
FetchOneColumn
();
PopGlobalSQLState
();
return
$id
;
}
sub
ValidateBugID
{
# Validates and verifies a bug ID, making sure the number is a
# positive integer, that it represents an existing bug in the
...
...
@@ -157,7 +142,7 @@ sub ValidateBugID {
# If the ID isn't a number, it might be an alias, so try to convert it.
my
$alias
=
$id
;
if
(
!
detaint_natural
(
$id
))
{
$id
=
BugAliasToID
(
$alias
);
$id
=
bug_alias_to_id
(
$alias
);
$id
||
ThrowUserError
(
"invalid_bug_id_or_alias"
,
{
'bug_id'
=>
$alias
,
'field'
=>
$field
});
...
...
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