[mb-commits] branch, beta, updated. Merge branch 'mbs-4578-dbdefs' into beta MBS-4578: change sample to use schem...
MusicBrainz Git Server <[email protected]>
| Newsgroups | gmane.comp.audio.musicbrainz.cvs |
|---|---|
| Message-ID | <E1TVDRd-0007vt-ST@wiley> |
The branch, beta has been updated
via http://git.musicbrainz.org/gitweb/?p=musicbrainz-server/core.git;a=commit;h=2707e9959447393bf5d7446aab5eeffd8fa3ae90 (commit)
via http://git.musicbrainz.org/gitweb/?p=musicbrainz-server/core.git;a=commit;h=d7b2451b24e2f75c96d503cd44ed8f4673bd1284 (commit)
via http://git.musicbrainz.org/gitweb/?p=musicbrainz-server/core.git;a=commit;h=40dcfcfaf35d4c67e57b1d3f284dc32053065259 (commit)
via http://git.musicbrainz.org/gitweb/?p=musicbrainz-server/core.git;a=commit;h=bee2c5e4c10cb433b64cc4b4b9b3a2d73f1d12b5 (commit)
via http://git.musicbrainz.org/gitweb/?p=musicbrainz-server/core.git;a=commit;h=5973d6afc938033760a193ad0b743fcf7663c781 (commit)
via http://git.musicbrainz.org/gitweb/?p=musicbrainz-server/core.git;a=commit;h=75bd2f4879611b230f7ae830f80bbc55d9ff83a7 (commit)
via http://git.musicbrainz.org/gitweb/?p=musicbrainz-server/core.git;a=commit;h=162f4da09ea8944601d8c029c482b62162d204e3 (commit)
via http://git.musicbrainz.org/gitweb/?p=musicbrainz-server/core.git;a=commit;h=493e73ff3671a87cf7cc89616a66dff717858bf2 (commit)
via http://git.musicbrainz.org/gitweb/?p=musicbrainz-server/core.git;a=commit;h=40e5743f4c2a63184208d73d51cb44c81534edc2 (commit)
via http://git.musicbrainz.org/gitweb/?p=musicbrainz-server/core.git;a=commit;h=cf298fc455f0fe3dc81346756d5da03aee88cd17 (commit)
via http://git.musicbrainz.org/gitweb/?p=musicbrainz-server/core.git;a=commit;h=07c3940e6a656af732fe621e5e39b1a32f9149f4 (commit)
via http://git.musicbrainz.org/gitweb/?p=musicbrainz-server/core.git;a=commit;h=a9c45ab3cb9493b76f92ee2927b6adc98d3da857 (commit)
via http://git.musicbrainz.org/gitweb/?p=musicbrainz-server/core.git;a=commit;h=a37e9c8c2b40a729c17ebae91984a6209416974d (commit)
from http://git.musicbrainz.org/gitweb/?p=musicbrainz-server/core.git;a=commit;h=8bfc991d2ee2fa6e921bc89c37abf37e55c51a30 (commit)
Summary of changes:
INSTALL.md | 2 +-
Makefile.PL | 2 +
admin/ExportAllTables | 4 +-
admin/InitDb.pl | 4 +-
admin/MBImport.pl | 12 +-
admin/SendMailForUnverifiedAccounts | 3 -
admin/SubscribeAutomodsToList | 2 +-
admin/UpdateStyleSheetLinks | 2 +-
admin/cleanup/ArchiveOldModerations | 2 +-
admin/replication/LoadReplicationChanges | 6 +-
app.psgi | 6 +-
bin/check_last_replication_date | 2 +-
lib/{DBDefs.pm.default => DBDefs.pm.sample} | 294 ++++++++++----------
lib/{DBDefs.pm.default => DBDefs/Default.pm} | 88 ++----
lib/MusicBrainz/Script/RebuildCoverArt.pm | 2 +-
lib/MusicBrainz/Server.pm | 32 +-
lib/MusicBrainz/Server/Context.pm | 4 +-
lib/MusicBrainz/Server/Controller/Account.pm | 16 +-
lib/MusicBrainz/Server/Controller/Admin.pm | 2 +-
lib/MusicBrainz/Server/Controller/Doc.pm | 4 +-
lib/MusicBrainz/Server/Controller/Partners.pm | 2 +-
lib/MusicBrainz/Server/Controller/Release.pm | 8 +-
lib/MusicBrainz/Server/Controller/Root.pm | 34 ++--
lib/MusicBrainz/Server/Controller/Search.pm | 2 +-
lib/MusicBrainz/Server/Controller/Test.pm | 2 +-
lib/MusicBrainz/Server/Controller/User.pm | 6 +-
lib/MusicBrainz/Server/Controller/WS/1/Track.pm | 2 +-
.../Server/Controller/WS/js/WikiDocVersion.pm | 2 +-
lib/MusicBrainz/Server/ControllerBase/WS/1.pm | 4 +-
lib/MusicBrainz/Server/ControllerBase/WS/2.pm | 4 +-
.../Server/CoverArt/Provider/WebService/Amazon.pm | 10 +-
lib/MusicBrainz/Server/Data/CoverArtArchive.pm | 8 +-
lib/MusicBrainz/Server/Data/FileCache.pm | 12 +-
lib/MusicBrainz/Server/Data/RateLimiter.pm | 2 +-
lib/MusicBrainz/Server/Data/Search.pm | 6 +-
lib/MusicBrainz/Server/Data/Statistics.pm | 4 +-
lib/MusicBrainz/Server/Data/WebService.pm | 2 +-
lib/MusicBrainz/Server/Data/WikiDoc.pm | 10 +-
lib/MusicBrainz/Server/Data/WikiDocIndex.pm | 10 +-
lib/MusicBrainz/Server/Edit/Release/AddCoverArt.pm | 2 +-
.../Server/Edit/Release/EditCoverArt.pm | 2 +-
.../Server/Edit/Release/RemoveCoverArt.pm | 2 +-
lib/MusicBrainz/Server/EditQueue.pm | 2 +-
lib/MusicBrainz/Server/Email.pm | 18 +-
lib/MusicBrainz/Server/Email/Role.pm | 2 +-
lib/MusicBrainz/Server/Entity/URL/ASIN.pm | 2 +-
lib/MusicBrainz/Server/Filters.pm | 4 +-
lib/MusicBrainz/Server/Form/Search/Search.pm | 2 +-
lib/MusicBrainz/Server/Log.pm | 2 +-
lib/MusicBrainz/Server/Model/MB.pm | 10 +-
lib/MusicBrainz/Server/Replication.pm | 2 +-
lib/MusicBrainz/Server/Translation.pm | 16 +-
lib/MusicBrainz/Server/View/Default.pm | 2 +-
lib/MusicBrainz/Server/Wizard.pm | 2 +-
lib/Sql.pm | 2 +-
script/compile_resources.pl | 2 +-
t/lib/t/MusicBrainz/Script/RebuildCoverArt.pm | 2 +-
.../MusicBrainz/Server/Data/AutoEditorElection.pm | 12 +-
t/lib/t/MusicBrainz/Server/Data/CoverArt.pm | 6 +-
t/lib/t/MusicBrainz/Server/Data/EditNote.pm | 2 +-
t/lib/t/MusicBrainz/Server/Data/Vote.pm | 4 +-
.../MusicBrainz/Server/Edit/Relationship/Create.pm | 2 +-
t/lib/t/MusicBrainz/Server/Email.pm | 8 +-
t/lib/t/MusicBrainz/Server/Email/Subscriptions.pm | 2 +-
64 files changed, 354 insertions(+), 377 deletions(-)
copy lib/{DBDefs.pm.default => DBDefs.pm.sample} (69%)
rename lib/{DBDefs.pm.default => DBDefs/Default.pm} (85%)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 2707e9959447393bf5d7446aab5eeffd8fa3ae90
Merge: 8bfc991 d7b2451b
Author: Ian McEwen <[email protected]>
Date: Sun Nov 4 20:26:54 2012 -0700
Merge branch 'mbs-4578-dbdefs' into beta
Conflicts:
lib/DBDefs/Default.pm
commit d7b2451b24e2f75c96d503cd44ed8f4673bd1284
Author: Ian McEwen <[email protected]>
Date: Wed Oct 31 21:08:09 2012 -0700
MBS-4578: change sample to use schema 16 as well
diff --git a/lib/DBDefs.pm.sample b/lib/DBDefs.pm.sample
index a9af89c..30622c6 100644
--- a/lib/DBDefs.pm.sample
+++ b/lib/DBDefs.pm.sample
@@ -92,7 +92,7 @@ MusicBrainz::Server::DatabaseConnectionFactory->register_databases(
# replication_control.current_schema_sequence.
# This is required, there is no default in order to prevent it changing without
# manual intervention.
-sub DB_SCHEMA_SEQUENCE { 15 }
+sub DB_SCHEMA_SEQUENCE { 16 }
# What type of server is this?
# * RT_MASTER - This is a master replication server. Changes are allowed, and
commit 40dcfcfaf35d4c67e57b1d3f284dc32053065259
Author: Ian McEwen <[email protected]>
Date: Wed Oct 31 21:02:38 2012 -0700
MBS-4578: update to current beta
diff --git a/lib/DBDefs.pm.sample b/lib/DBDefs.pm.sample
index 4841641..a9af89c 100644
--- a/lib/DBDefs.pm.sample
+++ b/lib/DBDefs.pm.sample
@@ -68,7 +68,14 @@ MusicBrainz::Server::DatabaseConnectionFactory->register_databases(
# port => "",
},
# How to connect for read-only access. See "REPLICATION_TYPE" (below)
- # READONLY => undef,
+ READONLY => {
+ database => "musicbrainz_db",
+ schema => "musicbrainz",
+ username => "musicbrainz",
+ password => "musicbrainz",
+# host => "",
+# port => "",
+ },
# How to connect for administrative access
SYSTEM => {
database => "template1",
@@ -95,6 +102,9 @@ sub DB_SCHEMA_SEQUENCE { 15 }
# by applying the next replication packet in turn. If the slave
# server is not going to be used for development work, change
# DB_STAGING_SERVER to 0.
+#
+# A READONLY database connection must be configured if you
+# choose RT_SLAVE, as well as the usual READWRITE.
# * RT_STANDALONE - This server neither generates nor uses replication
# packets. Changes to the database are allowed.
# sub REPLICATION_TYPE { RT_STANDALONE }
@@ -355,7 +365,7 @@ sub WEB_SERVER { "www.musicbrainz.example.com" }
# If you're using multiple front-end webservers make sure they all connect to
# the same memcached server. Also make sure enough memory is configured for
# memcached so sessions aren't evicted from the cache.
-# sub SESSION_STORE { "Session::Store::Memcached" }
+# sub SESSION_STORE { "Session::Store::MusicBrainz" }
# sub SESSION_STORE_ARGS
# {
# my $self = shift;
@@ -389,6 +399,10 @@ sub WEB_SERVER { "www.musicbrainz.example.com" }
# are not yet properly supported, like right-to-left languages
# sub MB_LANGUAGES {qw()}
+# Should the site fall back to browser settings when trying to set a language
+# (note: will still only use languages in MB_LANGUAGES)
+# sub LANGUAGE_FALLBACK_TO_BROWSER{ 1 }
+
# Private, please do not change
# sub _RUNNING_TESTS { 0 }
diff --git a/lib/MusicBrainz/Server/Translation.pm b/lib/MusicBrainz/Server/Translation.pm
index cd42bc7..52e64f1 100644
--- a/lib/MusicBrainz/Server/Translation.pm
+++ b/lib/MusicBrainz/Server/Translation.pm
@@ -115,7 +115,7 @@ sub set_language
my @avail_lang;
if (defined $lang) {
@avail_lang = ($lang);
- } elsif (DBDefs::LANGUAGE_FALLBACK_TO_BROWSER) {
+ } elsif (DBDefs->LANGUAGE_FALLBACK_TO_BROWSER) {
# change e.g. 'en-aq' to 'en_AQ'
@avail_lang = map { s/-([a-z]{2})/_\U$1/; $_; }
grep {
commit bee2c5e4c10cb433b64cc4b4b9b3a2d73f1d12b5
Merge: 5973d6a 27eeb63
Author: Ian McEwen <[email protected]>
Date: Wed Oct 31 20:56:03 2012 -0700
Merge branch 'beta' into mbs-4578-dbdefs
Conflicts:
Makefile.PL
lib/DBDefs/Default.pm
lib/MusicBrainz/Server.pm
lib/MusicBrainz/Server/Controller/Doc.pm
lib/MusicBrainz/Server/Data/WikiDoc.pm
diff --cc Makefile.PL
index e5057c1,a65b716..08c20c3
--- a/Makefile.PL
+++ b/Makefile.PL
@@@ -49,8 -50,6 +51,7 @@@ requires 'Email::MIME::Creator'
requires 'Email::Valid';
requires 'Encode::Detect' => '1.01';
requires 'Exception::Class' => '1.29';
+requires 'File::Spec';
- requires 'Function::Parameters';
requires 'HTML::FormHandler' => '0.40013';
requires 'HTML::Tiny' => '1.05';
requires 'HTML::TreeBuilder::XPath';
diff --cc lib/MusicBrainz/Server.pm
index 58833f3,0334947..b4bf2f1
--- a/lib/MusicBrainz/Server.pm
+++ b/lib/MusicBrainz/Server.pm
@@@ -247,50 -248,33 +248,33 @@@ around 'dispatch' => sub
$c->model('MB')->context->connector->refresh;
- $_->instance->build_languages_from_header($c->req->headers)
- for qw( MusicBrainz::Server::Translation
- MusicBrainz::Server::Translation::Statistics
- MusicBrainz::Server::Translation::Countries
- MusicBrainz::Server::Translation::Scripts
- MusicBrainz::Server::Translation::Languages
- MusicBrainz::Server::Translation::Attributes
- MusicBrainz::Server::Translation::Relationships
- MusicBrainz::Server::Translation::Instruments
- MusicBrainz::Server::Translation::InstrumentDescriptions );
-
- my $cookie_lang = Translation->instance->language_from_cookie($c->request->cookies->{lang});
- my $lang = Translation->instance->set_language($cookie_lang);
- # because s///r is a perl 5.14 feature
- my $html_lang = $lang;
- $html_lang =~ s/_([A-Z]{2})/-\L$1/;
- $c->stash(
- current_language => $lang,
- current_language_html => $html_lang
- );
-
- if(my $max_request_time = DBDefs->MAX_REQUEST_TIME) {
- alarm($max_request_time);
- POSIX::sigaction(
- SIGALRM, POSIX::SigAction->new(sub {
- $c->log->error(sprintf("Request for %s took over %d seconds. Killing process",
- $c->req->uri,
- $max_request_time));
- $c->log->error(Devel::StackTrace->new->as_string);
- $c->log->_flush;
- if (my $sth = $c->model('MB')->context->sql->sth) {
- $sth->cancel;
- }
- exit(42)
- }));
-
- $c->$orig(@_);
-
- alarm(0);
- }
- else {
- $c->$orig(@_);
- }
- Translation->instance->unset_language();
+ with_translations($c, sub {
+ my $c = shift;
+ my $orig = shift;
+
- if(my $max_request_time = DBDefs::MAX_REQUEST_TIME) {
++ if(my $max_request_time = DBDefs->MAX_REQUEST_TIME) {
+ alarm($max_request_time);
+ POSIX::sigaction(
+ SIGALRM, POSIX::SigAction->new(sub {
+ $c->log->error(sprintf("Request for %s took over %d seconds. Killing process",
+ $c->req->uri,
+ $max_request_time));
+ $c->log->error(Devel::StackTrace->new->as_string);
+ $c->log->_flush;
+ if (my $sth = $c->model('MB')->context->sql->sth) {
+ $sth->cancel;
+ }
+ exit(42)
+ }));
+
+ $c->$orig(@_);
+
+ alarm(0);
+ }
+ else {
+ $c->$orig(@_);
+ }
+ }, $orig, @_);
};
sub gettext { shift; Translation->instance->gettext(@_) }
diff --cc lib/MusicBrainz/Server/Controller/Doc.pm
index b9aeff2,4373e9f..ffa11a5
--- a/lib/MusicBrainz/Server/Controller/Doc.pm
+++ b/lib/MusicBrainz/Server/Controller/Doc.pm
@@@ -28,11 -28,11 +28,11 @@@ sub show : Path(''
$c->stash(
id => $id,
page => $page,
- google_custom_search => &DBDefs::GOOGLE_CUSTOM_SEARCH,
+ google_custom_search => DBDefs->GOOGLE_CUSTOM_SEARCH,
);
- if ($id =~ /^(Special|User|MetaBrainz|Proposal):/i) {
+ if ($id =~ /^[^:]+:/i && $id !~ /^Category:/i) {
- $c->response->redirect(sprintf('http://%s/%s', DBDefs::WIKITRANS_SERVER, $id));
+ $c->response->redirect(sprintf('http://%s/%s', DBDefs->WIKITRANS_SERVER, $id));
$c->detach;
}
diff --cc lib/MusicBrainz/Server/Controller/User.pm
index 13d017c,6f186e3..9a4fdf6
--- a/lib/MusicBrainz/Server/Controller/User.pm
+++ b/lib/MusicBrainz/Server/Controller/User.pm
@@@ -149,9 -151,9 +151,9 @@@ sub cookie_login : Privat
die "Expired"
if time() > $expiry;
- my $user = $c->model('Editor')->get_by_name($user_name) or last;
+ my $user = $c->model('Editor')->get_by_name($user_name) or return;
- my $correct_pass_sha1 = sha1_base64($user->password . "\t" . DBDefs::SMTP_SECRET_CHECKSUM);
+ my $correct_pass_sha1 = sha1_base64($user->password . "\t" . DBDefs->SMTP_SECRET_CHECKSUM);
die "Password sha1 do not match"
unless $pass_sha1 eq $correct_pass_sha1;
diff --cc lib/MusicBrainz/Server/ControllerBase/WS/2.pm
index 830c4e2,5261a2d..71c022e
--- a/lib/MusicBrainz/Server/ControllerBase/WS/2.pm
+++ b/lib/MusicBrainz/Server/ControllerBase/WS/2.pm
@@@ -101,9 -102,9 +102,9 @@@ sub bad_req : Privat
sub deny_readonly : Private
{
my ($self, $c) = @_;
- if (DBDefs::DB_READ_ONLY) {
+ if (DBDefs->DB_READ_ONLY) {
$c->res->status(503);
- $c->res->content_type("application/xml; charset=UTF-8");
+ $c->res->content_type($c->stash->{serializer}->mime_type . '; charset=utf-8');
$c->res->body($c->stash->{serializer}->output_error("The database is currently in readonly mode and cannot handle your request"));
}
}
diff --cc lib/MusicBrainz/Server/Data/CoverArtArchive.pm
index 1085c87,6bac9ed..96b9bc0
--- a/lib/MusicBrainz/Server/Data/CoverArtArchive.pm
+++ b/lib/MusicBrainz/Server/Data/CoverArtArchive.pm
@@@ -13,8 -13,10 +13,10 @@@ my $caa = Net::CoverArtArchive->new (co
sub find_available_artwork {
my ($self, $mbid) = @_;
- my $prefix = DBDefs::COVER_ART_ARCHIVE_DOWNLOAD_PREFIX."/release/$mbid";
+ my $prefix = DBDefs->COVER_ART_ARCHIVE_DOWNLOAD_PREFIX."/release/$mbid";
+ my $types = { map { $_->name => $_ } $self->c->model('CoverArtType')->get_all() };
+
return [
map {
Net::CoverArtArchive::CoverArt->new(
diff --cc lib/MusicBrainz/Server/Data/WikiDoc.pm
index f0c74f5,a0582af..f928eff
--- a/lib/MusicBrainz/Server/Data/WikiDoc.pm
+++ b/lib/MusicBrainz/Server/Data/WikiDoc.pm
@@@ -115,7 -120,7 +120,7 @@@ sub _load_pag
return MusicBrainz::Server::Entity::WikiDocPage->new({ canonical => "MusicBrainz_Documentation" })
if ($id eq "");
- my $doc_url = sprintf "http://%s/%s?action=render", DBDefs->WIKITRANS_SERVER, $id;
- my $doc_url = sprintf "http://%s/%s?action=render&redirect=no", &DBDefs::WIKITRANS_SERVER, $id;
++ my $doc_url = sprintf "http://%s/%s?action=render&redirect=no", DBDefs->WIKITRANS_SERVER, $id;
if (defined $version) {
$doc_url .= "&oldid=$version";
}
diff --cc lib/MusicBrainz/Server/Form/Search/Search.pm
index ad63fff,353a06c..bbd9ac7
--- a/lib/MusicBrainz/Server/Form/Search/Search.pm
+++ b/lib/MusicBrainz/Server/Form/Search/Search.pm
@@@ -40,10 -40,10 +40,10 @@@ sub options_typ
'cdstub' => l('CD Stub'),
'editor' => l('Editor'),
'freedb' => l('FreeDB'),
- 'tag' => l('Tag'),
+ 'tag' => lp('Tag', 'noun'),
);
- push @options, ( 'doc' => l('Documentation') ) if &DBDefs::GOOGLE_CUSTOM_SEARCH;
+ push @options, ( 'doc' => l('Documentation') ) if DBDefs->GOOGLE_CUSTOM_SEARCH;
return \@options;
}
diff --cc lib/MusicBrainz/Server/Translation.pm
index c958b76,2c64394..cd42bc7
--- a/lib/MusicBrainz/Server/Translation.pm
+++ b/lib/MusicBrainz/Server/Translation.pm
@@@ -107,8 -120,10 +120,10 @@@ sub set_languag
@avail_lang = map { s/-([a-z]{2})/_\U$1/; $_; }
grep {
my $l = $_;
- grep { $l eq $_ } DBDefs::MB_LANGUAGES
+ grep { $l eq $_ } DBDefs->MB_LANGUAGES
} $self->all_system_languages;
+ } else {
+ @avail_lang = ('en');
}
my $set_lang = web_set_locale(\@avail_lang, [ 'utf-8' ], LC_MESSAGES);
if (!defined $set_lang) {
diff --cc t/lib/t/MusicBrainz/Server/Data/EditNote.pm
index 971990c,412bf2f..54fc51f
--- a/t/lib/t/MusicBrainz/Server/Data/EditNote.pm
+++ b/t/lib/t/MusicBrainz/Server/Data/EditNote.pm
@@@ -129,11 -129,13 +129,13 @@@ $test->c->model('Vote')->enter_votes(2
$en_data->add_note($edit->id, { text => "This is my note!", editor_id => 3 });
-my $server = DBDefs::WEB_SERVER_USED_IN_EMAIL;
+my $server = DBDefs->WEB_SERVER_USED_IN_EMAIL;
my $email_transport = MusicBrainz::Server::Email->get_test_transport;
- is(scalar @{ $email_transport->deliveries }, 2);
+ is($email_transport->delivery_count, 2);
+
+ my $email2 = $email_transport->shift_deliveries->{email};
+ my $email = $email_transport->shift_deliveries->{email};
- my $email = $email_transport->deliveries->[1]->{email};
is($email->get_header('Subject'), 'Note added to your edit #' . $edit->id, 'Subject explains a note was added to edit');
is($email->get_header('To'), '"editor1" <[email protected]>', 'Email is addressed to editor1');
like($email->get_body, qr{http://$server/edit/${\ $edit->id }}, 'Email body contains edit url');
diff --cc t/lib/t/MusicBrainz/Server/Data/Vote.pm
index 332dee2,74fae80..71864d3
--- a/t/lib/t/MusicBrainz/Server/Data/Vote.pm
+++ b/t/lib/t/MusicBrainz/Server/Data/Vote.pm
@@@ -70,14 -70,14 +70,14 @@@ $vote_data->enter_votes(2, { edit_id =
$vote_data->enter_votes(2, { edit_id => $edit->id, vote => $VOTE_YES });
my $email_transport = MusicBrainz::Server::Email->get_test_transport;
- is(scalar @{ $email_transport->deliveries }, 1);
+ is($email_transport->delivery_count, 1);
- my $email = $email_transport->deliveries->[-1]->{email};
+ my $email = $email_transport->shift_deliveries->{email};
is($email->get_header('Subject'), 'Someone has voted against your edit #2', 'Subject explains someone has voted against your edit');
-is($email->get_header('References'), sprintf '<edit-%d@%s>', $edit->id, &DBDefs::WEB_SERVER_USED_IN_EMAIL, 'References header contains edit id');
+is($email->get_header('References'), sprintf '<edit-%d@%s>', $edit->id, DBDefs->WEB_SERVER_USED_IN_EMAIL, 'References header contains edit id');
is($email->get_header('To'), '"editor1" <[email protected]>', 'To header contains editor email');
-my $server = DBDefs::WEB_SERVER_USED_IN_EMAIL;
+my $server = DBDefs->WEB_SERVER_USED_IN_EMAIL;
like($email->get_body, qr{http://$server/edit/${\ $edit->id }}, 'body contains link to edit');
like($email->get_body, qr{'editor2'}, 'body mentions editor2');
commit 5973d6afc938033760a193ad0b743fcf7663c781
Merge: 75bd2f4 bd949ec
Author: Ian McEwen <[email protected]>
Date: Mon Sep 3 03:22:40 2012 -0700
Merge branch 'master' into mbs-4578-dbdefs
Conflicts:
lib/MusicBrainz/Server/Data/WebService.pm
lib/MusicBrainz/Server/Data/WikiDoc.pm
lib/MusicBrainz/Server/Entity/URL/ASIN.pm
diff --cc lib/DBDefs/Default.pm
index 0b59466,0d6c551..b14a321
--- a/lib/DBDefs/Default.pm
+++ b/lib/DBDefs/Default.pm
@@@ -316,14 -344,14 +316,14 @@@ sub GOOGLE_ANALYTICS_CODE { ''
# If you're using multiple front-end webservers make sure they all connect to
# the same memcached server. Also make sure enough memory is configured for
# memcached so sessions aren't evicted from the cache.
- sub SESSION_STORE { "Session::Store::Memcached" }
+ sub SESSION_STORE { "Session::Store::MusicBrainz" }
sub SESSION_STORE_ARGS
{
+ my $self = shift;
return {
memcached_new_args => {
- data => MEMCACHED_SERVERS(),
- namespace => MEMCACHED_NAMESPACE(),
- memcached_class => 'Cache::Memcached::Fast',
+ data => $self->MEMCACHED_SERVERS(),
+ namespace => $self->MEMCACHED_NAMESPACE()
}
}
}
diff --cc lib/MusicBrainz/Server/Data/WebService.pm
index 73120c9,65f2379..ffdd215
--- a/lib/MusicBrainz/Server/Data/WebService.pm
+++ b/lib/MusicBrainz/Server/Data/WebService.pm
@@@ -197,14 -200,9 +200,9 @@@ sub xml_searc
};
}
- my $url = 'http://' . DBDefs::LUCENE_SERVER . "/ws/2/$resource/?" .
+ my $url = 'http://' . DBDefs->LUCENE_SERVER . "/ws/2/$resource/?" .
"max=$limit&type=$resource&fmt=xml&offset=$offset&query=". uri_escape_utf8($query);
-
- require LWP::UserAgent;
- my $ua = LWP::UserAgent->new;
- $ua->env_proxy;
- my $response = $ua->get($url);
- $ua->timeout(2);
+ my $response = $self->c->lwp->get($url);
if ( $response->is_success )
{
return { xml => decode('utf-8', $response->content) };
diff --cc lib/MusicBrainz/Server/Data/WikiDoc.pm
index 5fbf693,4fe854f..f0c74f5
--- a/lib/MusicBrainz/Server/Data/WikiDoc.pm
+++ b/lib/MusicBrainz/Server/Data/WikiDoc.pm
@@@ -152,11 -149,8 +149,8 @@@ sub get_versio
{
my ($self, $id) = @_;
- my $doc_url = sprintf "http://%s/?title=%s", &DBDefs::WIKITRANS_SERVER, $id;
+ my $doc_url = sprintf "http://%s/?title=%s", DBDefs->WIKITRANS_SERVER, $id;
-
- my $ua = LWP::UserAgent->new();
- $ua->env_proxy;
- my $response = $ua->get($doc_url);
+ my $response = $self->c->lwp->get($doc_url);
my $content = $response->decoded_content;
diff --cc lib/MusicBrainz/Server/Entity/URL/ASIN.pm
index e5d0542,aad2aa5..e74c871
--- a/lib/MusicBrainz/Server/Entity/URL/ASIN.pm
+++ b/lib/MusicBrainz/Server/Entity/URL/ASIN.pm
@@@ -27,12 -27,11 +27,11 @@@ sub sidebar_name { shift->pretty_name
sub affiliate_url {
my $self = shift;
my $url = $self->url;
- if ($url =~ m{^http://(?:www.)?(.*?\.)amazon\.([a-z\.]+)(?:\:[0-9]+)?/.*/([0-9B][0-9A-Z]{9})(?:[^0-9A-Z]|$)}i) {
- my $asin = $3;
- my $ass_id = DBDefs->AMAZON_ASSOCIATE_TAG;
- return URI->new("http://amazon.$2/exec/obidos/ASIN/$asin/$ass_id?v=glance&s=music");
- }
- else {
+ if ($url =~ m{^http://(?:.*?\.)(amazon\.([a-z\.]+))(?:\:[0-9]+)?/[^?]+$}i) {
- my $ass_id = DBDefs::AWS_ASSOCIATE_ID($1);
++ my $ass_id = DBDefs->AWS_ASSOCIATE_ID($1);
+ return $url unless $ass_id;
+ return URI->new("$url?tag=$ass_id");
+ } else {
return $url;
}
}
commit 75bd2f4879611b230f7ae830f80bbc55d9ff83a7
Author: Ian McEwen <[email protected]>
Date: Wed Aug 29 15:41:29 2012 -0700
MBS-4578: remove DB_SCHEMA_SEQUENCE from DBDefs::Default to prevent accidental increments due to git updates
diff --git a/lib/DBDefs.pm.sample b/lib/DBDefs.pm.sample
index e3ddc8e..4841641 100644
--- a/lib/DBDefs.pm.sample
+++ b/lib/DBDefs.pm.sample
@@ -83,6 +83,8 @@ MusicBrainz::Server::DatabaseConnectionFactory->register_databases(
# The schema sequence number. Must match the value in
# replication_control.current_schema_sequence.
+# This is required, there is no default in order to prevent it changing without
+# manual intervention.
sub DB_SCHEMA_SEQUENCE { 15 }
# What type of server is this?
diff --git a/lib/DBDefs/Default.pm b/lib/DBDefs/Default.pm
index 24f7066..0b59466 100644
--- a/lib/DBDefs/Default.pm
+++ b/lib/DBDefs/Default.pm
@@ -47,10 +47,6 @@ sub STATIC_FILES_DIR { my $self = shift; $self->MB_SERVER_ROOT . '/root/static'
# The Database
################################################################################
-# The schema sequence number. Must match the value in
-# replication_control.current_schema_sequence.
-sub DB_SCHEMA_SEQUENCE { 15 }
-
# What type of server is this?
# * RT_MASTER - This is a master replication server. Changes are allowed, and
# they result in replication packets being produced.
commit 162f4da09ea8944601d8c029c482b62162d204e3
Author: Ian McEwen <[email protected]>
Date: Wed Aug 29 14:51:33 2012 -0700
MBS-4578: correct Model::MB with '::' -> '->' change after merge.
diff --git a/lib/MusicBrainz/Server/Model/MB.pm b/lib/MusicBrainz/Server/Model/MB.pm
index 8528a19..26ef183 100644
--- a/lib/MusicBrainz/Server/Model/MB.pm
+++ b/lib/MusicBrainz/Server/Model/MB.pm
@@ -33,9 +33,9 @@ sub _build_context {
);
$c->dbh->do("SET statement_timeout = " .
- (DBDefs::MAX_REQUEST_TIME() * 1000))
- if (defined(DBDefs::MAX_REQUEST_TIME)
- && DBDefs::MAX_REQUEST_TIME > 0);
+ (DBDefs->MAX_REQUEST_TIME() * 1000))
+ if (defined(DBDefs->MAX_REQUEST_TIME)
+ && DBDefs->MAX_REQUEST_TIME > 0);
return $c;
}
commit 493e73ff3671a87cf7cc89616a66dff717858bf2
Merge: 40e5743 8c3e436
Author: Ian McEwen <[email protected]>
Date: Wed Aug 29 14:51:01 2012 -0700
Merge branch 'master' into mbs-4578-dbdefs
Conflicts:
lib/MusicBrainz/Server/Connector.pm
lib/MusicBrainz/Server/Model/MB.pm
diff --cc Makefile.PL
index 63cbfe8,c909eca..b07a0b9
--- a/Makefile.PL
+++ b/Makefile.PL
@@@ -48,9 -47,8 +48,9 @@@ requires 'Email::MIME::Creator'
requires 'Email::Valid';
requires 'Encode::Detect' => '1.01';
requires 'Exception::Class' => '1.29';
+requires 'File::Spec';
requires 'Function::Parameters';
- requires 'HTML::FormHandler' => '0.36002';
+ requires 'HTML::FormHandler' => '0.40013';
requires 'HTML::Tiny' => '1.05';
requires 'HTML::TreeBuilder::XPath';
requires 'IO::All';
diff --cc lib/MusicBrainz/Server/Model/MB.pm
index 13ef034,430d93d..8528a19
--- a/lib/MusicBrainz/Server/Model/MB.pm
+++ b/lib/MusicBrainz/Server/Model/MB.pm
@@@ -20,16 -22,22 +22,22 @@@ sub with_transaction
sub _build_context {
my $self = shift;
-
- if (DBDefs::_RUNNING_TESTS()) {
+ if (DBDefs->_RUNNING_TESTS()) {
require MusicBrainz::Server::Test;
return MusicBrainz::Server::Test->create_test_context;
}
else {
- my $cache_opts = &DBDefs::CACHE_MANAGER_OPTIONS;
+ my $cache_opts = DBDefs->CACHE_MANAGER_OPTIONS;
- return MusicBrainz::Server::Context->new(
+ my $c = MusicBrainz::Server::Context->new(
cache_manager => MusicBrainz::Server::CacheManager->new($cache_opts)
);
+
+ $c->dbh->do("SET statement_timeout = " .
+ (DBDefs::MAX_REQUEST_TIME() * 1000))
+ if (defined(DBDefs::MAX_REQUEST_TIME)
+ && DBDefs::MAX_REQUEST_TIME > 0);
+
+ return $c;
}
}
commit 40e5743f4c2a63184208d73d51cb44c81534edc2
Author: Ian McEwen <[email protected]>
Date: Wed Aug 29 14:41:07 2012 -0700
MBS-4578: rename DBDefs.pm.default to DBDefs.pm.sample
diff --git a/INSTALL.md b/INSTALL.md
index 41c0684..3a7eca4 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -73,7 +73,7 @@ Server configuration
2. Modify the server configuration file.
- cp lib/DBDefs.pm.default lib/DBDefs.pm
+ cp lib/DBDefs.pm.sample lib/DBDefs.pm
Fill in the appropriate values for `MB_SERVER_ROOT` and `WEB_SERVER`.
diff --git a/lib/DBDefs.pm.default b/lib/DBDefs.pm.sample
similarity index 100%
rename from lib/DBDefs.pm.default
rename to lib/DBDefs.pm.sample
commit cf298fc455f0fe3dc81346756d5da03aee88cd17
Author: Ian McEwen <[email protected]>
Date: Wed Aug 29 14:39:26 2012 -0700
MBS-4578: clean up .default
diff --git a/lib/DBDefs.pm.default b/lib/DBDefs.pm.default
index 531f8fc..e3ddc8e 100644
--- a/lib/DBDefs.pm.default
+++ b/lib/DBDefs.pm.default
@@ -26,21 +26,28 @@ use warnings;
#____________________________________________________________________________
package DBDefs;
+use parent 'DBDefs::Default';
+use MusicBrainz::Server::Replication ':replication_type';
+use MusicBrainz::Server::DatabaseConnectionFactory;
+
+# Commented-out lines should generally have sane defaults; anything that's uncommented
+# probably needs personal attention.
################################################################################
# Directories
################################################################################
# The server root, i.e. the parent directory of admin, bin, lib, root, etc.
-sub MB_SERVER_ROOT { "/home/httpd/musicbrainz/musicbrainz-server" }
+# By default, this uses the path of lib/DBDefs/Default.pm, minus '/lib/DBDefs/Default.pm'
+# sub MB_SERVER_ROOT { "/home/httpd/musicbrainz/musicbrainz-server" }
# Where static files are located
-sub STATIC_FILES_DIR { MB_SERVER_ROOT . '/root/static' }
+# sub STATIC_FILES_DIR { my $self= shift; $self->MB_SERVER_ROOT . '/root/static' }
################################################################################
# The Database
################################################################################
-use MusicBrainz::Server::DatabaseConnectionFactory;
+# Configuring databases here is required; there are no defaults.
MusicBrainz::Server::DatabaseConnectionFactory->register_databases(
# How to connect when we need read-write access to the database
READWRITE => {
@@ -88,8 +95,7 @@ sub DB_SCHEMA_SEQUENCE { 15 }
# DB_STAGING_SERVER to 0.
# * RT_STANDALONE - This server neither generates nor uses replication
# packets. Changes to the database are allowed.
-use MusicBrainz::Server::Replication ':replication_type';
-sub REPLICATION_TYPE { RT_STANDALONE }
+# sub REPLICATION_TYPE { RT_STANDALONE }
################################################################################
# HTTP Server Names
@@ -98,22 +104,23 @@ sub REPLICATION_TYPE { RT_STANDALONE }
# The host names used by the server.
# To use a port number other than 80, add it like so: "myhost:8000"
sub WEB_SERVER { "www.musicbrainz.example.com" }
-sub LUCENE_SERVER { "search.musicbrainz.org" }
-sub WEB_SERVER_USED_IN_EMAIL { WEB_SERVER }
+# sub LUCENE_SERVER { "search.musicbrainz.org" }
+# sub WEB_SERVER_USED_IN_EMAIL { my $self = shift; $self->WEB_SERVER }
################################################################################
# Mail Settings
################################################################################
-sub SMTP_SERVER { "localhost" }
+# sub SMTP_SERVER { "localhost" }
# This value should be set to some secret value for your server. Any old
# string of stuff should do; something suitably long and random, like for
# passwords. However you MUST change it from the default
# value (the empty string). This is so an attacker can't just look in CVS and
# see the default secret value, and then use it to attack your server.
-sub SMTP_SECRET_CHECKSUM { "" }
-sub EMAIL_VERIFICATION_TIMEOUT { 604800 } # one week
+
+# sub SMTP_SECRET_CHECKSUM { "" }
+# sub EMAIL_VERIFICATION_TIMEOUT { 604800 } # one week
################################################################################
# Server Settings
@@ -123,40 +130,40 @@ sub EMAIL_VERIFICATION_TIMEOUT { 604800 } # one week
# Keeping this defined enables the banner that is shown across the top of each
# page, as well as some testing features that are only enabled when not on
# the live server.
-sub DB_STAGING_SERVER { 1 }
+# sub DB_STAGING_SERVER { 1 }
# This description is shown in the banner when DB_STAGING_SERVER is enabled.
# If left undefined the default value will be shown.
# Default: "This is a MusicBrainz development server."
-sub DB_STAGING_SERVER_DESCRIPTION { "" }
+# sub DB_STAGING_SERVER_DESCRIPTION { "" }
# Only change this if running a non-sanitized database on a dev server,
# e.g. http://test.musicbrainz.org.
-sub DB_STAGING_SERVER_SANITIZED { 1 }
+# sub DB_STAGING_SERVER_SANITIZED { 1 }
# Testing features enable "Accept edit" and "Reject edit" links on edits,
# this should only be enabled on staging servers. Also, this enables non-admin
# users to edit user permissions.
-sub DB_STAGING_TESTING_FEATURES { DB_STAGING_SERVER }
+# sub DB_STAGING_TESTING_FEATURES { my $self = shift; $self->DB_STAGING_SERVER }
################################################################################
# Documentation Server Settings
################################################################################
-sub WIKITRANS_SERVER { "wiki.musicbrainz.org" }
+# sub WIKITRANS_SERVER { "wiki.musicbrainz.org" }
# The path to MediaWiki's api.php file. This is required to automatically
# determine which documentation pages need to be updated in the
# transclusion table.
-sub WIKITRANS_SERVER_API { "wiki.musicbrainz.org/-/api.php" }
+# sub WIKITRANS_SERVER_API { "wiki.musicbrainz.org/-/api.php" }
-sub WIKITRANS_INDEX_FILE { MB_SERVER_ROOT() . "/root/static/wikidocs/index.txt" }
-sub WIKITRANS_INDEX_URL { "http://musicbrainz.org/static/wikidocs/index.txt" }
+# sub WIKITRANS_INDEX_FILE { my $self = shift; $self->MB_SERVER_ROOT . "/root/static/wikidocs/index.txt" }
+# sub WIKITRANS_INDEX_URL { "http://musicbrainz.org/static/wikidocs/index.txt" }
# To enable documentation search on your server, create your own Google Custom
# Search engine and enter its ID as the value of GOOGLE_CUSTOM_SEARCH.
# Alternatively, if you're okay with the search results pointing to
# the musicbrainz.org server, you can use '006539527923176875863:xsv3chs2ovc'.
-sub GOOGLE_CUSTOM_SEARCH { '' }
+# sub GOOGLE_CUSTOM_SEARCH { '' }
################################################################################
# Cache Settings
@@ -164,11 +171,11 @@ sub GOOGLE_CUSTOM_SEARCH { '' }
# MEMCACHED_SERVERS allows configuration of global memcached servers, if more
# close configuration is not required
-sub MEMCACHED_SERVERS { return ['127.0.0.1:11211']; };
+# sub MEMCACHED_SERVERS { return ['127.0.0.1:11211']; };
# MEMCACHED_NAMESPACE allows configuration of a global memcached namespace, if
# more close configuration is not required
-sub MEMCACHED_NAMESPACE { return 'MB:'; };
+# sub MEMCACHED_NAMESPACE { return 'MB:'; };
# PLUGIN_CACHE_OPTIONS are the options configured for Plugin::Cache. $c->cache
# is provided by Plugin::Cache, and is required for HTTP Digest authentication
@@ -180,14 +187,14 @@ sub MEMCACHED_NAMESPACE { return 'MB:'; };
# If you want to use something such as Memcached, the settings here should be
# the same as the settings you use for the session store.
#
-sub PLUGIN_CACHE_OPTIONS {
- return {
-# class => "Cache::Memory",
- class => "Cache::Memcached::Fast",
- servers => MEMCACHED_SERVERS(),
- namespace => MEMCACHED_NAMESPACE(),
- };
-};
+# sub PLUGIN_CACHE_OPTIONS {
+# my $self = shift;
+# return {
+# class => "Cache::Memcached::Fast",
+# servers => $self->MEMCACHED_SERVERS(),
+# namespace => $self->MEMCACHED_NAMESPACE(),
+# };
+# };
# Use memcached and a small in-memory cache, see below if you
# want to disable caching
@@ -195,26 +202,26 @@ sub PLUGIN_CACHE_OPTIONS {
# The caching options here relate to object caching - such as caching artists,
# releases, etc in order to speed up queries. If you are using Memcached
# to store sessions as well this should be a *different* memcached server.
-our %CACHE_MANAGER_OPTIONS = (
- profiles => {
- memory => {
- class => 'Cache::Memory',
- wrapped => 1,
- keys => [qw( at g c lng lt mf rgt rs rp scr wt )],
- options => {
- default_expires => '1 hour',
- },
- },
- external => {
- class => 'Cache::Memcached::Fast',
- options => {
- servers => MEMCACHED_SERVERS(),
- namespace => MEMCACHED_NAMESPACE()
- },
- },
- },
- default_profile => 'external',
-);
+# our %CACHE_MANAGER_OPTIONS = (
+# profiles => {
+# memory => {
+# class => 'Cache::Memory',
+# wrapped => 1,
+# keys => [qw( at g c lng lt mf rgt rs rp scr wt )],
+# options => {
+# default_expires => '1 hour',
+# },
+# },
+# external => {
+# class => 'Cache::Memcached::Fast',
+# options => {
+# servers => MEMCACHED_SERVERS(),
+# namespace => MEMCACHED_NAMESPACE()
+# },
+# },
+# },
+# default_profile => 'external',
+# );
# No caching
#our %CACHE_MANAGER_OPTIONS = (
@@ -227,7 +234,7 @@ our %CACHE_MANAGER_OPTIONS = (
# default_profile => 'null',
#);
-sub CACHE_MANAGER_OPTIONS { \%CACHE_MANAGER_OPTIONS }
+# sub CACHE_MANAGER_OPTIONS { \%CACHE_MANAGER_OPTIONS }
################################################################################
# Rate-Limiting
@@ -238,7 +245,7 @@ sub CACHE_MANAGER_OPTIONS { \%CACHE_MANAGER_OPTIONS }
# an error).
# Just like the memcached server settings, there is NO SECURITY built into the
# ratelimit protocol, so be careful about enabling it.
-sub RATELIMIT_SERVER { undef }
+# sub RATELIMIT_SERVER { undef }
################################################################################
# Minify settings
@@ -246,9 +253,9 @@ sub RATELIMIT_SERVER { undef }
# The following two values determine how scripts and styles are minified. By
# default, a dummy minifier is used:
-sub MINIFY_DUMMY { my %args = @_; return $args{input}; }
-sub MINIFY_SCRIPTS { return \&MINIFY_DUMMY; }
-sub MINIFY_STYLES { return \&MINIFY_DUMMY; }
+# sub MINIFY_DUMMY { shift; my %args = @_; return $args{input}; }
+# sub MINIFY_SCRIPTS { return \&MINIFY_DUMMY; }
+# sub MINIFY_STYLES { return \&MINIFY_DUMMY; }
# If you wish to minify either javascript or css, uncomment the following lines
# and install the neccesary CPAN packages.
@@ -262,77 +269,79 @@ sub MINIFY_STYLES { return \&MINIFY_DUMMY; }
# Set this value to something true (e.g. 1) to set the server to read-only.
# To date, this option is widely ignored in the code; don't be surprised if you
# set it to true and find that writes are still possible.
-sub DB_READ_ONLY { 0 }
+# sub DB_READ_ONLY { 0 }
# Set this value to a message that you'd like to display to users when
# they attempt to write to your read-only database (not used if DB_READ_ONLY
# is false)
-sub DB_READ_ONLY_MESSAGE { <<EOF }
-This server is temporarily in read-only mode
-for database maintainance.
-EOF
+# sub DB_READ_ONLY_MESSAGE { <<EOF }
+# This server is temporarily in read-only mode
+# for database maintainance.
+# EOF
# Development server feature.
# Used to display which git branch is currently running along with information
# about the last commit
-sub GIT_BRANCH
-{
- if (DB_STAGING_SERVER) {
- my $branch = `git branch --no-color 2> /dev/null | sed -e '/^[^*]/d'`;
- $branch =~ s/\* (.+)/$1/;
- my $sha = `git log -1 --format=format:"%h"`;
- my $msg = `git log -1 --format=format:"Last commit by %an on %ad%n%s" --date=short`;
- return $branch, $sha, $msg;
- }
-}
+# sub GIT_BRANCH
+# {
+# my $self = shift;
+# if ($self->DB_STAGING_SERVER) {
+# my $branch = `git branch --no-color 2> /dev/null | sed -e '/^[^*]/d'`;
+# $branch =~ s/\* (.+)/$1/;
+# my $sha = `git log -1 --format=format:"%h"`;
+# my $msg = `git log -1 --format=format:"Last commit by %an on %ad%n%s" --date=short`;
+# return $branch, $sha, $msg;
+# }
+# }
# How long (in seconds) a web/rdf session can go "idle" before being timed out
-sub WEB_SESSION_SECONDS_TO_LIVE { 3600 * 3 }
+# sub WEB_SESSION_SECONDS_TO_LIVE { 3600 * 3 }
# The cookie name to use
-sub SESSION_COOKIE { "AF_SID" }
+# sub SESSION_COOKIE { "AF_SID" }
# The domain into which the session cookie is written
-sub SESSION_DOMAIN { undef }
+# sub SESSION_DOMAIN { undef }
# How long an annotation is considered as being locked.
-sub ANNOTATION_LOCK_TIME { 60*15 }
+# sub ANNOTATION_LOCK_TIME { 60*15 }
# Amazon associate and developer ids
-my %amazon_store_associate_ids = (
- 'amazon.ca' => 'musicbrainz01-20',
- 'amazon.co.jp' => 'musicbrainz-22',
- 'amazon.co.uk' => 'musicbrainz0c-21',
- 'amazon.com' => 'musicbrainz0d-20',
- 'amazon.de' => 'musicbrainz00-21',
- 'amazon.fr' => 'musicbrainz0e-21',
- 'amazon.it' => '', #TODO: Someone should probably sign up for an associate ID.
-);
-
-sub AWS_ASSOCIATE_ID
-{
- return keys %amazon_store_associate_ids if not @_;
- return $amazon_store_associate_ids{$_[0]};
-}
-
-sub AWS_PRIVATE { '' }
-sub AWS_PUBLIC { '' }
-
-sub AMAZON_ASSOCIATE_TAG { '' }
+# my %amazon_store_associate_ids = (
+# 'amazon.ca' => 'musicbrainz01-20',
+# 'amazon.co.jp' => 'musicbrainz-22',
+# 'amazon.co.uk' => 'musicbrainz0c-21',
+# 'amazon.com' => 'musicbrainz0d-20',
+# 'amazon.de' => 'musicbrainz00-21',
+# 'amazon.fr' => 'musicbrainz0e-21',
+# 'amazon.it' => '', #TODO: Someone should probably sign up for an associate ID.
+# );
+
+# sub AWS_ASSOCIATE_ID
+# {
+# shift;
+# return keys %amazon_store_associate_ids if not @_;
+# return $amazon_store_associate_ids{$_[0]};
+# }
+
+# sub AWS_PRIVATE { '' }
+# sub AWS_PUBLIC { '' }
+
+# sub AMAZON_ASSOCIATE_TAG { '' }
# To enable use of reCAPTCHA:
# 1. make sure $ENV{'REMOTE_ADDR'} is the ip address of the visitor.
# 2. replace undef with your recaptcha keys:
-sub RECAPTCHA_PUBLIC_KEY { return undef }
-sub RECAPTCHA_PRIVATE_KEY { return undef }
+# sub RECAPTCHA_PUBLIC_KEY { return undef }
+# sub RECAPTCHA_PRIVATE_KEY { return undef }
# internet archive private/public keys (for coverartarchive.org).
-sub COVER_ART_ARCHIVE_ID { };
-sub COVER_ART_ARCHIVE_KEY { };
-sub COVER_ART_ARCHIVE_UPLOAD_PREFIXER { sprintf("http://%s.s3.us.archive.org/", shift) };
-sub COVER_ART_ARCHIVE_DOWNLOAD_PREFIX { "http://coverartarchive.org" };
+# sub COVER_ART_ARCHIVE_ID { };
+# sub COVER_ART_ARCHIVE_KEY { };
+# sub COVER_ART_ARCHIVE_UPLOAD_PREFIXER { shift; sprintf("http://%s.s3.us.archive.org/", shift) };
+# sub COVER_ART_ARCHIVE_DOWNLOAD_PREFIX { "http://coverartarchive.org" };
# Add a Google Analytics tracking code to enable Google Analytics tracking.
-sub GOOGLE_ANALYTICS_CODE { '' }
+# sub GOOGLE_ANALYTICS_CODE { '' }
################################################################################
# Sessions (advanced)
@@ -344,44 +353,45 @@ sub GOOGLE_ANALYTICS_CODE { '' }
# If you're using multiple front-end webservers make sure they all connect to
# the same memcached server. Also make sure enough memory is configured for
# memcached so sessions aren't evicted from the cache.
-sub SESSION_STORE { "Session::Store::Memcached" }
-sub SESSION_STORE_ARGS
-{
- return {
- memcached_new_args => {
- data => MEMCACHED_SERVERS(),
- namespace => MEMCACHED_NAMESPACE(),
- memcached_class => 'Cache::Memcached::Fast',
- }
- }
-}
+# sub SESSION_STORE { "Session::Store::Memcached" }
+# sub SESSION_STORE_ARGS
+# {
+# my $self = shift;
+# return {
+# memcached_new_args => {
+# data => $self->MEMCACHED_SERVERS(),
+# namespace => $self->MEMCACHED_NAMESPACE()
+# }
+# }
+# }
# MusicBrainz::Server::Wizard saves wizard sessions in memcached,
# seperately from the regular session store.
-sub WIZARD_MEMCACHED
-{
- return { servers => MEMCACHED_SERVERS(), namespace => MEMCACHED_NAMESPACE() };
-}
+# sub WIZARD_MEMCACHED
+# {
+# my $self = shift;
+# return { servers => $self->MEMCACHED_SERVERS(), namespace => $self->MEMCACHED_NAMESPACE() };
+# }
-sub USE_ETAGS { 1 }
+# sub USE_ETAGS { 1 }
-sub CATALYST_DEBUG { 1 }
+# sub CATALYST_DEBUG { 1 }
# If you are developing on MusicBrainz, you should set this to a true value
# This will turn off some optimizations (such as CSS/JS compression) to make
# developing and debuging easier
-sub DEVELOPMENT_SERVER { 1 }
+# sub DEVELOPMENT_SERVER { 1 }
# Please activate the officially approved languages here. Not every .po
# file is active because we might have fully translated languages which
# are not yet properly supported, like right-to-left languages
-sub MB_LANGUAGES {qw()}
+# sub MB_LANGUAGES {qw()}
# Private, please do not change
-sub _RUNNING_TESTS { 0 }
+# sub _RUNNING_TESTS { 0 }
# Set this to an email address and the server will email any bugs to you
-sub EMAIL_BUGS { undef }
+# sub EMAIL_BUGS { undef }
################################################################################
# Profiling
@@ -389,35 +399,35 @@ sub EMAIL_BUGS { undef }
# Set these to >0 to enable profiling
# Log if a request in /ws takes more than x seconds
-sub PROFILE_WEB_SERVICE { 0 }
+# sub PROFILE_WEB_SERVICE { 0 }
# Log if a request in / (not /ws) takes more than x seconds
-sub PROFILE_SITE { 0 }
+# sub PROFILE_SITE { 0 }
# If you want the FastCGI processes to restart, configure this
-sub AUTO_RESTART {
-# return {
-# active => 1,
-# check_each => 10,
-# max_bits => 134217728,
-# min_handled_requests => 100
-# }
-}
+# sub AUTO_RESTART {
+## return {
+## active => 1,
+## check_each => 10,
+## max_bits => 134217728,
+## min_handled_requests => 100
+## }
+# }
# The maximum amount of time a process can be serving a single request
# If undef, the process is never killed
# If set to a positive integer, the process can server a single request
# for MAX_REQUEST_TIME seconds, and if it is still not done the process
# will be killed (and log a message about the request it was serving).
-sub MAX_REQUEST_TIME { undef }
-
-sub LOGGER_ARGUMENTS {
- return (
- outputs => [
- [ 'Screen', min_level => 'debug', newline => 1 ],
- ],
- )
-}
+# sub MAX_REQUEST_TIME { undef }
+
+# sub LOGGER_ARGUMENTS {
+# return (
+# outputs => [
+# [ 'Screen', min_level => 'debug', newline => 1 ],
+# ],
+# )
+# }
1;
# eof DBDefs.pm
diff --git a/lib/DBDefs/Default.pm b/lib/DBDefs/Default.pm
index 5645fc6..24f7066 100644
--- a/lib/DBDefs/Default.pm
+++ b/lib/DBDefs/Default.pm
@@ -85,6 +85,7 @@ sub SMTP_SERVER { "localhost" }
# passwords. However you MUST change it from the default
# value (the empty string). This is so an attacker can't just look in CVS and
# see the default secret value, and then use it to attack your server.
+
sub SMTP_SECRET_CHECKSUM { "" }
sub EMAIL_VERIFICATION_TIMEOUT { 604800 } # one week
@@ -156,7 +157,6 @@ sub MEMCACHED_NAMESPACE { return 'MB:'; };
sub PLUGIN_CACHE_OPTIONS {
my $self = shift;
return {
-# class => "Cache::Memory",
class => "Cache::Memcached::Fast",
servers => $self->MEMCACHED_SERVERS(),
namespace => $self->MEMCACHED_NAMESPACE(),
@@ -285,7 +285,7 @@ my %amazon_store_associate_ids = (
sub AWS_ASSOCIATE_ID
{
- shift;
+ shift;
return keys %amazon_store_associate_ids if not @_;
return $amazon_store_associate_ids{$_[0]};
}
@@ -323,12 +323,11 @@ sub GOOGLE_ANALYTICS_CODE { '' }
sub SESSION_STORE { "Session::Store::Memcached" }
sub SESSION_STORE_ARGS
{
- my $self = shift;
+ my $self = shift;
return {
memcached_new_args => {
data => $self->MEMCACHED_SERVERS(),
- namespace => $self->MEMCACHED_NAMESPACE(),
- memcached_class => 'Cache::Memcached::Fast',
+ namespace => $self->MEMCACHED_NAMESPACE()
}
}
}
@@ -337,7 +336,7 @@ sub SESSION_STORE_ARGS
# seperately from the regular session store.
sub WIZARD_MEMCACHED
{
- my $self = shift;
+ my $self = shift;
return { servers => $self->MEMCACHED_SERVERS(), namespace => $self->MEMCACHED_NAMESPACE() };
}
commit 07c3940e6a656af732fe621e5e39b1a32f9149f4
Author: Ian McEwen <[email protected]>
Date: Wed Aug 29 14:24:16 2012 -0700
MBS-4578: Switch to using __FILE__ and File::Spec/Cwd for MB_SERVER_ROOT
diff --git a/Makefile.PL b/Makefile.PL
index 8e8f8e1..63cbfe8 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -26,6 +26,7 @@ requires 'CGI::Expand';
requires 'Class::MOP';
requires 'CSS::Minifier';
requires 'Clone';
+requires 'Cwd';
requires 'Data::Compare';
requires 'Data::Dumper::Concise';
requires 'Data::OptList';
@@ -47,6 +48,7 @@ requires 'Email::MIME::Creator';
requires 'Email::Valid';
requires 'Encode::Detect' => '1.01';
requires 'Exception::Class' => '1.29';
+requires 'File::Spec';
requires 'Function::Parameters';
requires 'HTML::FormHandler' => '0.36002';
requires 'HTML::Tiny' => '1.05';
diff --git a/lib/DBDefs/Default.pm b/lib/DBDefs/Default.pm
index 72b147d..5645fc6 100644
--- a/lib/DBDefs/Default.pm
+++ b/lib/DBDefs/Default.pm
@@ -27,12 +27,19 @@ use warnings;
package DBDefs::Default;
+use File::Spec::Functions qw( splitdir catdir );
+use Cwd qw( abs_path );
+
################################################################################
# Directories
################################################################################
# The server root, i.e. the parent directory of admin, bin, lib, root, etc.
-sub MB_SERVER_ROOT { "/home/httpd/musicbrainz/musicbrainz-server" }
+sub MB_SERVER_ROOT {
+ my @splitfilename = splitdir(abs_path('./' . __FILE__));
+ my @parentdir = @splitfilename[0..(scalar @splitfilename - 4)];
+ return catdir(@parentdir);
+}
# Where static files are located
sub STATIC_FILES_DIR { my $self = shift; $self->MB_SERVER_ROOT . '/root/static' }
commit a9c45ab3cb9493b76f92ee2927b6adc98d3da857
Author: Ian McEwen <[email protected]>
Date: Mon Aug 20 18:13:56 2012 -0700
Change to have a DBDefs::Default class, and use it... frickin' everywhere
diff --git a/admin/ExportAllTables b/admin/ExportAllTables
index 99960d3..8166fd8 100755
--- a/admin/ExportAllTables
+++ b/admin/ExportAllTables
@@ -518,8 +518,8 @@ my ($iSchemaSequence, $iReplicationSequence, $dtReplicationDate) = do {
};
$iSchemaSequence or die "Don't know what schema sequence number we're using";
-$iSchemaSequence == &DBDefs::DB_SCHEMA_SEQUENCE
- or die "Stored schema sequence ($iSchemaSequence) does not match DBDefs::DB_SCHEMA_SEQUENCE (".&DBDefs::DB_SCHEMA_SEQUENCE.")";
+$iSchemaSequence == DBDefs->DB_SCHEMA_SEQUENCE
+ or die "Stored schema sequence ($iSchemaSequence) does not match DBDefs->DB_SCHEMA_SEQUENCE (".DBDefs->DB_SCHEMA_SEQUENCE.")";
# Write the SCHEMA_SEQUENCE file. Again, this is parseable - it's just an
# integer.
diff --git a/admin/InitDb.pl b/admin/InitDb.pl
index e684cda..76f1a91 100755
--- a/admin/InitDb.pl
+++ b/admin/InitDb.pl
@@ -37,7 +37,7 @@ use MusicBrainz::Server::Replication ':replication_type';
use aliased 'MusicBrainz::Server::DatabaseConnectionFactory' => 'Databases';
-my $REPTYPE = &DBDefs::REPLICATION_TYPE;
+my $REPTYPE = DBDefs->REPLICATION_TYPE;
my $psql = "psql";
my $path_to_pending_so;
@@ -394,7 +394,7 @@ Options are:
-q, --quiet Don't show the output of any SQL scripts
-h --help This help
--with-pending=PATH For use only if this is a master replication server
- (DBDefs::REPLICATION_TYPE==RT_MASTER). PATH specifies
+ (DBDefs->REPLICATION_TYPE==RT_MASTER). PATH specifies
the path to "pending.so" (on the database server).
--fix-broken-utf8 replace invalid UTF-8 byte sequences with the special
Unicode "replacement character" U+FFFD.
diff --git a/admin/MBImport.pl b/admin/MBImport.pl
index 055531a..0293ba9 100755
--- a/admin/MBImport.pl
+++ b/admin/MBImport.pl
@@ -138,7 +138,7 @@ $timestamp =~ s/^This snapshot was taken at //;
print localtime() . " : Snapshot timestamp is $timestamp\n";
# We should also have SCHEMA_SEQUENCE files, which match. Plus they must
-# match DBDefs::DB_SCHEMA_SEQUENCE.
+# match DBDefs->DB_SCHEMA_SEQUENCE.
my $SCHEMA_SEQUENCE = read_all_and_check("SCHEMA_SEQUENCE");
if (not defined $SCHEMA_SEQUENCE)
{
@@ -146,10 +146,10 @@ if (not defined $SCHEMA_SEQUENCE)
print STDERR localtime() . " : Don't be surprised if this import fails\n";
$| = 1, print(chr(7)), sleep 5
if -t STDOUT;
-} elsif ($SCHEMA_SEQUENCE != &DBDefs::DB_SCHEMA_SEQUENCE) {
+} elsif ($SCHEMA_SEQUENCE != DBDefs->DB_SCHEMA_SEQUENCE) {
printf STDERR "%s : Schema sequence mismatch - codebase is %d, snapshot files are %d\n",
scalar localtime,
- &DBDefs::DB_SCHEMA_SEQUENCE,
+ DBDefs->DB_SCHEMA_SEQUENCE,
$SCHEMA_SEQUENCE,
;
exit 1;
@@ -474,7 +474,7 @@ sub ImportAllTables
$file or print("No data file found for '$table', skipping\n"), next;
$imported_tables{$table} = 1;
- if (&DBDefs::REPLICATION_TYPE == RT_SLAVE)
+ if (DBDefs->REPLICATION_TYPE == RT_SLAVE)
{
my $basetable = $table;
$basetable =~ s/_sanitised$//;
@@ -587,11 +587,11 @@ sub validate_tar
my $all = do { local $/; <$fh> };
close $fh;
chomp($all);
- if ($all ne &DBDefs::DB_SCHEMA_SEQUENCE)
+ if ($all ne DBDefs->DB_SCHEMA_SEQUENCE)
{
printf STDERR "%s : Schema sequence mismatch - codebase is %d, $tar is %d\n",
scalar localtime,
- &DBDefs::DB_SCHEMA_SEQUENCE,
+ DBDefs->DB_SCHEMA_SEQUENCE,
$all,
;
exit 1;
diff --git a/admin/SendMailForUnverifiedAccounts b/admin/SendMailForUnverifiedAccounts
index 6cdcff1..083099c 100755
--- a/admin/SendMailForUnverifiedAccounts
+++ b/admin/SendMailForUnverifiedAccounts
@@ -5,12 +5,9 @@ use warnings;
use lib "cgi-bin";
use MusicBrainz;
-use DBDefs;
use UserStuff;
use Sql;
-# sub DBDefs::DEBUG_MAIL_SPOOL { "/tmp/verify" }
-
my $mb = new MusicBrainz;
$mb->Login;
my $sql = new Sql($mb->{dbh});
diff --git a/admin/SubscribeAutomodsToList b/admin/SubscribeAutomodsToList
index 9191823..32ffcb1 100755
--- a/admin/SubscribeAutomodsToList
+++ b/admin/SubscribeAutomodsToList
@@ -55,7 +55,7 @@ my $automods = $c->sql->select_list_of_lists("SELECT name, email FROM editor
WHERE (privs & ?) > 0", $AUTO_EDITOR_FLAG);
{
- my $rsync_script = &DBDefs::MB_SERVER_ROOT . "/bin/rsync-automods-list";
+ my $rsync_script = DBDefs->MB_SERVER_ROOT . "/bin/rsync-automods-list";
last unless -f $rsync_script and -x _;
require POSIX;
pipe(my $r, my $w) or die $!;
diff --git a/admin/UpdateStyleSheetLinks b/admin/UpdateStyleSheetLinks
index f7e6ffd..3316f2d 100755
--- a/admin/UpdateStyleSheetLinks
+++ b/admin/UpdateStyleSheetLinks
@@ -30,7 +30,7 @@ use FindBin;
use lib "$FindBin::Bin/../lib";
use DBDefs;
-chdir &DBDefs::MB_SERVER_ROOT or die $!;
+chdir DBDefs->MB_SERVER_ROOT or die $!;
chdir "root/static" or die $!;
vRefreshImportedStyleSheets("main.css");
diff --git a/admin/cleanup/ArchiveOldModerations b/admin/cleanup/ArchiveOldModerations
index bf26e63..a4c5449 100755
--- a/admin/cleanup/ArchiveOldModerations
+++ b/admin/cleanup/ArchiveOldModerations
@@ -129,7 +129,7 @@ sub nibble
}
print localtime() . " : Saving to $filename\n";
- print $fh "-- schema sequence " . &DBDefs::DB_SCHEMA_SEQUENCE . "\n"
+ print $fh "-- schema sequence " . DBDefs->DB_SCHEMA_SEQUENCE . "\n"
or die $!;
my $done = 0;
diff --git a/admin/replication/LoadReplicationChanges b/admin/replication/LoadReplicationChanges
index 7e17ca5..9808cf4 100755
--- a/admin/replication/LoadReplicationChanges
+++ b/admin/replication/LoadReplicationChanges
@@ -35,7 +35,7 @@ use integer;
use Getopt::Long;
use MusicBrainz::Server::Replication qw( :replication_type NON_REPLICATED_TABLES );
-&DBDefs::REPLICATION_TYPE == RT_SLAVE
+DBDefs->REPLICATION_TYPE == RT_SLAVE
or die "This is not a slave server!\n";
my $fHelp;
@@ -114,11 +114,11 @@ my ($iSchemaSequence, $iReplicationSequence, $dtReplicationDate) = do {
)};
};
-unless ($iSchemaSequence == &DBDefs::DB_SCHEMA_SEQUENCE)
+unless ($iSchemaSequence == DBDefs->DB_SCHEMA_SEQUENCE)
{
printf STDERR "%s : Schema sequence mismatch - codebase is %d, database is %d\n",
scalar localtime,
- &DBDefs::DB_SCHEMA_SEQUENCE,
+ DBDefs->DB_SCHEMA_SEQUENCE,
$iSchemaSequence,
;
exit 1;
diff --git a/app.psgi b/app.psgi
index c98bd3c..8a36082 100644
--- a/app.psgi
+++ b/app.psgi
@@ -12,7 +12,7 @@ use Plack::Middleware::Debug::TemplateToolkit;
# Has to come before requiring MusicBrainz::Server
BEGIN {
use Template;
- if (DBDefs::CATALYST_DEBUG) {
+ if (DBDefs->CATALYST_DEBUG) {
$Template::Config::CONTEXT = 'My::Template::Context';
$INC{'My/Template/Context.pm'} = 1;
}
@@ -20,10 +20,10 @@ BEGIN {
use MusicBrainz::Server;
-debug_method_calls() if DBDefs::CATALYST_DEBUG;
+debug_method_calls() if DBDefs->CATALYST_DEBUG;
builder {
- if (DBDefs::CATALYST_DEBUG) {
+ if (DBDefs->CATALYST_DEBUG) {
enable 'Debug', panels => [ qw( Memory Session Timer DAOLogger ExclusiveTime TemplateToolkit Parameters ) ];
}
if ($ENV{'MUSICBRAINZ_USE_PROXY'}) {
diff --git a/bin/check_last_replication_date b/bin/check_last_replication_date
index d95177b..72b95d3 100755
--- a/bin/check_last_replication_date
+++ b/bin/check_last_replication_date
@@ -53,7 +53,7 @@ GetOptions(
@ARGV == 0 or die "Usage: $0 [-w SECONDS] [-c SECONDS]\n";
use MusicBrainz::Server::Replication ':replication_type';
-if (&DBDefs::REPLICATION_TYPE != RT_SLAVE)
+if (DBDefs->REPLICATION_TYPE != RT_SLAVE)
{
print "This is not a slave database!\n";
exit 2;
diff --git a/lib/DBDefs/Default.pm b/lib/DBDefs/Default.pm
index 3caddf1..72b147d 100644
--- a/lib/DBDefs/Default.pm
+++ b/lib/DBDefs/Default.pm
@@ -34,46 +34,12 @@ package DBDefs::Default;
# The server root, i.e. the parent directory of admin, bin, lib, root, etc.
sub MB_SERVER_ROOT { "/home/httpd/musicbrainz/musicbrainz-server" }
# Where static files are located
-sub STATIC_FILES_DIR { MB_SERVER_ROOT . '/root/static' }
+sub STATIC_FILES_DIR { my $self = shift; $self->MB_SERVER_ROOT . '/root/static' }
################################################################################
# The Database
################################################################################
-use MusicBrainz::Server::DatabaseConnectionFactory;
-MusicBrainz::Server::DatabaseConnectionFactory->register_databases(
- # How to connect when we need read-write access to the database
- READWRITE => {
- database => "musicbrainz_db",
- schema => "musicbrainz",
- username => "musicbrainz",
- password => "musicbrainz",
-# host => "",
-# port => "",
- },
- # How to connect to a test database
- TEST => {
- database => "musicbrainz_test",
- schema => "musicbrainz",
- username => "musicbrainz",
- password => "musicbrainz",
-# host => "",
-# port => "",
- },
- # How to connect for read-only access. See "REPLICATION_TYPE" (below)
- # READONLY => undef,
- # How to connect for administrative access
- SYSTEM => {
- database => "template1",
- username => "postgres",
-# password => "",
-# host => "",
-# port => "",
- },
- # Fill out only if RAWDATA lives on a different host from the READWRITE server.
- # RAWDATA_SYSTEM => undef,
-);
-
# The schema sequence number. Must match the value in
# replication_control.current_schema_sequence.
sub DB_SCHEMA_SEQUENCE { 15 }
@@ -99,7 +65,7 @@ sub REPLICATION_TYPE { RT_STANDALONE }
# To use a port number other than 80, add it like so: "myhost:8000"
sub WEB_SERVER { "www.musicbrainz.example.com" }
sub LUCENE_SERVER { "search.musicbrainz.org" }
-sub WEB_SERVER_USED_IN_EMAIL { WEB_SERVER }
+sub WEB_SERVER_USED_IN_EMAIL { my $self = shift; $self->WEB_SERVER }
################################################################################
# Mail Settings
@@ -137,7 +103,7 @@ sub DB_STAGING_SERVER_SANITIZED { 1 }
# Testing features enable "Accept edit" and "Reject edit" links on edits,
# this should only be enabled on staging servers. Also, this enables non-admin
# users to edit user permissions.
-sub DB_STAGING_TESTING_FEATURES { DB_STAGING_SERVER }
+sub DB_STAGING_TESTING_FEATURES { my $self = shift; $self->DB_STAGING_SERVER }
################################################################################
# Documentation Server Settings
@@ -149,7 +115,7 @@ sub WIKITRANS_SERVER { "wiki.musicbrainz.org" }
# transclusion table.
sub WIKITRANS_SERVER_API { "wiki.musicbrainz.org/-/api.php" }
-sub WIKITRANS_INDEX_FILE { MB_SERVER_ROOT() . "/root/static/wikidocs/index.txt" }
+sub WIKITRANS_INDEX_FILE { my $self = shift; $self->MB_SERVER_ROOT . "/root/static/wikidocs/index.txt" }
sub WIKITRANS_INDEX_URL { "http://musicbrainz.org/static/wikidocs/index.txt" }
# To enable documentation search on your server, create your own Google Custom
@@ -181,11 +147,12 @@ sub MEMCACHED_NAMESPACE { return 'MB:'; };
# the same as the settings you use for the session store.
#
sub PLUGIN_CACHE_OPTIONS {
+ my $self = shift;
return {
# class => "Cache::Memory",
class => "Cache::Memcached::Fast",
- servers => MEMCACHED_SERVERS(),
- namespace => MEMCACHED_NAMESPACE(),
+ servers => $self->MEMCACHED_SERVERS(),
+ namespace => $self->MEMCACHED_NAMESPACE(),
};
};
@@ -246,7 +213,7 @@ sub RATELIMIT_SERVER { undef }
# The following two values determine how scripts and styles are minified. By
# default, a dummy minifier is used:
-sub MINIFY_DUMMY { my %args = @_; return $args{input}; }
+sub MINIFY_DUMMY { shift; my %args = @_; return $args{input}; }
sub MINIFY_SCRIPTS { return \&MINIFY_DUMMY; }
sub MINIFY_STYLES { return \&MINIFY_DUMMY; }
@@ -277,7 +244,8 @@ EOF
# about the last commit
sub GIT_BRANCH
{
- if (DB_STAGING_SERVER) {
+ my $self = shift;
+ if ($self->DB_STAGING_SERVER) {
my $branch = `git branch --no-color 2> /dev/null | sed -e '/^[^*]/d'`;
$branch =~ s/\* (.+)/$1/;
my $sha = `git log -1 --format=format:"%h"`;
@@ -310,6 +278,7 @@ my %amazon_store_associate_ids = (
sub AWS_ASSOCIATE_ID
{
+ shift;
return keys %amazon_store_associate_ids if not @_;
return $amazon_store_associate_ids{$_[0]};
}
@@ -328,7 +297,7 @@ sub RECAPTCHA_PRIVATE_KEY { return undef }
# internet archive private/public keys (for coverartarchive.org).
sub COVER_ART_ARCHIVE_ID { };
sub COVER_ART_ARCHIVE_KEY { };
-sub COVER_ART_ARCHIVE_UPLOAD_PREFIXER { sprintf("http://%s.s3.us.archive.org/", shift) };
+sub COVER_ART_ARCHIVE_UPLOAD_PREFIXER { shift; sprintf("http://%s.s3.us.archive.org/", shift) };
sub COVER_ART_ARCHIVE_DOWNLOAD_PREFIX { "http://coverartarchive.org" };
# Add a Google Analytics tracking code to enable Google Analytics tracking.
@@ -347,10 +316,11 @@ sub GOOGLE_ANALYTICS_CODE { '' }
sub SESSION_STORE { "Session::Store::Memcached" }
sub SESSION_STORE_ARGS
{
+ my $self = shift;
return {
memcached_new_args => {
- data => MEMCACHED_SERVERS(),
- namespace => MEMCACHED_NAMESPACE(),
+ data => $self->MEMCACHED_SERVERS(),
+ namespace => $self->MEMCACHED_NAMESPACE(),
memcached_class => 'Cache::Memcached::Fast',
}
}
@@ -360,7 +330,8 @@ sub SESSION_STORE_ARGS
# seperately from the regular session store.
sub WIZARD_MEMCACHED
{
- return { servers => MEMCACHED_SERVERS(), namespace => MEMCACHED_NAMESPACE() };
+ my $self = shift;
+ return { servers => $self->MEMCACHED_SERVERS(), namespace => $self->MEMCACHED_NAMESPACE() };
}
sub USE_ETAGS { 1 }
diff --git a/lib/MusicBrainz/Script/RebuildCoverArt.pm b/lib/MusicBrainz/Script/RebuildCoverArt.pm
index eb98580..046b276 100644
--- a/lib/MusicBrainz/Script/RebuildCoverArt.pm
+++ b/lib/MusicBrainz/Script/RebuildCoverArt.pm
@@ -43,7 +43,7 @@ sub run
printf STDERR "You do not have both AWS_PUBLIC and AWS_PRIVATE defined in DBDefs.\n" .
"You will not be able to find artwork from Amazon until these are set."
- unless (DBDefs::AWS_PUBLIC && DBDefs::AWS_PRIVATE);
+ unless (DBDefs->AWS_PUBLIC && DBDefs->AWS_PRIVATE);
$self->ensure_release_cover_art;
diff --git a/lib/MusicBrainz/Server.pm b/lib/MusicBrainz/Server.pm
index ea6bda7..58833f3 100644
--- a/lib/MusicBrainz/Server.pm
+++ b/lib/MusicBrainz/Server.pm
@@ -83,14 +83,14 @@ if ($ENV{'MUSICBRAINZ_USE_PROXY'})
__PACKAGE__->config( using_frontend_proxy => 1 );
}
-if (DBDefs::EMAIL_BUGS) {
+if (DBDefs->EMAIL_BUGS) {
__PACKAGE__->config->{'Plugin::ErrorCatcher'} = {
emit_module => 'Catalyst::Plugin::ErrorCatcher::Email'
};
__PACKAGE__->config->{'Plugin::ErrorCatcher::Email'} = {
- to => DBDefs::EMAIL_BUGS(),
- from => 'bug-reporter@' . DBDefs::WEB_SERVER(),
+ to => DBDefs->EMAIL_BUGS(),
+ from => 'bug-reporter@' . DBDefs->WEB_SERVER(),
use_tags => 1,
subject => 'Unhandled error in %f (line %l)'
};
@@ -98,7 +98,7 @@ if (DBDefs::EMAIL_BUGS) {
push @args, "ErrorCatcher";
}
-__PACKAGE__->config->{'Plugin::Cache'}{backend} = &DBDefs::PLUGIN_CACHE_OPTIONS;
+__PACKAGE__->config->{'Plugin::Cache'}{backend} = DBDefs->PLUGIN_CACHE_OPTIONS;
__PACKAGE__->config->{'Plugin::Authentication'} = {
default_realm => 'moderators',
@@ -148,7 +148,7 @@ __PACKAGE__->config->{form} = {
form_name_space => 'MusicBrainz::Server::Forms',
};
-if (&DBDefs::_RUNNING_TESTS) {
+if (DBDefs->_RUNNING_TESTS) {
push @args, "Session::Store::Dummy";
# /static is usually taken care of by Plack or nginx, but not when running
@@ -164,29 +164,29 @@ if (&DBDefs::_RUNNING_TESTS) {
}
}
else {
- push @args, &DBDefs::SESSION_STORE;
- __PACKAGE__->config->{'Plugin::Session'} = &DBDefs::SESSION_STORE_ARGS;
+ push @args, DBDefs->SESSION_STORE;
+ __PACKAGE__->config->{'Plugin::Session'} = DBDefs->SESSION_STORE_ARGS;
}
-if (&DBDefs::CATALYST_DEBUG) {
+if (DBDefs->CATALYST_DEBUG) {
push @args, "-Debug";
}
-if (&DBDefs::SESSION_COOKIE) {
- __PACKAGE__->config->{session}{cookie_name} = &DBDefs::SESSION_COOKIE;
+if (DBDefs->SESSION_COOKIE) {
+ __PACKAGE__->config->{session}{cookie_name} = DBDefs->SESSION_COOKIE;
}
-if (&DBDefs::SESSION_DOMAIN) {
- __PACKAGE__->config->{session}{cookie_domain} = &DBDefs::SESSION_DOMAIN;
+if (DBDefs->SESSION_DOMAIN) {
+ __PACKAGE__->config->{session}{cookie_domain} = DBDefs->SESSION_DOMAIN;
}
-__PACKAGE__->config->{session}{cookie_expires} = &DBDefs::WEB_SESSION_SECONDS_TO_LIVE;
+__PACKAGE__->config->{session}{cookie_expires} = DBDefs->WEB_SESSION_SECONDS_TO_LIVE;
-if (&DBDefs::USE_ETAGS) {
+if (DBDefs->USE_ETAGS) {
push @args, "Cache::HTTP";
}
-if (my $config = DBDefs::AUTO_RESTART) {
+if (my $config = DBDefs->AUTO_RESTART) {
__PACKAGE__->config->{'Plugin::AutoRestart'} = $config;
push @args, 'AutoRestart';
}
@@ -268,7 +268,7 @@ around 'dispatch' => sub {
current_language_html => $html_lang
);
- if(my $max_request_time = DBDefs::MAX_REQUEST_TIME) {
+ if(my $max_request_time = DBDefs->MAX_REQUEST_TIME) {
alarm($max_request_time);
POSIX::sigaction(
SIGALRM, POSIX::SigAction->new(sub {
diff --git a/lib/MusicBrainz/Server/Connector.pm b/lib/MusicBrainz/Server/Connector.pm
index 692afb2..3d4b0cf 100644
--- a/lib/MusicBrainz/Server/Connector.pm
+++ b/lib/MusicBrainz/Server/Connector.pm
@@ -52,9 +52,9 @@ sub _build_conn
$dbh->do("SET CLIENT_ENCODING = 'UNICODE'");
$dbh->do("SET statement_timeout = " .
- (DBDefs::MAX_REQUEST_TIME() * 1000))
- if (defined(DBDefs::MAX_REQUEST_TIME)
- && DBDefs::MAX_REQUEST_TIME > 0);
+ (DBDefs->MAX_REQUEST_TIME() * 1000))
+ if (defined(DBDefs->MAX_REQUEST_TIME)
+ && DBDefs->MAX_REQUEST_TIME > 0);
if ($schema) {
$dbh->do("SET search_path=$schema,public");
diff --git a/lib/MusicBrainz/Server/Context.pm b/lib/MusicBrainz/Server/Context.pm
index b310907..3cd5f46 100644
--- a/lib/MusicBrainz/Server/Context.pm
+++ b/lib/MusicBrainz/Server/Context.pm
@@ -22,7 +22,7 @@ has 'connector' => (
has 'database' => (
is => 'ro',
isa => 'Str',
- default => sub { &DBDefs::REPLICATION_TYPE == RT_SLAVE ? 'READONLY' : 'READWRITE' }
+ default => sub { DBDefs->REPLICATION_TYPE == RT_SLAVE ? 'READONLY' : 'READWRITE' }
);
sub _build_connector {
@@ -62,7 +62,7 @@ sub model
sub create_script_context
{
my ($class, %args) = @_;
- my $cache_manager = MusicBrainz::Server::CacheManager->new(&DBDefs::CACHE_MANAGER_OPTIONS);
+ my $cache_manager = MusicBrainz::Server::CacheManager->new(DBDefs->CACHE_MANAGER_OPTIONS);
return MusicBrainz::Server::Context->new(cache_manager => $cache_manager, %args);
}
diff --git a/lib/MusicBrainz/Server/Controller/Account.pm b/lib/MusicBrainz/Server/Controller/Account.pm
index ce6d2df..515b93a 100644
--- a/lib/MusicBrainz/Server/Controller/Account.pm
+++ b/lib/MusicBrainz/Server/Controller/Account.pm
@@ -78,7 +78,7 @@ sub verify_email : Path('/verify-email') ForbiddenOnSlaves
$c->detach;
}
- if (($time + &DBDefs::EMAIL_VERIFICATION_TIMEOUT) < time()) {
+ if (($time + DBDefs->EMAIL_VERIFICATION_TIMEOUT) < time()) {
$c->stash(
message => l('Sorry, this email verification link has expired.'),
template => 'account/verify_email_error.tt',
@@ -110,7 +110,7 @@ sub verify_email : Path('/verify-email') ForbiddenOnSlaves
sub _reset_password_checksum
{
my ($self, $id, $time) = @_;
- return sha1_base64("reset_password $id $time " . DBDefs::SMTP_SECRET_CHECKSUM);
+ return sha1_base64("reset_password $id $time " . DBDefs->SMTP_SECRET_CHECKSUM);
}
sub _send_password_reset_email
@@ -194,7 +194,7 @@ sub reset_password : Path('/reset-password') ForbiddenOnSlaves
$c->detach;
}
- if ($time + &DBDefs::EMAIL_VERIFICATION_TIMEOUT < time()) {
+ if ($time + DBDefs->EMAIL_VERIFICATION_TIMEOUT < time()) {
$c->stash(
message => l('Sorry, this password reset link has expired.'),
template => 'account/reset_password_error.tt',
@@ -402,8 +402,8 @@ sub register : Path('/register') ForbiddenOnSlaves
my $captcha = Captcha::reCAPTCHA->new;
my $captcha_result;
my $use_captcha = ($c->req->address &&
- defined DBDefs::RECAPTCHA_PUBLIC_KEY &&
- defined DBDefs::RECAPTCHA_PRIVATE_KEY);
+ defined DBDefs->RECAPTCHA_PUBLIC_KEY &&
+ defined DBDefs->RECAPTCHA_PRIVATE_KEY);
if ($c->form_posted && $form->submitted_and_valid($c->req->params)) {
@@ -414,7 +414,7 @@ sub register : Path('/register') ForbiddenOnSlaves
my $response = $c->req->params->{recaptcha_response_field};
$captcha_result = $captcha->check_answer (
- &DBDefs::RECAPTCHA_PRIVATE_KEY,
+ DBDefs->RECAPTCHA_PRIVATE_KEY,
$c->req->address, $challenge, $response);
$valid = $captcha_result->{is_valid};
@@ -454,7 +454,7 @@ sub register : Path('/register') ForbiddenOnSlaves
my $captcha_html = "";
$captcha_html = $captcha->get_html (
- &DBDefs::RECAPTCHA_PUBLIC_KEY, $captcha_result) if $use_captcha;
+ DBDefs->RECAPTCHA_PUBLIC_KEY, $captcha_result) if $use_captcha;
$c->stash(
use_captcha => $use_captcha,
@@ -520,7 +520,7 @@ sub _send_confirmation_email
sub _checksum
{
my ($self, $email, $uid, $time) = @_;
- return sha1_base64("$email $uid $time " . DBDefs::SMTP_SECRET_CHECKSUM);
+ return sha1_base64("$email $uid $time " . DBDefs->SMTP_SECRET_CHECKSUM);
}
sub donation : Local RequireAuth HiddenOnSlaves
diff --git a/lib/MusicBrainz/Server/Controller/Admin.pm b/lib/MusicBrainz/Server/Controller/Admin.pm
index 95bebe2..9628f01 100644
--- a/lib/MusicBrainz/Server/Controller/Admin.pm
+++ b/lib/MusicBrainz/Server/Controller/Admin.pm
@@ -16,7 +16,7 @@ sub edit_user : Path('/admin/user/edit') Args(1) RequireAuth HiddenOnSlaves
my ($self, $c, $user_name) = @_;
$c->detach('/error_403')
- unless $c->user->is_admin or DBDefs::DB_STAGING_TESTING_FEATURES;
+ unless $c->user->is_admin or DBDefs->DB_STAGING_TESTING_FEATURES;
my $user = $c->model('Editor')->get_by_name($user_name);
my $form = $c->form(
diff --git a/lib/MusicBrainz/Server/Controller/Doc.pm b/lib/MusicBrainz/Server/Controller/Doc.pm
index 1d355d6..b9aeff2 100644
--- a/lib/MusicBrainz/Server/Controller/Doc.pm
+++ b/lib/MusicBrainz/Server/Controller/Doc.pm
@@ -28,11 +28,11 @@ sub show : Path('')
$c->stash(
id => $id,
page => $page,
- google_custom_search => &DBDefs::GOOGLE_CUSTOM_SEARCH,
+ google_custom_search => DBDefs->GOOGLE_CUSTOM_SEARCH,
);
if ($id =~ /^(Special|User|MetaBrainz|Proposal):/i) {
- $c->response->redirect(sprintf('http://%s/%s', DBDefs::WIKITRANS_SERVER, $id));
+ $c->response->redirect(sprintf('http://%s/%s', DBDefs->WIKITRANS_SERVER, $id));
$c->detach;
}
diff --git a/lib/MusicBrainz/Server/Controller/Partners.pm b/lib/MusicBrainz/Server/Controller/Partners.pm
index 05c52ba..21ca6fb 100644
--- a/lib/MusicBrainz/Server/Controller/Partners.pm
+++ b/lib/MusicBrainz/Server/Controller/Partners.pm
@@ -6,7 +6,7 @@ sub amazon : Local Args(2)
{
my ($self, $c, $store, $asin) = @_;
- my $ass_id = &DBDefs::AWS_ASSOCIATE_ID($store)
+ my $ass_id = DBDefs->AWS_ASSOCIATE_ID($store)
or die "Invalid store";
$c->response->redirect(
diff --git a/lib/MusicBrainz/Server/Controller/Release.pm b/lib/MusicBrainz/Server/Controller/Release.pm
index f0004de..49b4597 100644
--- a/lib/MusicBrainz/Server/Controller/Release.pm
+++ b/lib/MusicBrainz/Server/Controller/Release.pm
@@ -73,7 +73,7 @@ after 'load' => sub
}
# FIXME: replace this with a proper Net::CoverArtArchive::CoverArt::Front object.
- my $prefix = DBDefs::COVER_ART_ARCHIVE_DOWNLOAD_PREFIX . "/release/" . $release->gid;
+ my $prefix = DBDefs->COVER_ART_ARCHIVE_DOWNLOAD_PREFIX . "/release/" . $release->gid;
$c->stash->{release_artwork} = {
image => $prefix.'/front',
large_thumbnail => $prefix.'/front-500',
@@ -405,7 +405,7 @@ sub cover_art_uploader : Chained('load') PathPart('cover-art-uploader') RequireA
[ $entity->gid ],
{ id => $id })->as_string ();
- $c->stash->{form_action} = DBDefs::COVER_ART_ARCHIVE_UPLOAD_PREFIXER($bucket);
+ $c->stash->{form_action} = DBDefs->COVER_ART_ARCHIVE_UPLOAD_PREFIXER($bucket);
$c->stash->{s3fields} = $c->model ('CoverArtArchive')->post_fields ($bucket, $entity->gid, $id, $redirect);
}
@@ -431,7 +431,7 @@ sub add_cover_art : Chained('load') PathPart('add-cover-art') RequireAuth
my $id = $c->model('CoverArtArchive')->fresh_id;
$c->stash({
id => $id,
- index_url => DBDefs::COVER_ART_ARCHIVE_DOWNLOAD_PREFIX . "/release/" . $entity->gid . "/",
+ index_url => DBDefs->COVER_ART_ARCHIVE_DOWNLOAD_PREFIX . "/release/" . $entity->gid . "/",
images => \@artwork
});
@@ -659,7 +659,7 @@ sub edit_cover_art : Chained('load') PathPart('edit-cover-art') Args(1) Edit Req
$c->stash({
artwork => $artwork,
images => \@artwork,
- index_url => DBDefs::COVER_ART_ARCHIVE_DOWNLOAD_PREFIX . "/release/" . $entity->gid . "/"
+ index_url => DBDefs->COVER_ART_ARCHIVE_DOWNLOAD_PREFIX . "/release/" . $entity->gid . "/"
});
my @type_ids = map { $_->id } $c->model ('CoverArtType')->get_by_name (@{ $artwork->types });
diff --git a/lib/MusicBrainz/Server/Controller/Root.pm b/lib/MusicBrainz/Server/Controller/Root.pm
index fde3a2b..eb29664 100644
--- a/lib/MusicBrainz/Server/Controller/Root.pm
+++ b/lib/MusicBrainz/Server/Controller/Root.pm
@@ -18,7 +18,7 @@ use aliased 'MusicBrainz::Server::Translation';
__PACKAGE__->config->{namespace} = '';
with 'MusicBrainz::Server::Controller::Role::Profile' => {
- threshold => DBDefs::PROFILE_SITE()
+ threshold => DBDefs->PROFILE_SITE()
};
=head1 NAME
@@ -155,7 +155,7 @@ sub begin : Private
return if exists $c->action->attributes->{Minimal};
- $c->stats->enable(1) if DBDefs::DEVELOPMENT_SERVER;
+ $c->stats->enable(1) if DBDefs->DEVELOPMENT_SERVER;
# if no javascript cookie is set we don't know if javascript is enabled or not.
my $jscookie = $c->request->cookie('javascript');
@@ -165,13 +165,13 @@ sub begin : Private
$c->stash(
javascript => $js,
no_javascript => $js eq "false",
- wiki_server => &DBDefs::WIKITRANS_SERVER,
+ wiki_server => DBDefs->WIKITRANS_SERVER,
server_languages => Translation->instance->all_languages(),
server_details => {
- staging_server => &DBDefs::DB_STAGING_SERVER,
- testing_features => &DBDefs::DB_STAGING_TESTING_FEATURES,
- is_slave_db => &DBDefs::REPLICATION_TYPE == RT_SLAVE,
- read_only => &DBDefs::DB_READ_ONLY
+ staging_server => DBDefs->DB_STAGING_SERVER,
+ testing_features => DBDefs->DB_STAGING_TESTING_FEATURES,
+ is_slave_db => DBDefs->REPLICATION_TYPE == RT_SLAVE,
+ read_only => DBDefs->DB_READ_ONLY
},
);
@@ -214,7 +214,7 @@ sub begin : Private
$c->forward('/error_401');
}
- if (DBDefs::DB_READ_ONLY && (exists $c->action->attributes->{Edit} ||
+ if (DBDefs->DB_READ_ONLY && (exists $c->action->attributes->{Edit} ||
exists $c->action->attributes->{DenyWhenReadonly})) {
$c->stash( message => 'The server is currently in read only mode and is not accepting edits');
$c->forward('/error_400');
@@ -279,22 +279,22 @@ sub end : ActionClass('RenderView')
return if exists $c->action->attributes->{Minimal};
$c->stash->{server_details} = {
- staging_server => &DBDefs::DB_STAGING_SERVER,
- staging_server_description => &DBDefs::DB_STAGING_SERVER_DESCRIPTION,
- testing_features => &DBDefs::DB_STAGING_TESTING_FEATURES,
- is_slave_db => &DBDefs::REPLICATION_TYPE == RT_SLAVE,
- is_sanitized => &DBDefs::DB_STAGING_SERVER_SANITIZED,
- developement_server => &DBDefs::DEVELOPMENT_SERVER
+ staging_server => DBDefs->DB_STAGING_SERVER,
+ staging_server_description => DBDefs->DB_STAGING_SERVER_DESCRIPTION,
+ testing_features => DBDefs->DB_STAGING_TESTING_FEATURES,
+ is_slave_db => DBDefs->REPLICATION_TYPE == RT_SLAVE,
+ is_sanitized => DBDefs->DB_STAGING_SERVER_SANITIZED,
+ developement_server => DBDefs->DEVELOPMENT_SERVER
};
# For displaying which git branch is active as well as last commit information
# (only shown on staging servers)
- my ($git_branch, $git_sha, $git_msg) = &DBDefs::GIT_BRANCH;
+ my ($git_branch, $git_sha, $git_msg) = DBDefs->GIT_BRANCH;
$c->stash->{server_details}->{git}->{branch} = $git_branch;
$c->stash->{server_details}->{git}->{sha} = $git_sha;
$c->stash->{server_details}->{git}->{msg} = $git_msg;
- $c->stash->{google_analytics_code} = &DBDefs::GOOGLE_ANALYTICS_CODE;
+ $c->stash->{google_analytics_code} = DBDefs->GOOGLE_ANALYTICS_CODE;
# For displaying release attributes
$c->stash->{release_attribute} = \&MusicBrainz::Server::Release::attribute_name;
@@ -316,7 +316,7 @@ sub end : ActionClass('RenderView')
$c->stash->{various_artist_mbid} = ModDefs::VARTIST_MBID;
- $c->stash->{wiki_server} = &DBDefs::WIKITRANS_SERVER;
+ $c->stash->{wiki_server} = DBDefs->WIKITRANS_SERVER;
}
sub chrome_frame : Local
diff --git a/lib/MusicBrainz/Server/Controller/Search.pm b/lib/MusicBrainz/Server/Controller/Search.pm
index ff1c973..e87d9f3 100644
--- a/lib/MusicBrainz/Server/Controller/Search.pm
+++ b/lib/MusicBrainz/Server/Controller/Search.pm
@@ -69,7 +69,7 @@ sub doc : Private
my ($self, $c) = @_;
$c->stash(
- google_custom_search => &DBDefs::GOOGLE_CUSTOM_SEARCH,
+ google_custom_search => DBDefs->GOOGLE_CUSTOM_SEARCH,
template => 'search/results-doc.tt'
);
}
diff --git a/lib/MusicBrainz/Server/Controller/Test.pm b/lib/MusicBrainz/Server/Controller/Test.pm
index a3be5a0..3b08d09 100644
--- a/lib/MusicBrainz/Server/Controller/Test.pm
+++ b/lib/MusicBrainz/Server/Controller/Test.pm
@@ -8,7 +8,7 @@ use DBDefs;
sub auto : Private
{
my ($self, $c) = @_;
- unless (DBDefs::DB_STAGING_TESTING_FEATURES) {
+ unless (DBDefs->DB_STAGING_TESTING_FEATURES) {
$c->forward('/error_404');
return 0;
}
diff --git a/lib/MusicBrainz/Server/Controller/User.pm b/lib/MusicBrainz/Server/Controller/User.pm
index bd6ec4d..7e58f46 100644
--- a/lib/MusicBrainz/Server/Controller/User.pm
+++ b/lib/MusicBrainz/Server/Controller/User.pm
@@ -151,7 +151,7 @@ sub cookie_login : Private
my $user = $c->model('Editor')->get_by_name($user_name) or last;
- my $correct_pass_sha1 = sha1_base64($user->password . "\t" . DBDefs::SMTP_SECRET_CHECKSUM);
+ my $correct_pass_sha1 = sha1_base64($user->password . "\t" . DBDefs->SMTP_SECRET_CHECKSUM);
die "Password sha1 do not match"
unless $pass_sha1 eq $correct_pass_sha1;
@@ -183,7 +183,7 @@ sub _cookie_sha {
my ($user_name, $password_sha1, $expiry_time, $ip_mask) = @_;
return sha1_base64(
encode('utf-8', "2\t$user_name\t$password_sha1\t$expiry_time\t$ip_mask") .
- DBDefs::SMTP_SECRET_CHECKSUM
+ DBDefs->SMTP_SECRET_CHECKSUM
);
}
@@ -191,7 +191,7 @@ sub _set_login_cookie
{
my ($self, $c) = @_;
my $expiry_time = time + 86400 * 635;
- my $password_sha1 = sha1_base64($c->user->password . "\t" . DBDefs::SMTP_SECRET_CHECKSUM);
+ my $password_sha1 = sha1_base64($c->user->password . "\t" . DBDefs->SMTP_SECRET_CHECKSUM);
my $ip_mask = '';
my $value = sprintf("2\t%s\t%s\t%s\t%s", $c->user->name, $password_sha1,
$expiry_time, $ip_mask);
diff --git a/lib/MusicBrainz/Server/Controller/WS/1/Track.pm b/lib/MusicBrainz/Server/Controller/WS/1/Track.pm
index f785870..c3f0cf9 100644
--- a/lib/MusicBrainz/Server/Controller/WS/1/Track.pm
+++ b/lib/MusicBrainz/Server/Controller/WS/1/Track.pm
@@ -109,7 +109,7 @@ sub submit : Private
$c->detach('bad_req');
}
- if (DBDefs::REPLICATION_TYPE == DBDefs::RT_SLAVE) {
+ if (DBDefs->REPLICATION_TYPE == DBDefs->RT_SLAVE) {
$c->stash->{error} = 'Cannot submit PUIDs or ISRCs to a slave server.';
$c->detach('bad_req');
}
diff --git a/lib/MusicBrainz/Server/Controller/WS/js/WikiDocVersion.pm b/lib/MusicBrainz/Server/Controller/WS/js/WikiDocVersion.pm
index 2f555dc..c07d37e 100644
--- a/lib/MusicBrainz/Server/Controller/WS/js/WikiDocVersion.pm
+++ b/lib/MusicBrainz/Server/Controller/WS/js/WikiDocVersion.pm
@@ -30,7 +30,7 @@ sub version : Chained('root') PathPart('wikidocversion') {
my $output = $c->model('WikiDoc')->get_version ($title);
- $output->{server} = &DBDefs::WIKITRANS_SERVER;
+ $output->{server} = DBDefs->WIKITRANS_SERVER;
$c->res->content_type($c->stash->{serializer}->mime_type . '; charset=utf-8');
$c->res->body($c->stash->{serializer}->serialize('generic', $output));
diff --git a/lib/MusicBrainz/Server/ControllerBase/WS/1.pm b/lib/MusicBrainz/Server/ControllerBase/WS/1.pm
index 735291f..6b06f07 100644
--- a/lib/MusicBrainz/Server/ControllerBase/WS/1.pm
+++ b/lib/MusicBrainz/Server/ControllerBase/WS/1.pm
@@ -13,7 +13,7 @@ use Scalar::Util qw( looks_like_number );
use Try::Tiny;
with 'MusicBrainz::Server::Controller::Role::Profile' => {
- threshold => DBDefs::PROFILE_WEB_SERVICE()
+ threshold => DBDefs->PROFILE_WEB_SERVICE()
};
with 'MusicBrainz::Server::Controller::Role::CORS';
@@ -166,7 +166,7 @@ sub bad_req : Private
sub deny_readonly : Private
{
my ($self, $c) = @_;
- if(DBDefs::DB_READ_ONLY) {
+ if(DBDefs->DB_READ_ONLY) {
$c->res->status(HTTP_SERVICE_UNAVAILABLE);
$c->res->content_type("text/plain; charset=utf-8");
$c->res->body($c->stash->{serializer}->output_error("The database is currently in readonly mode and cannot handle your request"));
diff --git a/lib/MusicBrainz/Server/ControllerBase/WS/2.pm b/lib/MusicBrainz/Server/ControllerBase/WS/2.pm
index 7622b4e..bd2ce64 100644
--- a/lib/MusicBrainz/Server/ControllerBase/WS/2.pm
+++ b/lib/MusicBrainz/Server/ControllerBase/WS/2.pm
@@ -21,7 +21,7 @@ with 'MusicBrainz::Server::WebService::Format' =>
};
with 'MusicBrainz::Server::Controller::Role::Profile' => {
- threshold => DBDefs::PROFILE_WEB_SERVICE()
+ threshold => DBDefs->PROFILE_WEB_SERVICE()
};
with 'MusicBrainz::Server::Controller::Role::CORS';
@@ -101,7 +101,7 @@ sub bad_req : Private
sub deny_readonly : Private
{
my ($self, $c) = @_;
- if (DBDefs::DB_READ_ONLY) {
+ if (DBDefs->DB_READ_ONLY) {
$c->res->status(503);
$c->res->content_type("application/xml; charset=UTF-8");
$c->res->body($c->stash->{serializer}->output_error("The database is currently in readonly mode and cannot handle your request"));
diff --git a/lib/MusicBrainz/Server/CoverArt/Provider/WebService/Amazon.pm b/lib/MusicBrainz/Server/CoverArt/Provider/WebService/Amazon.pm
index 5ca1dcb..d58050c 100644
--- a/lib/MusicBrainz/Server/CoverArt/Provider/WebService/Amazon.pm
+++ b/lib/MusicBrainz/Server/CoverArt/Provider/WebService/Amazon.pm
@@ -49,8 +49,8 @@ my $last_request_time;
sub _build__aws_signature
{
- my $public = DBDefs::AWS_PUBLIC();
- my $private = DBDefs::AWS_PRIVATE();
+ my $public = DBDefs->AWS_PUBLIC();
+ my $private = DBDefs->AWS_PRIVATE();
return Net::Amazon::AWSSign->new($public, $private);
}
@@ -58,8 +58,8 @@ sub handles
{
# Handle any thing that is an Amazon ASIN url relationship (but only if
# the server config has AWS keys)
- my $public = DBDefs::AWS_PUBLIC();
- my $private = DBDefs::AWS_PRIVATE();
+ my $public = DBDefs->AWS_PUBLIC();
+ my $private = DBDefs->AWS_PRIVATE();
return $public && $private;
}
@@ -110,7 +110,7 @@ sub search_by_barcode
sub _lookup_coverart {
my ($self, $url) = @_;
- $url .= "&AssociateTag=" . DBDefs::AMAZON_ASSOCIATE_TAG;
+ $url .= "&AssociateTag=" . DBDefs->AMAZON_ASSOCIATE_TAG;
$url = $self->_aws_signature->addRESTSecret($url);
# Respect Amazon SLA
diff --git a/lib/MusicBrainz/Server/Data/CoverArtArchive.pm b/lib/MusicBrainz/Server/Data/CoverArtArchive.pm
index 5ed6e46..1085c87 100644
--- a/lib/MusicBrainz/Server/Data/CoverArtArchive.pm
+++ b/lib/MusicBrainz/Server/Data/CoverArtArchive.pm
@@ -8,12 +8,12 @@ use Net::CoverArtArchive qw( find_available_artwork );
use Net::CoverArtArchive::CoverArt;
use Time::HiRes qw( time );
-my $caa = Net::CoverArtArchive->new (cover_art_archive_prefix => &DBDefs::COVER_ART_ARCHIVE_DOWNLOAD_PREFIX);
+my $caa = Net::CoverArtArchive->new (cover_art_archive_prefix => DBDefs->COVER_ART_ARCHIVE_DOWNLOAD_PREFIX);
sub find_available_artwork {
my ($self, $mbid) = @_;
- my $prefix = DBDefs::COVER_ART_ARCHIVE_DOWNLOAD_PREFIX."/release/$mbid";
+ my $prefix = DBDefs->COVER_ART_ARCHIVE_DOWNLOAD_PREFIX."/release/$mbid";
return [
map {
@@ -48,8 +48,8 @@ sub post_fields
{
my ($self, $bucket, $mbid, $id, $redirect) = @_;
- my $aws_id = &DBDefs::COVER_ART_ARCHIVE_ID;
- my $aws_key = &DBDefs::COVER_ART_ARCHIVE_KEY;
+ my $aws_id = DBDefs->COVER_ART_ARCHIVE_ID;
+ my $aws_key = DBDefs->COVER_ART_ARCHIVE_KEY;
my $policy = Net::Amazon::S3::Policy->new(expiration => int(time()) + 3600);
my $filename = "mbid-$mbid-" . $id . '.jpg';
diff --git a/lib/MusicBrainz/Server/Data/FileCache.pm b/lib/MusicBrainz/Server/Data/FileCache.pm
index c0563a0..fcdf880 100644
--- a/lib/MusicBrainz/Server/Data/FileCache.pm
+++ b/lib/MusicBrainz/Server/Data/FileCache.pm
@@ -24,7 +24,7 @@ sub manifest_signature {
unless (exists $self->manifest_signatures->{$manifest}) {
my $signature = md5_hex(join ',', map {
join(':', file($_)->basename, file_md5_hex($_));
- } map { DBDefs::STATIC_FILES_DIR . "/$_" }
+ } map { DBDefs->STATIC_FILES_DIR . "/$_" }
$self->manifest_files($manifest, $type));
$self->manifest_signatures->{$manifest} = $signature;
@@ -48,7 +48,7 @@ sub _expand {
sub manifest_files {
my ($self, $manifest, $type) = @_;
- my $relative_to = DBDefs::STATIC_FILES_DIR;
+ my $relative_to = DBDefs->STATIC_FILES_DIR;
return
# Convert paths back to relative paths of the manifest directory
@@ -66,25 +66,25 @@ sub squash {
my ($self, $minifier, $manifest, $type, $prefix) = @_;
my $input = join("\n",
map { io($_)->all }
- map { DBDefs::STATIC_FILES_DIR . "/$_" }
+ map { DBDefs->STATIC_FILES_DIR . "/$_" }
$self->manifest_files($manifest, $type));
my $hash = $self->manifest_signature($manifest, $type);
printf STDERR "Compiling $manifest...";
my $output = $minifier->(input => $input);
- $output > io(DBDefs::STATIC_FILES_DIR . "/$prefix$hash.$type");
+ $output > io(DBDefs->STATIC_FILES_DIR . "/$prefix$hash.$type");
printf STDERR "OK\n";
}
sub compile_javascript_manifest {
my ($self, $manifest) = @_;
- return $self->squash(DBDefs::MINIFY_SCRIPTS, $manifest, 'js', '');
+ return $self->squash(DBDefs->MINIFY_SCRIPTS, $manifest, 'js', '');
}
sub compile_css_manifest {
my ($self, $manifest) = @_;
- return $self->squash(DBDefs::MINIFY_STYLES, $manifest, 'css', 'styles/');
+ return $self->squash(DBDefs->MINIFY_STYLES, $manifest, 'css', 'styles/');
}
__PACKAGE__->meta->make_immutable;
diff --git a/lib/MusicBrainz/Server/Data/RateLimiter.pm b/lib/MusicBrainz/Server/Data/RateLimiter.pm
index 5b38377..cc43b65 100644
--- a/lib/MusicBrainz/Server/Data/RateLimiter.pm
+++ b/lib/MusicBrainz/Server/Data/RateLimiter.pm
@@ -20,7 +20,7 @@ sub get_socket
{
my ($self) = @_;
- my $server = DBDefs::RATELIMIT_SERVER or return;
+ my $server = DBDefs->RATELIMIT_SERVER or return;
my $s = $self->_socket;
return $s if $s;
diff --git a/lib/MusicBrainz/Server/Data/Search.pm b/lib/MusicBrainz/Server/Data/Search.pm
index 7ee3778..d1c3a67 100644
--- a/lib/MusicBrainz/Server/Data/Search.pm
+++ b/lib/MusicBrainz/Server/Data/Search.pm
@@ -562,7 +562,7 @@ sub external_search
$query = uri_escape_utf8($query);
$type =~ s/release_group/release-group/;
my $search_url = sprintf("http://%s/ws/2/%s/?query=%s&offset=%s&max=%s&fmt=json&dismax=%s",
- DBDefs::LUCENE_SERVER,
+ DBDefs->LUCENE_SERVER,
$type,
$query,
$offset,
@@ -570,7 +570,7 @@ sub external_search
$adv ? 'false' : 'true',
);
- if (&DBDefs::_RUNNING_TESTS)
+ if (DBDefs->_RUNNING_TESTS)
{
$ua = MusicBrainz::Server::Test::mock_search_server($type);
}
@@ -837,7 +837,7 @@ sub xml_search
$query = uri_escape_utf8($query);
my $search_url = sprintf("http://%s/ws/%d/%s/?query=%s&offset=%s&max=%s&fmt=xml",
- DBDefs::LUCENE_SERVER,
+ DBDefs->LUCENE_SERVER,
$version,
$type,
$query,
diff --git a/lib/MusicBrainz/Server/Data/Statistics.pm b/lib/MusicBrainz/Server/Data/Statistics.pm
index 5ed1c41..3433423 100644
--- a/lib/MusicBrainz/Server/Data/Statistics.pm
+++ b/lib/MusicBrainz/Server/Data/Statistics.pm
@@ -1634,8 +1634,8 @@ sub recalculate {
or warn("Unknown statistic '$statistic'"), return;
return if $definition->{PREREQ_ONLY};
- return if $definition->{NONREPLICATED} && &DBDefs::REPLICATION_TYPE == RT_SLAVE;
- return if $definition->{PRIVATE} && &DBDefs::REPLICATION_TYPE != RT_MASTER;
+ return if $definition->{NONREPLICATED} && DBDefs->REPLICATION_TYPE == RT_SLAVE;
+ return if $definition->{PRIVATE} && DBDefs->REPLICATION_TYPE != RT_MASTER;
my $db = $definition->{DB} || 'READWRITE';
my $sql = $db eq 'READWRITE' ? $self->sql
diff --git a/lib/MusicBrainz/Server/Data/WikiDoc.pm b/lib/MusicBrainz/Server/Data/WikiDoc.pm
index e58091b..5fbf693 100644
--- a/lib/MusicBrainz/Server/Data/WikiDoc.pm
+++ b/lib/MusicBrainz/Server/Data/WikiDoc.pm
@@ -18,8 +18,8 @@ sub _fix_html_links
{
my ($self, $node, $index) = @_;
- my $server = DBDefs::WEB_SERVER;
- my $wiki_server = DBDefs::WIKITRANS_SERVER;
+ my $server = DBDefs->WEB_SERVER;
+ my $wiki_server = DBDefs->WIKITRANS_SERVER;
my $class = $node->attr('class') || "";
@@ -48,7 +48,7 @@ sub _fix_html_markup
{
my ($self, $content, $index) = @_;
- my $wiki_server = DBDefs::WIKITRANS_SERVER;
+ my $wiki_server = DBDefs->WIKITRANS_SERVER;
my $tree = HTML::TreeBuilder::XPath->new;
$tree->parse_content ("<html><body>".$content."</body></html>");
@@ -116,7 +116,7 @@ sub _load_page
return MusicBrainz::Server::Entity::WikiDocPage->new({ canonical => "MusicBrainz_Documentation" })
if ($id eq "");
- my $doc_url = sprintf "http://%s/%s?action=render", &DBDefs::WIKITRANS_SERVER, $id;
+ my $doc_url = sprintf "http://%s/%s?action=render", DBDefs->WIKITRANS_SERVER, $id;
if (defined $version) {
$doc_url .= "&oldid=$version";
}
@@ -152,7 +152,7 @@ sub get_version
{
my ($self, $id) = @_;
- my $doc_url = sprintf "http://%s/?title=%s", &DBDefs::WIKITRANS_SERVER, $id;
+ my $doc_url = sprintf "http://%s/?title=%s", DBDefs->WIKITRANS_SERVER, $id;
my $ua = LWP::UserAgent->new();
$ua->env_proxy;
diff --git a/lib/MusicBrainz/Server/Data/WikiDocIndex.pm b/lib/MusicBrainz/Server/Data/WikiDocIndex.pm
index 2fad8ea..0f902ac 100644
--- a/lib/MusicBrainz/Server/Data/WikiDocIndex.pm
+++ b/lib/MusicBrainz/Server/Data/WikiDocIndex.pm
@@ -19,10 +19,10 @@ Readonly my $CACHE_KEY => "wikidoc-index";
has _index_file => (
is => 'ro',
- default => sub { &DBDefs::WIKITRANS_INDEX_FILE }
+ default => sub { DBDefs->WIKITRANS_INDEX_FILE }
);
-sub _master_index_url { &DBDefs::WIKITRANS_INDEX_URL }
+sub _master_index_url { DBDefs->WIKITRANS_INDEX_URL }
sub _parse_index
{
@@ -73,7 +73,7 @@ sub _load_index
return $index
if defined $index;
- if (&DBDefs::REPLICATION_TYPE == RT_SLAVE) {
+ if (DBDefs->REPLICATION_TYPE == RT_SLAVE) {
$index = $self->_load_index_from_master;
}
else {
@@ -142,12 +142,12 @@ sub get_wiki_versions
# The API can only process 50 pages at a time, lets be conservative.
my $query = join ('|', splice(@keys, 0, 40));
- if (!defined &DBDefs::WIKITRANS_SERVER_API) {
+ if (!defined DBDefs->WIKITRANS_SERVER_API) {
warn 'WIKITRANS_SERVER_API must be defined within DBDefs.pm';
return undef;
}
- my $doc_url = sprintf "http://%s?action=query&prop=info&format=xml&titles=%s", &DBDefs::WIKITRANS_SERVER_API, $query;
+ my $doc_url = sprintf "http://%s?action=query&prop=info&format=xml&titles=%s", DBDefs->WIKITRANS_SERVER_API, $query;
my $ua = LWP::UserAgent->new(max_redirect => 0, timeout => 5);
$ua->env_proxy;
diff --git a/lib/MusicBrainz/Server/Edit/Release/AddCoverArt.pm b/lib/MusicBrainz/Server/Edit/Release/AddCoverArt.pm
index 630880d..d7123aa 100644
--- a/lib/MusicBrainz/Server/Edit/Release/AddCoverArt.pm
+++ b/lib/MusicBrainz/Server/Edit/Release/AddCoverArt.pm
@@ -107,7 +107,7 @@ sub build_display_data {
Release->new( name => $self->data->{entity}{name} );
# FIXME: replace this with a proper Net::CoverArtArchive::CoverArt object.
- my $prefix = DBDefs::COVER_ART_ARCHIVE_DOWNLOAD_PREFIX . "/release/" . $release->gid . "/";
+ my $prefix = DBDefs->COVER_ART_ARCHIVE_DOWNLOAD_PREFIX . "/release/" . $release->gid . "/";
my $artwork = {
image => $prefix.$self->data->{cover_art_id}.'.jpg',
large_thumbnail => $prefix.$self->data->{cover_art_id}.'-500.jpg',
diff --git a/lib/MusicBrainz/Server/Edit/Release/EditCoverArt.pm b/lib/MusicBrainz/Server/Edit/Release/EditCoverArt.pm
index 5141c83..05f5dc9 100644
--- a/lib/MusicBrainz/Server/Edit/Release/EditCoverArt.pm
+++ b/lib/MusicBrainz/Server/Edit/Release/EditCoverArt.pm
@@ -128,7 +128,7 @@ sub build_display_data {
Release->new( name => $self->data->{entity}{name} );
# FIXME: replace this with a proper Net::CoverArtArchive::CoverArt object.
- my $prefix = DBDefs::COVER_ART_ARCHIVE_DOWNLOAD_PREFIX . "/release/" . $data{release}->gid . "/";
+ my $prefix = DBDefs->COVER_ART_ARCHIVE_DOWNLOAD_PREFIX . "/release/" . $data{release}->gid . "/";
$data{artwork} = {
image => $prefix.$self->data->{id}.'.jpg',
large_thumbnail => $prefix.$self->data->{id}.'-500.jpg',
diff --git a/lib/MusicBrainz/Server/Edit/Release/RemoveCoverArt.pm b/lib/MusicBrainz/Server/Edit/Release/RemoveCoverArt.pm
index ec1e7d1..81d2011 100644
--- a/lib/MusicBrainz/Server/Edit/Release/RemoveCoverArt.pm
+++ b/lib/MusicBrainz/Server/Edit/Release/RemoveCoverArt.pm
@@ -111,7 +111,7 @@ sub build_display_data {
Release->new( name => $self->data->{entity}{name} );
# FIXME: replace this with a proper Net::CoverArtArchive::CoverArt object.
- my $prefix = DBDefs::COVER_ART_ARCHIVE_DOWNLOAD_PREFIX . "/release/" . $release->gid . "/";
+ my $prefix = DBDefs->COVER_ART_ARCHIVE_DOWNLOAD_PREFIX . "/release/" . $release->gid . "/";
my $artwork = {
image => $prefix.$self->data->{cover_art_id}.'.jpg',
large_thumbnail => $prefix.$self->data->{cover_art_id}.'-500.jpg',
diff --git a/lib/MusicBrainz/Server/EditQueue.pm b/lib/MusicBrainz/Server/EditQueue.pm
index c13dbd6..7cb3365 100644
--- a/lib/MusicBrainz/Server/EditQueue.pm
+++ b/lib/MusicBrainz/Server/EditQueue.pm
@@ -47,7 +47,7 @@ sub process_edits
$self->log->info("Edit queue processing starting\n");
- if (&DBDefs::DB_READ_ONLY) {
+ if (DBDefs->DB_READ_ONLY) {
$self->log->error("Can't work on a read-only database (DB_READ_ONLY is set)\n");
return 0;
}
diff --git a/lib/MusicBrainz/Server/Email.pm b/lib/MusicBrainz/Server/Email.pm
index 3ffe5ab..94fe8f0 100644
--- a/lib/MusicBrainz/Server/Email.pm
+++ b/lib/MusicBrainz/Server/Email.pm
@@ -43,7 +43,7 @@ sub _user_address
sub _message_id
{
my $format_string = shift;
- return sprintf('<' . $format_string . '@%s>', @_, &DBDefs::WEB_SERVER_USED_IN_EMAIL);
+ return sprintf('<' . $format_string . '@%s>', @_, DBDefs->WEB_SERVER_USED_IN_EMAIL);
}
sub _create_email
@@ -95,7 +95,7 @@ sub _create_message_to_editor_email
my $from_name = $from->name;
my $contact_url = sprintf "http://%s/user/%s/contact",
- &DBDefs::WEB_SERVER_USED_IN_EMAIL,
+ DBDefs->WEB_SERVER_USED_IN_EMAIL,
uri_escape_utf8($from->name);
my $body = <<EOS;
@@ -169,7 +169,7 @@ sub _create_lost_username_email
);
my $user_name = $opts{user}->name;
- my $lost_password_url = sprintf "http://%s/lost-password", &DBDefs::WEB_SERVER_USED_IN_EMAIL;
+ my $lost_password_url = sprintf "http://%s/lost-password", DBDefs->WEB_SERVER_USED_IN_EMAIL;
my $body = <<EOS;
Someone, probably you, asked to look up the username of the
@@ -208,8 +208,8 @@ sub _create_no_vote_email
'Subject' => "Someone has voted against your edit #$edit_id",
);
- my $url = sprintf 'http://%s/edit/%d', &DBDefs::WEB_SERVER_USED_IN_EMAIL, $edit_id;
- my $prefs_url = sprintf 'http://%s/account/preferences', &DBDefs::WEB_SERVER_USED_IN_EMAIL;
+ my $url = sprintf 'http://%s/edit/%d', DBDefs->WEB_SERVER_USED_IN_EMAIL, $edit_id;
+ my $prefs_url = sprintf 'http://%s/account/preferences', DBDefs->WEB_SERVER_USED_IN_EMAIL;
my $body = <<EOS;
'${\ $voter->name }' has voted against your edit #$edit_id.
@@ -246,7 +246,7 @@ sub _create_password_reset_request_email
);
my $reset_password_link = $opts{reset_password_link};
- my $contact_url = sprintf "http://%s/doc/Contact_Us", &DBDefs::WEB_SERVER_USED_IN_EMAIL;
+ my $contact_url = sprintf "http://%s/doc/Contact_Us", DBDefs->WEB_SERVER_USED_IN_EMAIL;
my $body = <<EOS;
Someone, probably you, asked that your MusicBrainz password be reset.
@@ -291,7 +291,7 @@ sub _create_edit_note_email
);
my $from = $from_editor->name;
- my $respond = sprintf "http://%s/edit/%d", &DBDefs::WEB_SERVER_USED_IN_EMAIL, $edit_id;
+ my $respond = sprintf "http://%s/edit/%d", DBDefs->WEB_SERVER_USED_IN_EMAIL, $edit_id;
my $body;
if ($own_edit) {
@@ -477,12 +477,12 @@ sub _build_transport
{
my ($self) = @_;
- if (&DBDefs::_RUNNING_TESTS) { # XXX shouldn't be here
+ if (DBDefs->_RUNNING_TESTS) { # XXX shouldn't be here
return $self->get_test_transport;
}
return Email::Sender::Transport::SMTP->new({
- host => &DBDefs::SMTP_SERVER,
+ host => DBDefs->SMTP_SERVER,
});
}
diff --git a/lib/MusicBrainz/Server/Email/Role.pm b/lib/MusicBrainz/Server/Email/Role.pm
index 6842988..bdc23ba 100644
--- a/lib/MusicBrainz/Server/Email/Role.pm
+++ b/lib/MusicBrainz/Server/Email/Role.pm
@@ -30,7 +30,7 @@ has 'from' => (
has 'server' => (
isa => Str,
is => 'ro',
- default => sprintf 'http://%s', DBDefs::WEB_SERVER_USED_IN_EMAIL
+ default => sprintf 'http://%s', DBDefs->WEB_SERVER_USED_IN_EMAIL
);
sub text { '' }
diff --git a/lib/MusicBrainz/Server/Entity/URL/ASIN.pm b/lib/MusicBrainz/Server/Entity/URL/ASIN.pm
index 111c0fe..e5d0542 100644
--- a/lib/MusicBrainz/Server/Entity/URL/ASIN.pm
+++ b/lib/MusicBrainz/Server/Entity/URL/ASIN.pm
@@ -29,7 +29,7 @@ sub affiliate_url {
my $url = $self->url;
if ($url =~ m{^http://(?:www.)?(.*?\.)amazon\.([a-z\.]+)(?:\:[0-9]+)?/.*/([0-9B][0-9A-Z]{9})(?:[^0-9A-Z]|$)}i) {
my $asin = $3;
- my $ass_id = DBDefs::AMAZON_ASSOCIATE_TAG;
+ my $ass_id = DBDefs->AMAZON_ASSOCIATE_TAG;
return URI->new("http://amazon.$2/exec/obidos/ASIN/$asin/$ass_id?v=glance&s=music");
}
else {
diff --git a/lib/MusicBrainz/Server/Filters.pm b/lib/MusicBrainz/Server/Filters.pm
index f5fcae0..ef110c2 100644
--- a/lib/MusicBrainz/Server/Filters.pm
+++ b/lib/MusicBrainz/Server/Filters.pm
@@ -74,7 +74,7 @@ sub format_wikitext
return '' unless $text;
# MBS-2437: Expand MBID entity links
- my $ws = DBDefs::WEB_SERVER;
+ my $ws = DBDefs->WEB_SERVER;
$text =~ s/
\[
(artist|label|recording|release|release-group|url|work):
@@ -130,7 +130,7 @@ sub format_editnote
my ($html) = @_;
my $is_url = 1;
- my $server = &DBDefs::WEB_SERVER;
+ my $server = DBDefs->WEB_SERVER;
# Pre-pass the edit note to attempt to normalise any URLs
$html =~ s{(http://[^\s]+)}{normalise_url($1)}eg;
diff --git a/lib/MusicBrainz/Server/Form/Search/Search.pm b/lib/MusicBrainz/Server/Form/Search/Search.pm
index 8c61bda..ad63fff 100644
--- a/lib/MusicBrainz/Server/Form/Search/Search.pm
+++ b/lib/MusicBrainz/Server/Form/Search/Search.pm
@@ -43,7 +43,7 @@ sub options_type
'tag' => l('Tag'),
);
- push @options, ( 'doc' => l('Documentation') ) if &DBDefs::GOOGLE_CUSTOM_SEARCH;
+ push @options, ( 'doc' => l('Documentation') ) if DBDefs->GOOGLE_CUSTOM_SEARCH;
return \@options;
}
diff --git a/lib/MusicBrainz/Server/Log.pm b/lib/MusicBrainz/Server/Log.pm
index f8ff083..bcce442 100644
--- a/lib/MusicBrainz/Server/Log.pm
+++ b/lib/MusicBrainz/Server/Log.pm
@@ -10,7 +10,7 @@ use Log::Dispatch;
my $logger;
BEGIN {
$logger = Log::Dispatch->new(
- DBDefs::LOGGER_ARGUMENTS,
+ DBDefs->LOGGER_ARGUMENTS,
callbacks => \&_prefix_message
);
}
diff --git a/lib/MusicBrainz/Server/Model/MB.pm b/lib/MusicBrainz/Server/Model/MB.pm
index d3f1eee..13ef034 100644
--- a/lib/MusicBrainz/Server/Model/MB.pm
+++ b/lib/MusicBrainz/Server/Model/MB.pm
@@ -21,12 +21,12 @@ sub _build_context {
my $self = shift;
- if (DBDefs::_RUNNING_TESTS()) {
+ if (DBDefs->_RUNNING_TESTS()) {
require MusicBrainz::Server::Test;
return MusicBrainz::Server::Test->create_test_context;
}
else {
- my $cache_opts = &DBDefs::CACHE_MANAGER_OPTIONS;
+ my $cache_opts = DBDefs->CACHE_MANAGER_OPTIONS;
return MusicBrainz::Server::Context->new(
cache_manager => MusicBrainz::Server::CacheManager->new($cache_opts)
);
diff --git a/lib/MusicBrainz/Server/Replication.pm b/lib/MusicBrainz/Server/Replication.pm
index 148bc18..708973f 100644
--- a/lib/MusicBrainz/Server/Replication.pm
+++ b/lib/MusicBrainz/Server/Replication.pm
@@ -29,7 +29,7 @@ use strict;
package MusicBrainz::Server::Replication;
-# The possible values for DBDefs::REPLICATION_TYPE
+# The possible values for DBDefs->REPLICATION_TYPE
use constant RT_MASTER => 1;
use constant RT_SLAVE => 2;
use constant RT_STANDALONE => 3;
diff --git a/lib/MusicBrainz/Server/Translation.pm b/lib/MusicBrainz/Server/Translation.pm
index d66e529..c958b76 100644
--- a/lib/MusicBrainz/Server/Translation.pm
+++ b/lib/MusicBrainz/Server/Translation.pm
@@ -107,7 +107,7 @@ sub set_language
@avail_lang = map { s/-([a-z]{2})/_\U$1/; $_; }
grep {
my $l = $_;
- grep { $l eq $_ } DBDefs::MB_LANGUAGES
+ grep { $l eq $_ } DBDefs->MB_LANGUAGES
} $self->all_system_languages;
}
my $set_lang = web_set_locale(\@avail_lang, [ 'utf-8' ], LC_MESSAGES);
@@ -122,11 +122,11 @@ sub set_language
my $set_lang_nocountry = $set_lang;
$set_lang_nocountry =~ s/_[A-Z]{2}//;
# Change en_AQ back to en-aq to compare with MB_LANGUAGES
- if (grep { $set_lang eq $_ || $set_lang_munge eq $_ } DBDefs::MB_LANGUAGES) {
+ if (grep { $set_lang eq $_ || $set_lang_munge eq $_ } DBDefs->MB_LANGUAGES) {
return $set_lang;
}
# Check if the language without country code is in MB_LANGUAGES
- elsif (grep { $set_lang_nocountry eq $_ } DBDefs::MB_LANGUAGES) {
+ elsif (grep { $set_lang_nocountry eq $_ } DBDefs->MB_LANGUAGES) {
return $set_lang_nocountry;
}
# Give up, return the full language even though it looks wrong
@@ -148,10 +148,10 @@ sub language_from_cookie
my $cookie_nocountry = defined $cookie ? $cookie->value : '';
$cookie_nocountry =~ s/_[A-Z]{2}//;
if (defined $cookie &&
- grep { $cookie->value eq $_ || $cookie_munge eq $_ } DBDefs::MB_LANGUAGES) {
+ grep { $cookie->value eq $_ || $cookie_munge eq $_ } DBDefs->MB_LANGUAGES) {
return $cookie->value;
} elsif (defined $cookie &&
- grep { $cookie_nocountry eq $_ } DBDefs::MB_LANGUAGES) {
+ grep { $cookie_nocountry eq $_ } DBDefs->MB_LANGUAGES) {
return $cookie_nocountry;
} else {
return undef;
@@ -164,12 +164,12 @@ sub all_languages
map { [ $_ => DateTime::Locale->load($_) ] }
grep { my $l = $_;
grep { $l eq $_ } DateTime::Locale->ids() }
- map { s/-([a-z]{2})/_\U$1/; $_; } DBDefs::MB_LANGUAGES;
+ map { s/-([a-z]{2})/_\U$1/; $_; } DBDefs->MB_LANGUAGES;
my @lang_without_locale = sort_by { $_->[1]->{id} }
map { [ $_ => {'id' => $_, 'native_language' => ''} ] }
grep { my $l = $_;
!(grep { $l eq $_ } DateTime::Locale->ids()) }
- map { s/-([a-z]{2})/_\U$1/; $_; } DBDefs::MB_LANGUAGES;
+ map { s/-([a-z]{2})/_\U$1/; $_; } DBDefs->MB_LANGUAGES;
my @languages = (@lang_with_locale, @lang_without_locale);
return \@languages;
}
diff --git a/lib/MusicBrainz/Server/View/Default.pm b/lib/MusicBrainz/Server/View/Default.pm
index f1e4be0..a5e2285 100644
--- a/lib/MusicBrainz/Server/View/Default.pm
+++ b/lib/MusicBrainz/Server/View/Default.pm
@@ -17,7 +17,7 @@ sub process
$self->next::method(@_) or return 0;
- return 1 unless &DBDefs::USE_ETAGS;
+ return 1 unless DBDefs->USE_ETAGS;
my $method = $c->request->method;
return 1
diff --git a/lib/MusicBrainz/Server/WebService/XMLSearch.pm b/lib/MusicBrainz/Server/WebService/XMLSearch.pm
index 183379a..73120c9 100644
--- a/lib/MusicBrainz/Server/WebService/XMLSearch.pm
+++ b/lib/MusicBrainz/Server/WebService/XMLSearch.pm
@@ -197,7 +197,7 @@ sub xml_search
};
}
- my $url = 'http://' . &DBDefs::LUCENE_SERVER . "/ws/2/$resource/?" .
+ my $url = 'http://' . DBDefs->LUCENE_SERVER . "/ws/2/$resource/?" .
"max=$limit&type=$resource&fmt=xml&offset=$offset&query=". uri_escape_utf8($query);
require LWP::UserAgent;
diff --git a/lib/MusicBrainz/Server/Wizard.pm b/lib/MusicBrainz/Server/Wizard.pm
index a7f445e..22a813e 100644
--- a/lib/MusicBrainz/Server/Wizard.pm
+++ b/lib/MusicBrainz/Server/Wizard.pm
@@ -4,7 +4,7 @@ use Cache::Memcached::Fast;
use Carp qw( croak );
use MusicBrainz::Server::Form::Utils qw( expand_param expand_all_params collapse_param );
-my $cache = new Cache::Memcached::Fast (&DBDefs::WIZARD_MEMCACHED);
+my $cache = new Cache::Memcached::Fast (DBDefs->WIZARD_MEMCACHED);
has '_current' => (
is => 'rw',
diff --git a/lib/Sql.pm b/lib/Sql.pm
index a1dcaa9..fc18b66 100644
--- a/lib/Sql.pm
+++ b/lib/Sql.pm
@@ -211,7 +211,7 @@ sub commit
$self->dec_transaction_depth;
return unless $self->transaction_depth == 0;
- croak "Cannot commit, in readonly mode!" if DBDefs::DB_READ_ONLY;
+ croak "Cannot commit, in readonly mode!" if DBDefs->DB_READ_ONLY;
return try {
my $tt = Sql::Timer->new('COMMIT', []) if $self->debug;
diff --git a/script/compile_resources.pl b/script/compile_resources.pl
index 8726678..b2ccdbc 100755
--- a/script/compile_resources.pl
+++ b/script/compile_resources.pl
@@ -15,5 +15,5 @@ my $fc = MusicBrainz::Server::Data::FileCache->new;
find(sub {
$fc->compile_javascript_manifest($_) if ($_ =~ /.js.manifest$/);
$fc->compile_css_manifest($_) if ($_ =~ /.css.manifest$/);
-}, DBDefs::STATIC_FILES_DIR);
+}, DBDefs->STATIC_FILES_DIR);
diff --git a/t/lib/t/MusicBrainz/Script/RebuildCoverArt.pm b/t/lib/t/MusicBrainz/Script/RebuildCoverArt.pm
index 22fec0a..a3ab416 100644
--- a/t/lib/t/MusicBrainz/Script/RebuildCoverArt.pm
+++ b/t/lib/t/MusicBrainz/Script/RebuildCoverArt.pm
@@ -23,7 +23,7 @@ is($sql->select_single_value('SELECT 1 FROM release_coverart WHERE id = 1 AND co
SKIP: {
skip 'Testing Amazon CoverArt requires the AWS_PUBLIC and AWS_PRIVATE configuration variables to be set', 1
- unless DBDefs::AWS_PUBLIC() && DBDefs::AWS_PRIVATE();
+ unless DBDefs->AWS_PUBLIC() && DBDefs->AWS_PRIVATE();
is($sql->select_single_value('SELECT 1 FROM release_coverart WHERE id = 2 AND cover_art_url IS NOT NULL'), 1);
};
diff --git a/t/lib/t/MusicBrainz/Server/Data/AutoEditorElection.pm b/t/lib/t/MusicBrainz/Server/Data/AutoEditorElection.pm
index 34a7d4c..520b506 100644
--- a/t/lib/t/MusicBrainz/Server/Data/AutoEditorElection.pm
+++ b/t/lib/t/MusicBrainz/Server/Data/AutoEditorElection.pm
@@ -39,7 +39,7 @@ test 'Accept' => sub {
like($email->get_body, qr{http://[^/]+/election/${\ $election->id }});
like($email->get_body, qr{Candidate:\s+noob1});
like($email->get_body, qr{Proposer:\s+autoeditor1});
- is($email->get_header('References'), sprintf('<autoeditor-election-%s@%s>', $election->id, &DBDefs::WEB_SERVER_USED_IN_EMAIL), "References header is correct");
+ is($email->get_header('References'), sprintf('<autoeditor-election-%s@%s>', $election->id, DBDefs->WEB_SERVER_USED_IN_EMAIL), "References header is correct");
like($email->get_header('Message-Id'), qr{<autoeditor-election-1-\d+@.*>}, "Message-id header has correct format");
$email_transport->clear_deliveries;
@@ -77,7 +77,7 @@ test 'Accept' => sub {
like($email->get_body, qr{Proposer:\s+autoeditor1});
like($email->get_body, qr{Seconder:\s+autoeditor2});
like($email->get_body, qr{Seconder:\s+autoeditor3});
- is($email->get_header('References'), sprintf('<autoeditor-election-%s@%s>', $election->id, &DBDefs::WEB_SERVER_USED_IN_EMAIL), "References header is correct");
+ is($email->get_header('References'), sprintf('<autoeditor-election-%s@%s>', $election->id, DBDefs->WEB_SERVER_USED_IN_EMAIL), "References header is correct");
like($email->get_header('Message-Id'), qr{<autoeditor-election-1-\d+@.*>}, "Message-id header has correct format");
$email_transport->clear_deliveries;
@@ -141,7 +141,7 @@ test 'Accept' => sub {
is($email->get_header('Subject'), 'Autoeditor Election: noob1');
like($email->get_body, qr{Voting in this election is now closed: noob1 has been\s+accepted as an auto-editor});
like($email->get_body, qr{http://[^/]+/election/${\ $election->id }});
- is($email->get_header('References'), sprintf('<autoeditor-election-%s@%s>', $election->id, &DBDefs::WEB_SERVER_USED_IN_EMAIL), "References header is correct");
+ is($email->get_header('References'), sprintf('<autoeditor-election-%s@%s>', $election->id, DBDefs->WEB_SERVER_USED_IN_EMAIL), "References header is correct");
like($email->get_header('Message-Id'), qr{<autoeditor-election-1-\d+@.*>}, "Message-id header has correct format");
$email_transport->clear_deliveries;
@@ -190,7 +190,7 @@ test 'Rejected' => sub {
is($email->get_header('Subject'), 'Autoeditor Election: noob1');
like($email->get_body, qr{Voting in this election is now closed: the proposal to make\s+noob1 an auto-editor was declined});
like($email->get_body, qr{http://[^/]+/election/${\ $election->id }});
- is($email->get_header('References'), sprintf('<autoeditor-election-%s@%s>', $election->id, &DBDefs::WEB_SERVER_USED_IN_EMAIL), "References header is correct");
+ is($email->get_header('References'), sprintf('<autoeditor-election-%s@%s>', $election->id, DBDefs->WEB_SERVER_USED_IN_EMAIL), "References header is correct");
like($email->get_header('Message-Id'), qr{<autoeditor-election-1-\d+@.*>}, "Message-id header has correct format");
$email_transport->clear_deliveries;
@@ -308,7 +308,7 @@ test 'Timeout' => sub {
is($email->get_header('Subject'), 'Autoeditor Election: noob1');
like($email->get_body, qr{This election has been cancelled, because two seconders could not be\s+found within the allowed time \(1 week\)});
like($email->get_body, qr{http://[^/]+/election/${\ $election->id }});
- is($email->get_header('References'), sprintf('<autoeditor-election-%s@%s>', $election->id, &DBDefs::WEB_SERVER_USED_IN_EMAIL), "References header is correct");
+ is($email->get_header('References'), sprintf('<autoeditor-election-%s@%s>', $election->id, DBDefs->WEB_SERVER_USED_IN_EMAIL), "References header is correct");
like($email->get_header('Message-Id'), qr{<autoeditor-election-1-\d+@.*>}, "Message-id header has correct format");
$email_transport->clear_deliveries;
@@ -344,7 +344,7 @@ test 'Cancel' => sub {
is($email->get_header('Subject'), 'Autoeditor Election: noob1');
like($email->get_body, qr{This election has been cancelled by the proposer \(autoeditor1\)});
like($email->get_body, qr{http://[^/]+/election/${\ $election->id }});
- is($email->get_header('References'), sprintf('<autoeditor-election-%s@%s>', $election->id, &DBDefs::WEB_SERVER_USED_IN_EMAIL), "References header is correct");
+ is($email->get_header('References'), sprintf('<autoeditor-election-%s@%s>', $election->id, DBDefs->WEB_SERVER_USED_IN_EMAIL), "References header is correct");
like($email->get_header('Message-Id'), qr{<autoeditor-election-1-\d+@.*>}, "Message-id header has correct format");
$email_transport->clear_deliveries;
diff --git a/t/lib/t/MusicBrainz/Server/Data/CoverArt.pm b/t/lib/t/MusicBrainz/Server/Data/CoverArt.pm
index ce776e0..9bc0f5b 100644
--- a/t/lib/t/MusicBrainz/Server/Data/CoverArt.pm
+++ b/t/lib/t/MusicBrainz/Server/Data/CoverArt.pm
@@ -49,7 +49,7 @@ test 'Doesnt parse invalid cover art relationships' => sub {
test 'Handles Amazon ASINs' => sub {
plan skip_all => 'Testing Amazon ASINs requires the AWS_PUBLIC and AWS_PRIVATE configuration variables to be set'
- unless DBDefs::AWS_PUBLIC() && DBDefs::AWS_PRIVATE();
+ unless DBDefs->AWS_PUBLIC() && DBDefs->AWS_PRIVATE();
my $test = shift;
@@ -63,7 +63,7 @@ test 'Handles Amazon ASINs' => sub {
test 'Handles Amazon ASINs for downloads' => sub {
plan skip_all => 'Testing Amazon ASINs requires the AWS_PUBLIC and AWS_PRIVATE configuration variables to be set'
- unless DBDefs::AWS_PUBLIC() && DBDefs::AWS_PRIVATE();
+ unless DBDefs->AWS_PUBLIC() && DBDefs->AWS_PRIVATE();
my $test = shift;
@@ -77,7 +77,7 @@ test 'Handles Amazon ASINs for downloads' => sub {
test 'Searching Amazon by barcode' => sub {
plan skip_all => 'Testing Amazon barcode searches requires the AWS_PUBLIC and AWS_PRIVATE configuration variables to be set'
- unless DBDefs::AWS_PUBLIC() && DBDefs::AWS_PRIVATE();
+ unless DBDefs->AWS_PUBLIC() && DBDefs->AWS_PRIVATE();
my $test = shift;
diff --git a/t/lib/t/MusicBrainz/Server/Data/EditNote.pm b/t/lib/t/MusicBrainz/Server/Data/EditNote.pm
index 0c6e9ca..971990c 100644
--- a/t/lib/t/MusicBrainz/Server/Data/EditNote.pm
+++ b/t/lib/t/MusicBrainz/Server/Data/EditNote.pm
@@ -129,7 +129,7 @@ $test->c->model('Vote')->enter_votes(2, { edit_id => $edit->id, vote => 1 });
$en_data->add_note($edit->id, { text => "This is my note!", editor_id => 3 });
-my $server = DBDefs::WEB_SERVER_USED_IN_EMAIL;
+my $server = DBDefs->WEB_SERVER_USED_IN_EMAIL;
my $email_transport = MusicBrainz::Server::Email->get_test_transport;
is(scalar @{ $email_transport->deliveries }, 2);
diff --git a/t/lib/t/MusicBrainz/Server/Data/Vote.pm b/t/lib/t/MusicBrainz/Server/Data/Vote.pm
index 2c9a9d7..58add25 100644
--- a/t/lib/t/MusicBrainz/Server/Data/Vote.pm
+++ b/t/lib/t/MusicBrainz/Server/Data/Vote.pm
@@ -74,10 +74,10 @@ is(scalar @{ $email_transport->deliveries }, 1);
my $email = $email_transport->deliveries->[-1]->{email};
is($email->get_header('Subject'), 'Someone has voted against your edit #2', 'Subject explains someone has voted against your edit');
-is($email->get_header('References'), sprintf '<edit-%d@%s>', $edit->id, &DBDefs::WEB_SERVER_USED_IN_EMAIL, 'References header contains edit id');
+is($email->get_header('References'), sprintf '<edit-%d@%s>', $edit->id, DBDefs->WEB_SERVER_USED_IN_EMAIL, 'References header contains edit id');
is($email->get_header('To'), '"editor1" <[email protected]>', 'To header contains editor email');
-my $server = DBDefs::WEB_SERVER_USED_IN_EMAIL;
+my $server = DBDefs->WEB_SERVER_USED_IN_EMAIL;
like($email->get_body, qr{http://$server/edit/${\ $edit->id }}, 'body contains link to edit');
like($email->get_body, qr{'editor2'}, 'body mentions editor2');
diff --git a/t/lib/t/MusicBrainz/Server/Edit/Relationship/Create.pm b/t/lib/t/MusicBrainz/Server/Edit/Relationship/Create.pm
index 3b270c9..a76b163 100644
--- a/t/lib/t/MusicBrainz/Server/Edit/Relationship/Create.pm
+++ b/t/lib/t/MusicBrainz/Server/Edit/Relationship/Create.pm
@@ -71,7 +71,7 @@ subtest 'creating cover art relationships should update the releases coverart' =
};
subtest 'creating asin relationships should update the releases coverart' => sub {
- if (DBDefs::AWS_PUBLIC && DBDefs::AWS_PRIVATE)
+ if (DBDefs->AWS_PUBLIC && DBDefs->AWS_PRIVATE)
{
my $e0 = $c->model('Release')->get_by_id(2);
my $edit = $c->model('Edit')->create(
diff --git a/t/lib/t/MusicBrainz/Server/Email.pm b/t/lib/t/MusicBrainz/Server/Email.pm
index a52d84e..0817bd6 100644
--- a/t/lib/t/MusicBrainz/Server/Email.pm
+++ b/t/lib/t/MusicBrainz/Server/Email.pm
@@ -47,7 +47,7 @@ test all => sub {
is($e->get_header('BCC'), undef, 'BCC is undefined');
is($e->get_header('Subject'), 'Hey', 'Subject is Hey');
like($e->get_header('Message-Id'), qr{<correspondence-4444-8888-\d+@.*>}, "Message-Id has right format");
- is($e->get_header('References'), sprintf('<correspondence-%s-%s@%s>', $user1->id, $user2->id, &DBDefs::WEB_SERVER_USED_IN_EMAIL), 'References correct correspondence');
+ is($e->get_header('References'), sprintf('<correspondence-%s-%s@%s>', $user1->id, $user2->id, DBDefs->WEB_SERVER_USED_IN_EMAIL), 'References correct correspondence');
compare_body($e->get_body,
"MusicBrainz user 'Editor 1' has sent you the following message:\n".
"------------------------------------------------------------------------\n".
@@ -75,7 +75,7 @@ test all => sub {
is($e->get_header('BCC'), undef, 'BCC is undefined');
is($e->get_header('Subject'), 'Hey', 'Subject is Hey');
like($e->get_header('Message-Id'), qr{<correspondence-4444-8888-\d+@.*>}, "Message-Id has right format");
- is($e->get_header('References'), sprintf('<correspondence-%s-%s@%s>', $user1->id, $user2->id, &DBDefs::WEB_SERVER_USED_IN_EMAIL), 'References correct correspondence');
+ is($e->get_header('References'), sprintf('<correspondence-%s-%s@%s>', $user1->id, $user2->id, DBDefs->WEB_SERVER_USED_IN_EMAIL), 'References correct correspondence');
compare_body($e->get_body,
"MusicBrainz user 'Editor 1' has sent you the following message:\n".
"------------------------------------------------------------------------\n".
@@ -198,7 +198,7 @@ test all => sub {
is($e->get_header('From'), 'MusicBrainz Server <[email protected]>', 'From is noreply@...');
is($e->get_header('To'), '"Editor 1" <[email protected]>', 'To is Editor 1, [email protected]');
is($e->get_header('Reply-To'), 'MusicBrainz <[email protected]>', 'Reply-To is support@...');
- is($e->get_header('References'), sprintf('<edit-1234@%s>', &DBDefs::WEB_SERVER_USED_IN_EMAIL) , 'References edit-1234');
+ is($e->get_header('References'), sprintf('<edit-1234@%s>', DBDefs->WEB_SERVER_USED_IN_EMAIL) , 'References edit-1234');
like($e->get_header('Message-Id'), qr{<edit-1234-8888-no-vote-\d+@.*>} , 'Message ID has right format');
is($e->get_header('Subject'), 'Someone has voted against your edit #1234', 'Subject is Someone has voted against...');
compare_body($e->get_body,
@@ -233,7 +233,7 @@ test all => sub {
is($e->get_header('From'), '"Editor 2" <"Editor 2"@users.musicbrainz.org>', 'From is Editor 2, @users.musicbrainz.org');
is($e->get_header('To'), '"Editor 1" <[email protected]>', 'To is Editor 1, [email protected]');
is($e->get_header('Subject'), 'Note added to edit #1234', 'Subject is Note added to edit #1234');
- is($e->get_header('References'), sprintf('<edit-1234@%s>', &DBDefs::WEB_SERVER_USED_IN_EMAIL) , 'References edit-1234');
+ is($e->get_header('References'), sprintf('<edit-1234@%s>', DBDefs->WEB_SERVER_USED_IN_EMAIL) , 'References edit-1234');
like($e->get_header('Message-Id'), qr{<edit-1234-8888-edit-note-\d+@.*>} , 'Message ID has right format');
is($e->get_header('Sender'), 'MusicBrainz Server <[email protected]>', 'Sender is noreply@...');
compare_body($e->get_body,
diff --git a/t/lib/t/MusicBrainz/Server/Email/Subscriptions.pm b/t/lib/t/MusicBrainz/Server/Email/Subscriptions.pm
index cb88184..0e25e3f 100644
--- a/t/lib/t/MusicBrainz/Server/Email/Subscriptions.pm
+++ b/t/lib/t/MusicBrainz/Server/Email/Subscriptions.pm
@@ -27,7 +27,7 @@ test all => sub {
ok((grep {"$_" eq 'Message-Id' } $email->extra_headers), 'Has a message-id header');
- my $server = sprintf 'http://%s', DBDefs::WEB_SERVER_USED_IN_EMAIL;
+ my $server = sprintf 'http://%s', DBDefs->WEB_SERVER_USED_IN_EMAIL;
my $expected = "$server/user/%E3%83%8B%E3%83%83%E3%82%AD%E3%83%BC/subscriptions";
contains_string($text, $expected, 'Correctly escaped editor name');
commit a37e9c8c2b40a729c17ebae91984a6209416974d
Author: Ian McEwen <[email protected]>
Date: Mon Aug 20 15:48:58 2012 -0700
Make a basic DBDefs::Default file
diff --git a/lib/DBDefs/Default.pm b/lib/DBDefs/Default.pm
new file mode 100644
index 0000000..3caddf1
--- /dev/null
+++ b/lib/DBDefs/Default.pm
@@ -0,0 +1,423 @@
+#!/usr/bin/env perl
+
+use warnings;
+# vi: set ts=4 sw=4 :
+#____________________________________________________________________________
+#
+# MusicBrainz -- the open internet music database
+#
+# Copyright (C) 1998 Robert Kaye
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+# $Id$
+#____________________________________________________________________________
+
+package DBDefs::Default;
+
+################################################################################
+# Directories
+################################################################################
+
+# The server root, i.e. the parent directory of admin, bin, lib, root, etc.
+sub MB_SERVER_ROOT { "/home/httpd/musicbrainz/musicbrainz-server" }
+# Where static files are located
+sub STATIC_FILES_DIR { MB_SERVER_ROOT . '/root/static' }
+
+################################################################################
+# The Database
+################################################################################
+
+use MusicBrainz::Server::DatabaseConnectionFactory;
+MusicBrainz::Server::DatabaseConnectionFactory->register_databases(
+ # How to connect when we need read-write access to the database
+ READWRITE => {
+ database => "musicbrainz_db",
+ schema => "musicbrainz",
+ username => "musicbrainz",
+ password => "musicbrainz",
+# host => "",
+# port => "",
+ },
+ # How to connect to a test database
+ TEST => {
+ database => "musicbrainz_test",
+ schema => "musicbrainz",
+ username => "musicbrainz",
+ password => "musicbrainz",
+# host => "",
+# port => "",
+ },
+ # How to connect for read-only access. See "REPLICATION_TYPE" (below)
+ # READONLY => undef,
+ # How to connect for administrative access
+ SYSTEM => {
+ database => "template1",
+ username => "postgres",
+# password => "",
+# host => "",
+# port => "",
+ },
+ # Fill out only if RAWDATA lives on a different host from the READWRITE server.
+ # RAWDATA_SYSTEM => undef,
+);
+
+# The schema sequence number. Must match the value in
+# replication_control.current_schema_sequence.
+sub DB_SCHEMA_SEQUENCE { 15 }
+
+# What type of server is this?
+# * RT_MASTER - This is a master replication server. Changes are allowed, and
+# they result in replication packets being produced.
+# * RT_SLAVE - This is a slave replication server. After loading a snapshot
+# produced by a master, the only changes allowed are those made
+# by applying the next replication packet in turn. If the slave
+# server is not going to be used for development work, change
+# DB_STAGING_SERVER to 0.
+# * RT_STANDALONE - This server neither generates nor uses replication
+# packets. Changes to the database are allowed.
+use MusicBrainz::Server::Replication ':replication_type';
+sub REPLICATION_TYPE { RT_STANDALONE }
+
+################################################################################
+# HTTP Server Names
+################################################################################
+
+# The host names used by the server.
+# To use a port number other than 80, add it like so: "myhost:8000"
+sub WEB_SERVER { "www.musicbrainz.example.com" }
+sub LUCENE_SERVER { "search.musicbrainz.org" }
+sub WEB_SERVER_USED_IN_EMAIL { WEB_SERVER }
+
+################################################################################
+# Mail Settings
+################################################################################
+
+sub SMTP_SERVER { "localhost" }
+
+# This value should be set to some secret value for your server. Any old
+# string of stuff should do; something suitably long and random, like for
+# passwords. However you MUST change it from the default
+# value (the empty string). This is so an attacker can't just look in CVS and
+# see the default secret value, and then use it to attack your server.
+sub SMTP_SECRET_CHECKSUM { "" }
+sub EMAIL_VERIFICATION_TIMEOUT { 604800 } # one week
+
+################################################################################
+# Server Settings
+################################################################################
+
+# Set this to 0 if this is the master MusicBrainz server or a slave mirror.
+# Keeping this defined enables the banner that is shown across the top of each
+# page, as well as some testing features that are only enabled when not on
+# the live server.
+sub DB_STAGING_SERVER { 1 }
+
+# This description is shown in the banner when DB_STAGING_SERVER is enabled.
+# If left undefined the default value will be shown.
+# Default: "This is a MusicBrainz development server."
+sub DB_STAGING_SERVER_DESCRIPTION { "" }
+
+# Only change this if running a non-sanitized database on a dev server,
+# e.g. http://test.musicbrainz.org.
+sub DB_STAGING_SERVER_SANITIZED { 1 }
+
+# Testing features enable "Accept edit" and "Reject edit" links on edits,
+# this should only be enabled on staging servers. Also, this enables non-admin
+# users to edit user permissions.
+sub DB_STAGING_TESTING_FEATURES { DB_STAGING_SERVER }
+
+################################################################################
+# Documentation Server Settings
+################################################################################
+sub WIKITRANS_SERVER { "wiki.musicbrainz.org" }
+
+# The path to MediaWiki's api.php file. This is required to automatically
+# determine which documentation pages need to be updated in the
+# transclusion table.
+sub WIKITRANS_SERVER_API { "wiki.musicbrainz.org/-/api.php" }
+
+sub WIKITRANS_INDEX_FILE { MB_SERVER_ROOT() . "/root/static/wikidocs/index.txt" }
+sub WIKITRANS_INDEX_URL { "http://musicbrainz.org/static/wikidocs/index.txt" }
+
+# To enable documentation search on your server, create your own Google Custom
+# Search engine and enter its ID as the value of GOOGLE_CUSTOM_SEARCH.
+# Alternatively, if you're okay with the search results pointing to
+# the musicbrainz.org server, you can use '006539527923176875863:xsv3chs2ovc'.
+sub GOOGLE_CUSTOM_SEARCH { '' }
+
+################################################################################
+# Cache Settings
+################################################################################
+
+# MEMCACHED_SERVERS allows configuration of global memcached servers, if more
+# close configuration is not required
+sub MEMCACHED_SERVERS { return ['127.0.0.1:11211']; };
+
+# MEMCACHED_NAMESPACE allows configuration of a global memcached namespace, if
+# more close configuration is not required
+sub MEMCACHED_NAMESPACE { return 'MB:'; };
+
+# PLUGIN_CACHE_OPTIONS are the options configured for Plugin::Cache. $c->cache
+# is provided by Plugin::Cache, and is required for HTTP Digest authentication
+# in the webservice (Catalyst::Authentication::Credential::HTTP).
+#
+# Using Cache::Memory is good for a development environment, but is likely not
+# suited for production. Use something like memcached in a production setup.
+#
+# If you want to use something such as Memcached, the settings here should be
+# the same as the settings you use for the session store.
+#
+sub PLUGIN_CACHE_OPTIONS {
+ return {
+# class => "Cache::Memory",
+ class => "Cache::Memcached::Fast",
+ servers => MEMCACHED_SERVERS(),
+ namespace => MEMCACHED_NAMESPACE(),
+ };
+};
+
+# Use memcached and a small in-memory cache, see below if you
+# want to disable caching
+#
+# The caching options here relate to object caching - such as caching artists,
+# releases, etc in order to speed up queries. If you are using Memcached
+# to store sessions as well this should be a *different* memcached server.
+our %CACHE_MANAGER_OPTIONS = (
+ profiles => {
+ memory => {
+ class => 'Cache::Memory',
+ wrapped => 1,
+ keys => [qw( at g c lng lt mf rgt rs rp scr wt )],
+ options => {
+ default_expires => '1 hour',
+ },
+ },
+ external => {
+ class => 'Cache::Memcached::Fast',
+ options => {
+ servers => MEMCACHED_SERVERS(),
+ namespace => MEMCACHED_NAMESPACE()
+ },
+ },
+ },
+ default_profile => 'external',
+);
+
+# No caching
+#our %CACHE_MANAGER_OPTIONS = (
+# profiles => {
+# null => {
+# class => 'Cache::Null',
+# wrapped => 1,
+# },
+# },
+# default_profile => 'null',
+#);
+
+sub CACHE_MANAGER_OPTIONS { \%CACHE_MANAGER_OPTIONS }
+
+################################################################################
+# Rate-Limiting
+################################################################################
+
+# The "host:port" of the ratelimit server ($MB_SERVER/bin/ratelimit-server).
+# If undef, the rate-limit code always returns undef (as it does if there is
+# an error).
+# Just like the memcached server settings, there is NO SECURITY built into the
+# ratelimit protocol, so be careful about enabling it.
+sub RATELIMIT_SERVER { undef }
+
+################################################################################
+# Minify settings
+################################################################################
+
+# The following two values determine how scripts and styles are minified. By
+# default, a dummy minifier is used:
+sub MINIFY_DUMMY { my %args = @_; return $args{input}; }
+sub MINIFY_SCRIPTS { return \&MINIFY_DUMMY; }
+sub MINIFY_STYLES { return \&MINIFY_DUMMY; }
+
+# If you wish to minify either javascript or css, uncomment the following lines
+# and install the neccesary CPAN packages.
+# sub MINIFY_SCRIPTS { use Javascript::Closure; return \&Javascript::Closure::minify }
+# sub MINIFY_STYLES { use CSS::Minifier; return \&CSS::Minifier::minify }
+
+################################################################################
+# Other Settings
+################################################################################
+
+# Set this value to something true (e.g. 1) to set the server to read-only.
+# To date, this option is widely ignored in the code; don't be surprised if you
+# set it to true and find that writes are still possible.
+sub DB_READ_ONLY { 0 }
+
+# Set this value to a message that you'd like to display to users when
+# they attempt to write to your read-only database (not used if DB_READ_ONLY
+# is false)
+sub DB_READ_ONLY_MESSAGE { <<EOF }
+This server is temporarily in read-only mode
+for database maintainance.
+EOF
+
+# Development server feature.
+# Used to display which git branch is currently running along with information
+# about the last commit
+sub GIT_BRANCH
+{
+ if (DB_STAGING_SERVER) {
+ my $branch = `git branch --no-color 2> /dev/null | sed -e '/^[^*]/d'`;
+ $branch =~ s/\* (.+)/$1/;
+ my $sha = `git log -1 --format=format:"%h"`;
+ my $msg = `git log -1 --format=format:"Last commit by %an on %ad%n%s" --date=short`;
+ return $branch, $sha, $msg;
+ }
+}
+
+# How long (in seconds) a web/rdf session can go "idle" before being timed out
+sub WEB_SESSION_SECONDS_TO_LIVE { 3600 * 3 }
+
+# The cookie name to use
+sub SESSION_COOKIE { "AF_SID" }
+# The domain into which the session cookie is written
+sub SESSION_DOMAIN { undef }
+
+# How long an annotation is considered as being locked.
+sub ANNOTATION_LOCK_TIME { 60*15 }
+
+# Amazon associate and developer ids
+my %amazon_store_associate_ids = (
+ 'amazon.ca' => 'musicbrainz01-20',
+ 'amazon.co.jp' => 'musicbrainz-22',
+ 'amazon.co.uk' => 'musicbrainz0c-21',
+ 'amazon.com' => 'musicbrainz0d-20',
+ 'amazon.de' => 'musicbrainz00-21',
+ 'amazon.fr' => 'musicbrainz0e-21',
+ 'amazon.it' => '', #TODO: Someone should probably sign up for an associate ID.
+);
+
+sub AWS_ASSOCIATE_ID
+{
+ return keys %amazon_store_associate_ids if not @_;
+ return $amazon_store_associate_ids{$_[0]};
+}
+
+sub AWS_PRIVATE { '' }
+sub AWS_PUBLIC { '' }
+
+sub AMAZON_ASSOCIATE_TAG { '' }
+
+# To enable use of reCAPTCHA:
+# 1. make sure $ENV{'REMOTE_ADDR'} is the ip address of the visitor.
+# 2. replace undef with your recaptcha keys:
+sub RECAPTCHA_PUBLIC_KEY { return undef }
+sub RECAPTCHA_PRIVATE_KEY { return undef }
+
+# internet archive private/public keys (for coverartarchive.org).
+sub COVER_ART_ARCHIVE_ID { };
+sub COVER_ART_ARCHIVE_KEY { };
+sub COVER_ART_ARCHIVE_UPLOAD_PREFIXER { sprintf("http://%s.s3.us.archive.org/", shift) };
+sub COVER_ART_ARCHIVE_DOWNLOAD_PREFIX { "http://coverartarchive.org" };
+
+# Add a Google Analytics tracking code to enable Google Analytics tracking.
+sub GOOGLE_ANALYTICS_CODE { '' }
+
+################################################################################
+# Sessions (advanced)
+################################################################################
+
+# Unless you are installing an MusicBrainz server that needs to be fully r
+# redundant/load balanced, you do not need to change anything in this section.
+
+# If you're using multiple front-end webservers make sure they all connect to
+# the same memcached server. Also make sure enough memory is configured for
+# memcached so sessions aren't evicted from the cache.
+sub SESSION_STORE { "Session::Store::Memcached" }
+sub SESSION_STORE_ARGS
+{
+ return {
+ memcached_new_args => {
+ data => MEMCACHED_SERVERS(),
+ namespace => MEMCACHED_NAMESPACE(),
+ memcached_class => 'Cache::Memcached::Fast',
+ }
+ }
+}
+
+# MusicBrainz::Server::Wizard saves wizard sessions in memcached,
+# seperately from the regular session store.
+sub WIZARD_MEMCACHED
+{
+ return { servers => MEMCACHED_SERVERS(), namespace => MEMCACHED_NAMESPACE() };
+}
+
+sub USE_ETAGS { 1 }
+
+sub CATALYST_DEBUG { 1 }
+
+# If you are developing on MusicBrainz, you should set this to a true value
+# This will turn off some optimizations (such as CSS/JS compression) to make
+# developing and debuging easier
+sub DEVELOPMENT_SERVER { 1 }
+
+# Please activate the officially approved languages here. Not every .po
+# file is active because we might have fully translated languages which
+# are not yet properly supported, like right-to-left languages
+sub MB_LANGUAGES {qw()}
+
+# Private, please do not change
+sub _RUNNING_TESTS { 0 }
+
+# Set this to an email address and the server will email any bugs to you
+sub EMAIL_BUGS { undef }
+
+################################################################################
+# Profiling
+################################################################################
+# Set these to >0 to enable profiling
+
+# Log if a request in /ws takes more than x seconds
+sub PROFILE_WEB_SERVICE { 0 }
+
+# Log if a request in / (not /ws) takes more than x seconds
+sub PROFILE_SITE { 0 }
+
+# If you want the FastCGI processes to restart, configure this
+sub AUTO_RESTART {
+# return {
+# active => 1,
+# check_each => 10,
+# max_bits => 134217728,
+# min_handled_requests => 100
+# }
+}
+
+# The maximum amount of time a process can be serving a single request
+# If undef, the process is never killed
+# If set to a positive integer, the process can server a single request
+# for MAX_REQUEST_TIME seconds, and if it is still not done the process
+# will be killed (and log a message about the request it was serving).
+sub MAX_REQUEST_TIME { undef }
+
+sub LOGGER_ARGUMENTS {
+ return (
+ outputs => [
+ [ 'Screen', min_level => 'debug', newline => 1 ],
+ ],
+ )
+}
+
+1;
+# eof DBDefs.pm
-----------------------------------------------------------------------
hooks/post-receive
--
mb_server