Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resurrect patches from unstable branch #44

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
be26116
Bug 1446236 - use urlbase in AntiSpam extension
CyberShadow Mar 16, 2018
7d5e31e
Bug 1446236 - docs/en/rst/integrating/templates.rst: Fix a typo
CyberShadow Mar 16, 2018
fd2cc92
Bug 1446236 - Allow customizing link to bug writing guidelines
CyberShadow Mar 16, 2018
30c5eab
Bug 1446236 - Use terms.Bugzilla when refering to the bugzilla instal…
CyberShadow Mar 16, 2018
10f2057
Bug 1446236 - fix typo in comment
CyberShadow Mar 16, 2018
92e6a73
add Bugzilla->urlbase method that returns a URI object
dylanwh Mar 16, 2018
529fe30
Bug 1446236 - fix several occurrences of a typo (user's of)
CyberShadow Mar 16, 2018
59aba64
Bug 1446236 - Bugzilla/Search.pm: Use Bugzilla::Extension::TrackingFl…
CyberShadow Mar 18, 2018
3e0ef11
Bug 1446236 - BugModal: Use TrackingFlags only when present
CyberShadow Mar 18, 2018
cb8a64e
Bug 1446236 - Generate static error pages
CyberShadow Mar 18, 2018
8e5e1b6
Bug 1446236 - template/en/default/bug/new_bug.html.tmpl: Use relative…
CyberShadow Mar 18, 2018
46b975e
Bug 1446236 - Allow customizing the name of the "nobody" user (nobody…
CyberShadow Mar 18, 2018
b7abfa9
Bug 1446236 - edit-multiple.html.tmpl: Delete an old user-specific ha…
CyberShadow Mar 18, 2018
f344c52
Bug 1446236 - error pages fixups
CyberShadow Mar 18, 2018
f0b8f4f
Bug 1446236 - Add & use simpler method to check if an extension is pr…
CyberShadow Apr 8, 2018
7c1a336
table.html.tmpl: Use order_columns only when present (#23)
CyberShadow Apr 8, 2018
43c1f45
enter_bug: Fix hard BMO dependency (#29)
CyberShadow Apr 8, 2018
f8db696
Bug 1446236 - Fix instant search without GuidedBugEntry (#38)
CyberShadow Apr 8, 2018
a21b7bb
search-google.html.tmpl: Calculate sitesearch from urlbase (#20)
CyberShadow Apr 8, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
/data
/localconfig
/localconfig.*
/conf/env.conf
/index.html
/errors/
/error_reports
/.DS_Store
/template_cache
Expand Down
26 changes: 26 additions & 0 deletions Bugzilla.pm
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ use File::Spec::Functions;
use Safe;
use JSON::XS qw(decode_json);
use Scope::Guard;
use URI;

use parent qw(Bugzilla::CPAN);

Expand Down Expand Up @@ -124,6 +125,14 @@ sub template_inner {
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
our $in_extensions = 0;

sub extensions {
# Guard against extensions querying the extension list during initialization
# (through this method or has_extension).
# The extension list is not fully populated at that point,
# so the results would not be meaningful.
state $recursive = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
state $recursive = 0;

die "Recursive attempt to load/query extensions" if $recursive;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
die "Recursive attempt to load/query extensions" if $recursive;
die "Recursive attempt to load/query extensions" if $in_extensions > 0;

$recursive = 1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$recursive = 1;
local $in_extensions = $in_extensions + 1;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, applied these in #66


state $extensions;
return $extensions if $extensions;
my $extension_packages = Bugzilla::Extension->load_all();
Expand All @@ -133,9 +142,20 @@ sub extensions {
push @$extensions, $package;
}
}
$recursive = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$recursive = 0;

return $extensions;
}

sub has_extension {
my ($class, $name) = @_;
my $cache = $class->request_cache;
if (!$cache->{extensions_hash}) {
my %extensions = map { $_->NAME => 1 } @{Bugzilla->extensions};
$cache->{extensions_hash} = \%extensions;
}
return exists $cache->{extensions_hash}{$name};
}

sub cgi {
return request_cache->{cgi} ||= Bugzilla::CGI->new;
}
Expand All @@ -162,6 +182,12 @@ sub localconfig {
||= Bugzilla::Localconfig->new(read_localconfig());
}

sub urlbase {
my ($class) = @_;

# Since this could be modified, we have to return a new one every time.
return URI->new($class->localconfig->{urlbase});
}

sub params {
return request_cache->{params} ||= Bugzilla::Config::read_param_file();
Expand Down
2 changes: 1 addition & 1 deletion Bugzilla/CGI.pm
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ sub send_cookie {
}

# Add the default path and the domain in.
state $uri = URI->new(Bugzilla->localconfig->urlbase);
state $uri = Bugzilla->urlbase;
$paramhash{'-path'} = $uri->path;

# we don't set the domain.
Expand Down
8 changes: 8 additions & 0 deletions Bugzilla/Config/General.pm
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ use constant get_param_list => (
checker => \&check_email
},

{
name => 'nobody_user',
type => 't',
no_reset => '1',
default => '[email protected]',
checker => \&check_email
},

{
name => 'docs_urlbase',
type => 't',
Expand Down
2 changes: 1 addition & 1 deletion Bugzilla/Install/DB.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4227,7 +4227,7 @@ sub _migrate_group_owners {
my $dbh = Bugzilla->dbh;
return if $dbh->bz_column_info('groups', 'owner_user_id');
$dbh->bz_add_column('groups', 'owner_user_id', {TYPE => 'INT3'});
my $nobody = Bugzilla::User->check('[email protected]');
my $nobody = Bugzilla::User->check(Bugzilla->params->{'nobody_user'});
$dbh->do('UPDATE groups SET owner_user_id = ?', undef, $nobody->id);
}

Expand Down
88 changes: 87 additions & 1 deletion Bugzilla/Install/Filesystem.pm
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,51 @@ use constant HTTPD_ENV => qw(
NYTPROF_DIR
);

sub _error_page {
my ($code, $title, $description) = @_;
my $host = Bugzilla->urlbase->host;

return <<EOT;
<!DOCTYPE HTML>
<html>
<head>
<title>$title</title>
<style>
body {
margin: 1em 2em;
background-color: #455372;
color: #ddd;
font-family: sans-serif;
}
h1, h3 {
color: #fff;
}
a {
color: #fff;
text-decoration: none;
}
#buggie {
float: left;
}
#content {
margin-left: 100px;
padding-top: 20px;
}
</style>
</head>
<body>
<img src="/images/buggie.png" id="buggie" alt="buggie" width="78" height="215">
<div id="content">
<h1>$title</h1>
<p>$description</p>
<h3>Error $code</h3>
<p><a href="/">$host</a></p>
</div>
</body>
</html>
EOT
}

###############
# Permissions #
###############
Expand Down Expand Up @@ -344,6 +389,47 @@ sub FILESYSTEM {
{perms => CGI_READ, overwrite => 1, contents => $yui3_all_css},
);

# Create static error pages.
$create_dirs{"errors"} = DIR_CGI_READ;
$create_files{"errors/401.html"} = {
perms => CGI_READ,
overwrite => 1,
contents => _error_page(
401, 'Authentication Required',
"This server could not verify that you are authorized to access
that URL. you either supplied the wrong credentials (e.g., bad
password), or your browser doesn't understand how to supply the
credentials required."
)
};
$create_files{"errors/403.html"} = {
perms => CGI_READ,
overwrite => 1,
contents => _error_page(
403,
'Access Denied',
"Access to the requested resource has been denied."
)
};
$create_files{"errors/404.html"} = {
perms => CGI_READ,
overwrite => 1,
contents => _error_page(
404,
'Object Not Found',
"The requested URL was not found on this server."
)
};
$create_files{"errors/500.html"} = {
perms => CGI_READ,
overwrite => 1,
contents => _error_page(
500,
'Internal Server Error',
"The server encountered an internal error and was unable to complete your request."
)
};

Bugzilla::Hook::process(
'install_filesystem',
{
Expand Down Expand Up @@ -417,7 +503,7 @@ sub update_filesystem {
# Delete old files that no longer need to exist

# 2001-04-29 [email protected] - Remove oldemailtech
# http://bugzilla.mozilla.org/show_bugs.cgi?id=71552
# http://bugzilla.mozilla.org/show_bug.cgi?id=71552
if (-d 'shadow') {
print "Removing shadow directory...\n";
rmtree("shadow");
Expand Down
28 changes: 15 additions & 13 deletions Bugzilla/Search.pm
Original file line number Diff line number Diff line change
Expand Up @@ -802,19 +802,21 @@ sub data {
# BMO - to avoid massive amounts of joins, if we're selecting a lot of
# tracking flags, replace them with placeholders. the values will be
# retrieved later and injected into the result.
my %tf_map = map { $_ => 1 } Bugzilla->tracking_flag_names;
my @tf_selected = grep { exists $tf_map{$_} } @orig_fields;

# MySQL has a limit of 61 joins, and we want to avoid massive amounts of joins
# 30 ensures we won't hit the limit, nor generate too many joins
if (scalar @tf_selected > 30) {
foreach my $column (@tf_selected) {
$self->COLUMNS->{$column}->{name} = "'---'";
if (Bugzilla->has_extension('TrackingFlags')) {
my %tf_map = map { $_ => 1 } Bugzilla->tracking_flag_names;
my @tf_selected = grep { exists $tf_map{$_} } @orig_fields;

# MySQL has a limit of 61 joins, and we want to avoid massive amounts of joins
# 30 ensures we won't hit the limit, nor generate too many joins
if (scalar @tf_selected > 30) {
foreach my $column (@tf_selected) {
$self->COLUMNS->{$column}->{name} = "'---'";
}
$self->{tracking_flags} = \@tf_selected;
}
else {
$self->{tracking_flags} = [];
}
$self->{tracking_flags} = \@tf_selected;
}
else {
$self->{tracking_flags} = [];
}

my $start_time = [gettimeofday()];
Expand Down Expand Up @@ -869,7 +871,7 @@ sub data {
$self->{data} = [map { $data{$_} } @$bug_ids];

# BMO - get tracking flags values, and insert into result
if (@{$self->{tracking_flags}}) {
if (Bugzilla->has_extension('TrackingFlags') && @{$self->{tracking_flags}}) {

# read values
my $values;
Expand Down
4 changes: 3 additions & 1 deletion Bugzilla/Template.pm
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,7 @@ sub create {
'sudoer' => sub { return Bugzilla->sudoer; },

# Allow templates to access the "correct" URLBase value
'urlbase' => sub { return Bugzilla->localconfig->urlbase; },
'urlbase' => sub { Bugzilla->urlbase },

# Allow templates to get the absolute path of the URLBase value
'basepath' => sub { return Bugzilla->localconfig->basepath; },
Expand Down Expand Up @@ -1058,6 +1058,8 @@ sub create {

'feature_enabled' => sub { return Bugzilla->feature(@_); },

'has_extension' => sub { return Bugzilla->has_extension(@_); },

# field_descs can be somewhat slow to generate, so we generate
# it only once per-language no matter how many times
# $template->process() is called.
Expand Down
2 changes: 1 addition & 1 deletion docs/en/rst/integrating/templates.rst
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ customizing for your installation.
It needs a couple of lines of boilerplate at the top like this::

[% USE Bugzilla %]
[% cgi = Bugzilla.cgi %
[% cgi = Bugzilla.cgi %]

Then, this template can reference the form fields you have created using
the syntax ``[% cgi.param("field_name") %]``. When a bug report is
Expand Down
15 changes: 11 additions & 4 deletions enter_bug.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ use Bugzilla::Field;
use Bugzilla::Status;
use Bugzilla::UserAgent;

use List::Util qw(any);

my $user = Bugzilla->login(LOGIN_REQUIRED);

my $cloned_bug;
Expand Down Expand Up @@ -322,10 +324,15 @@ else {
= formvalue('bug_severity', Bugzilla->params->{'defaultseverity'});

# BMO - use per-product default hw/os
$default{'rep_platform'}
= formvalue('rep_platform', $product->default_platform // detect_platform());
$default{'op_sys'}
= formvalue('op_sys', $product->default_op_sys // detect_op_sys());
if (any { $_->NAME eq 'BMO' } @{ Bugzilla->extensions }) {
$default{'rep_platform'}
= formvalue('rep_platform', $product->default_platform // detect_platform());
$default{'op_sys'}
= formvalue('op_sys', $product->default_op_sys // detect_op_sys());
} else {
$default{'rep_platform'} = formvalue('rep_platform', detect_platform());
$default{'op_sys'} = formvalue('op_sys', detect_op_sys());
}
$vars->{'rep_platform'} = detect_platform();
$vars->{'rep_op_sys'} = detect_op_sys();

Expand Down
40 changes: 0 additions & 40 deletions errors/401.html

This file was deleted.

37 changes: 0 additions & 37 deletions errors/403.html

This file was deleted.

Loading