summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authormkanat%kerio.com <>2005-03-09 08:03:57 +0100
committermkanat%kerio.com <>2005-03-09 08:03:57 +0100
commit3a92f2d18482834d9f51852c3809b687452fea0e (patch)
tree066bef1a71986891510d4f04d7228843e2107258 /Bugzilla
parent642af3b414b8f4135170ca03ee7d0dedc49a9c13 (diff)
downloadbugzilla-3a92f2d18482834d9f51852c3809b687452fea0e.tar.gz
bugzilla-3a92f2d18482834d9f51852c3809b687452fea0e.tar.xz
Bug 283919: Move BugAliasToID out of CGI.pl into Bugzilla::Bug
Patch By Max Kanat-Alexander <mkanat@kerio.com> r=LpSolit, a=myk
Diffstat (limited to 'Bugzilla')
-rwxr-xr-xBugzilla/Bug.pm17
1 files changed, 16 insertions, 1 deletions
diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm
index b9229d98e..501f707b0 100755
--- a/Bugzilla/Bug.pm
+++ b/Bugzilla/Bug.pm
@@ -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;