diff --git a/mozilla/webtools/testopia/Bugzilla/Testopia/Search.pm b/mozilla/webtools/testopia/Bugzilla/Testopia/Search.pm
index 5cf168a38a0..91cb2237a10 100644
--- a/mozilla/webtools/testopia/Bugzilla/Testopia/Search.pm
+++ b/mozilla/webtools/testopia/Bugzilla/Testopia/Search.pm
@@ -389,6 +389,10 @@ sub init {
push @supptables, "INNER JOIN test_case_plans AS case_plans ON test_cases.case_id = case_plans.case_id";
push @orderby, 'case_plans.plan_id';
}
+ elsif($order eq 'requirement' && $obj eq 'case_run'){
+ push @supptables, "INNER JOIN test_cases ON test_cases.case_id = test_case_runs.case_id";
+ push @orderby, 'test_cases.requirement';
+ }
elsif ($order eq 'priority') {
if ($obj eq 'case_run'){
push @supptables, "INNER JOIN test_cases ON test_cases.case_id = test_case_runs.case_id";
diff --git a/mozilla/webtools/testopia/extensions/testopia/code/post_bug-after_creation.pl b/mozilla/webtools/testopia/extensions/testopia/code/post_bug-after_creation.pl
index 19fce47fb3e..6b11e052f46 100644
--- a/mozilla/webtools/testopia/extensions/testopia/code/post_bug-after_creation.pl
+++ b/mozilla/webtools/testopia/extensions/testopia/code/post_bug-after_creation.pl
@@ -6,16 +6,20 @@ use Bugzilla::Testopia::TestCase;
my $vars = Bugzilla->hook_args->{vars};
my $cgi = Bugzilla->cgi;
-if ($cgi->param('case_id')) {
+my $caserun_id = $cgi->param('caserun_id');
+my $case_id = $cgi->param('case_id');
+if (detaint_natural($case_id)) {
my $case = Bugzilla::Testopia::TestCase->new($cgi->param('case_id'));
+ ThrowUserError("invalid-test-id-non-existent", {'id' => $case_id, 'type' => 'Case'}) unless $case;
ThrowUserError("testopia-read-only", {'object' => $case}) unless $case->canedit;
$case->attach_bug($vars->{'id'});
$vars->{'case'} = $case;
}
-if ($cgi->param('caserun_id')) {
+if (detaint_natural($caserun_id)) {
my $caserun = Bugzilla::Testopia::TestCaseRun->new($cgi->param('caserun_id'));
+ ThrowUserError("invalid-test-id-non-existent", {'id' => $caserun_id, 'type' => 'Case-Run'}) unless $caserun;
ThrowUserError("testopia-read-only", {'object' => $caserun}) unless $caserun->canedit;
$caserun->attach_bug($vars->{'id'});
diff --git a/mozilla/webtools/testopia/template/en/default/hook/global/common-links.html.tmpl/links/testopia.html.tmpl b/mozilla/webtools/testopia/template/en/default/hook/global/common-links.html.tmpl/links/testopia.html.tmpl
index 88d0b57186b..2c17d7c1539 100644
--- a/mozilla/webtools/testopia/template/en/default/hook/global/common-links.html.tmpl/links/testopia.html.tmpl
+++ b/mozilla/webtools/testopia/template/en/default/hook/global/common-links.html.tmpl/links/testopia.html.tmpl
@@ -41,10 +41,10 @@