Skip to content
Browse files

(Bug 4631) Put "require ljlib.pl" in scripts in a BEGIN block

This is to ensure that ljlib.pl is loaded at compile-time, rather than
at runtime, so that scripts / workers (things not running in a web
server) don't break unexpectedly because of ordering issues.
  • Loading branch information...
1 parent 85ed163 commit 8928be806f157c03e55df2ff6e6e609dd541d314 @afuna afuna committed Sep 4, 2012
Showing with 172 additions and 65 deletions.
  1. +3 −1 bin/create-account
  2. +4 −1 bin/deleteusers.pl
  3. +3 −1 bin/dev/entrydump.pl
  4. +3 −1 bin/dumpsql.pl
  5. +3 −1 bin/get-users-for-paid-accounts.pl
  6. +4 −3 bin/incoming-mail-inject.pl
  7. +3 −1 bin/ljmaint.pl
  8. +3 −1 bin/ljsysban.pl
  9. +3 −4 bin/logsummarize.pl
  10. +3 −1 bin/misc/dump-poll.pl
  11. +4 −2 bin/qbufferd.pl
  12. +3 −1 bin/renameuser.pl
  13. +3 −1 bin/schedule-copier-jobs
  14. +3 −1 bin/truncate-cluster.pl
  15. +3 −1 bin/update-tor-exits
  16. +3 −1 bin/upgrading/compress_cluster.pl
  17. +3 −1 bin/upgrading/import-includes.pl
  18. +3 −1 bin/upgrading/make_system.pl
  19. +3 −1 bin/upgrading/migrate-userpics.pl
  20. +3 −1 bin/upgrading/migrate-userprop.pl
  21. +3 −1 bin/upgrading/populate-next-birthdays
  22. +3 −1 bin/upgrading/truncate_cluster.pl
  23. +3 −1 bin/worker/content-importer
  24. +3 −1 bin/worker/content-importer-lite
  25. +3 −1 bin/worker/content-importer-verify
  26. +3 −1 bin/worker/esn-cluster-subs
  27. +3 −1 bin/worker/esn-cluster-subs-mass
  28. +3 −1 bin/worker/esn-filter-subs
  29. +3 −1 bin/worker/esn-filter-subs-mass
  30. +3 −1 bin/worker/esn-fired-event
  31. +3 −1 bin/worker/esn-fired-event-mass
  32. +3 −1 bin/worker/esn-process-sub
  33. +3 −1 bin/worker/esn-process-sub-mass
  34. +3 −1 bin/worker/import-scheduler
  35. +3 −2 bin/worker/incoming-email
  36. +3 −2 bin/worker/latest-feed
  37. +3 −1 bin/worker/lazy-cleanup
  38. +3 −1 bin/worker/paidstatus
  39. +3 −1 bin/worker/ping-hubbub
  40. +3 −1 bin/worker/process-esn
  41. +3 −1 bin/worker/process-esn-mass
  42. +3 −1 bin/worker/process-eventlogrecord
  43. +3 −1 bin/worker/resolve-extacct
  44. +3 −1 bin/worker/schedule-synsuck
  45. +3 −1 bin/worker/search-constraints
  46. +3 −1 bin/worker/search-lookup
  47. +3 −1 bin/worker/search-updater
  48. +3 −1 bin/worker/shop-creditcard-charge
  49. +3 −1 bin/worker/spellcheck-gm
  50. +3 −1 bin/worker/sphinx-search-gm
  51. +3 −1 bin/worker/subscribe-hubbub
  52. +3 −1 bin/worker/support-notify
  53. +3 −1 bin/worker/sysban-gm
  54. +3 −1 bin/worker/taglib-gm
  55. +4 −2 bin/worker/talklib-gm
  56. +3 −1 bin/worker/userpic-resize-gm
View
4 bin/create-account
@@ -15,7 +15,9 @@
use strict;
use lib "$ENV{LJHOME}/cgi-bin";
-require 'ljlib.pl';
+BEGIN {
+ require 'ljlib.pl';
+}
use Getopt::Long;
View
5 bin/deleteusers.pl
@@ -15,7 +15,10 @@
use strict;
-require "$ENV{'LJHOME'}/cgi-bin/ljlib.pl";
+BEGIN {
+ require "$ENV{'LJHOME'}/cgi-bin/ljlib.pl";
+}
+
my $dbh = LJ::get_dbh("master");
$dbh->{'RaiseError'} = 1;
$dbh->{'PrintError'} = 1;
View
4 bin/dev/entrydump.pl
@@ -15,7 +15,9 @@
use strict;
use lib "$ENV{LJHOME}/cgi-bin";
-require 'ljlib.pl';
+BEGIN {
+ require 'ljlib.pl';
+}
use LJ::Entry;
my $url = shift;
View
4 bin/dumpsql.pl
@@ -14,7 +14,9 @@
# part of this distribution.
use strict;
-require "$ENV{'LJHOME'}/cgi-bin/ljlib.pl";
+BEGIN {
+ require "$ENV{'LJHOME'}/cgi-bin/ljlib.pl";
+}
my $dbh = LJ::get_db_writer();
View
4 bin/get-users-for-paid-accounts.pl
@@ -17,7 +17,9 @@
use strict;
use warnings;
use lib "$ENV{'LJHOME'}/cgi-bin";
-require "ljlib.pl";
+BEGIN {
+ require "ljlib.pl";
+}
use LJ::Sysban;
use DW::Pay;
use List::Util qw( min );
View
7 bin/incoming-mail-inject.pl
@@ -17,10 +17,11 @@
use warnings;
BEGIN {
$ENV{LJHOME} ||= "/home/lj";
+ use lib "$ENV{LJHOME}/cgi-bin";
+ use lib "$ENV{LJHOME}/extlib/lib/perl5";
+ require "$ENV{LJHOME}/cgi-bin/ljlib.pl";
}
-use lib "$ENV{LJHOME}/cgi-bin";
-use lib "$ENV{LJHOME}/extlib/lib/perl5";
-require "$ENV{LJHOME}/cgi-bin/ljlib.pl";
+
use Class::Autouse qw(
LJ::IncomingEmailHandle
);
View
4 bin/ljmaint.pl
@@ -21,7 +21,9 @@
die "\$LJHOME not set.\n";
}
-require "$ENV{'LJHOME'}/cgi-bin/ljlib.pl";
+BEGIN {
+ require "$ENV{'LJHOME'}/cgi-bin/ljlib.pl";
+}
unless ( LJ::is_enabled('ljmaint_tasks') ) {
print "ljmaint.pl tasks disabled, exiting\n";
View
4 bin/ljsysban.pl
@@ -55,7 +55,9 @@
}
# now load in the beast
-require "$ENV{'LJHOME'}/cgi-bin/ljlib.pl";
+BEGIN {
+ require "$ENV{'LJHOME'}/cgi-bin/ljlib.pl";
+}
use LJ::Sysban;
my $dbh = LJ::get_db_writer();
View
7 bin/logsummarize.pl
@@ -15,12 +15,11 @@
use strict;
-unless (-d $ENV{'LJHOME'}) {
- die "\$LJHOME not set.\n";
+BEGIN {
+ die "\$LJHOME not set.\n" unless ( -d $ENV{'LJHOME'} );
+ require "$ENV{'LJHOME'}/cgi-bin/ljlib.pl";
}
-require "$ENV{'LJHOME'}/cgi-bin/ljlib.pl";
-
my $db = LJ::get_dbh("logs");
unless ($db) {
die "No 'logs' db handle found.\n";
View
4 bin/misc/dump-poll.pl
@@ -21,7 +21,9 @@
use strict;
use warnings;
use lib "$ENV{'LJHOME'}/cgi-bin";
-require "$ENV{'LJHOME'}/cgi-bin/ljlib.pl";
+BEGIN {
+ require "$ENV{'LJHOME'}/cgi-bin/ljlib.pl";
+}
use LJ::Poll;
my $id = $ARGV[0] or die "Usage: $0 <poll_id>";
View
6 bin/qbufferd.pl
@@ -14,9 +14,11 @@
# part of this distribution.
use strict;
-use Getopt::Long
+use Getopt::Long;
use lib "$ENV{LJHOME}/cgi-bin";
-require "$ENV{'LJHOME'}/cgi-bin/ljlib.pl";
+BEGIN {
+ require "$ENV{'LJHOME'}/cgi-bin/ljlib.pl";
+}
use LJ::Support;
use LJ::Cmdbuffer;
View
4 bin/renameuser.pl
@@ -16,7 +16,9 @@
use strict;
use Getopt::Long;
-require "$ENV{'LJHOME'}/cgi-bin/ljlib.pl";
+BEGIN {
+ require "$ENV{'LJHOME'}/cgi-bin/ljlib.pl";
+}
sub usage {
die "Usage: [--swap --force] <from_user> <to_user>\n";
View
4 bin/schedule-copier-jobs
@@ -18,7 +18,9 @@
use strict;
use lib "$ENV{LJHOME}/cgi-bin";
-require 'ljlib.pl';
+BEGIN {
+ require 'ljlib.pl';
+}
die "Need to have Sphinx search enabled.\n"
unless @LJ::SPHINX_SEARCHD;
View
4 bin/truncate-cluster.pl
@@ -14,7 +14,9 @@
# part of this distribution.
use strict;
-require "$ENV{LJHOME}/cgi-bin/ljlib.pl";
+BEGIN {
+ require "$ENV{LJHOME}/cgi-bin/ljlib.pl";
+}
my $cid = shift;
die "Usage: truncate-cluster.pl <clusterid>\n" unless $cid =~ /^\d+$/;
View
4 bin/update-tor-exits
@@ -18,7 +18,9 @@
use strict;
use lib "$ENV{LJHOME}/cgi-bin";
-require 'ljlib.pl';
+BEGIN {
+ require 'ljlib.pl';
+}
die "\$LJ::USE_TOR_CONFIGS is disabled.\n" unless $LJ::USE_TOR_CONFIGS;
die "\$LJ::EXTERNAL_IP is not set.\n" unless $LJ::EXTERNAL_IP;
View
4 bin/upgrading/compress_cluster.pl
@@ -19,7 +19,9 @@
unless $clusterid;
# load libraries now
-require "$ENV{'LJHOME'}/cgi-bin/ljlib.pl";
+BEGIN {
+ require "$ENV{'LJHOME'}/cgi-bin/ljlib.pl";
+}
# force this option on, since that's the point of the tool
$LJ::COMPRESS_TEXT = 1;
View
4 bin/upgrading/import-includes.pl
@@ -19,7 +19,9 @@
# on disk is newer than the one in the database.
use strict;
-require "$ENV{'LJHOME'}/cgi-bin/ljlib.pl";
+BEGIN {
+ require "$ENV{'LJHOME'}/cgi-bin/ljlib.pl";
+}
# create list of files to check
my $dir = "$ENV{'LJHOME'}/htdocs/inc";
View
4 bin/upgrading/make_system.pl
@@ -15,7 +15,9 @@
use strict;
use lib "$ENV{LJHOME}/cgi-bin";
-require "$ENV{LJHOME}/cgi-bin/ljlib.pl";
+BEGIN {
+ require "$ENV{LJHOME}/cgi-bin/ljlib.pl";
+}
my $dbh = LJ::get_dbh("master");
View
4 bin/upgrading/migrate-userpics.pl
@@ -14,7 +14,9 @@
use strict;
use lib "$ENV{LJHOME}/cgi-bin";
-require 'ljlib.pl';
+BEGIN {
+ require 'ljlib.pl';
+}
use LJ::User;
use Getopt::Long;
use IPC::Open3;
View
4 bin/upgrading/migrate-userprop.pl
@@ -14,7 +14,9 @@
use strict;
use lib "$ENV{'LJHOME'}/cgi-bin";
-require 'ljlib.pl';
+BEGIN {
+ require 'ljlib.pl';
+}
# so output happens quickly
$| = 1;
View
4 bin/upgrading/populate-next-birthdays
@@ -13,7 +13,9 @@
# part of this distribution.
use strict;
-require "$ENV{'LJHOME'}/cgi-bin/ljlib.pl";
+BEGIN {
+ require "$ENV{'LJHOME'}/cgi-bin/ljlib.pl";
+}
my $dbslo = LJ::get_dbh("slow")
or die "cannot connect to slow role";
View
4 bin/upgrading/truncate_cluster.pl
@@ -19,7 +19,9 @@
unless $clusterid;
# load libraries now
-require "$ENV{'LJHOME'}/cgi-bin/ljlib.pl";
+BEGIN {
+ require "$ENV{'LJHOME'}/cgi-bin/ljlib.pl";
+}
# force this option on, since that's the point of the tool
$LJ::COMPRESS_TEXT = 1;
View
4 bin/worker/content-importer
@@ -17,7 +17,9 @@
use strict;
use lib "$ENV{LJHOME}/cgi-bin";
-require 'ljlib.pl';
+BEGIN {
+ require 'ljlib.pl';
+}
$LJ::LOG_GTOP = 1;
View
4 bin/worker/content-importer-lite
@@ -20,7 +20,9 @@
use strict;
use lib "$ENV{LJHOME}/cgi-bin";
-require 'ljlib.pl';
+BEGIN {
+ require 'ljlib.pl';
+}
use LJ::Worker::TheSchwartz;
use DW::Worker::ContentImporter::LiveJournal::Bio;
View
4 bin/worker/content-importer-verify
@@ -20,7 +20,9 @@
use strict;
use lib "$ENV{LJHOME}/cgi-bin";
-require 'ljlib.pl';
+BEGIN {
+ require 'ljlib.pl';
+}
use LJ::Worker::TheSchwartz;
use DW::Worker::ContentImporter::LiveJournal::Verify;
View
4 bin/worker/esn-cluster-subs
@@ -14,7 +14,9 @@
use strict;
use lib "$ENV{LJHOME}/cgi-bin";
-require 'ljlib.pl';
+BEGIN {
+ require 'ljlib.pl';
+}
use LJ::Protocol;
use LJ::Lang;
use LJ::Worker::TheSchwartz;
View
4 bin/worker/esn-cluster-subs-mass
@@ -14,7 +14,9 @@
use strict;
use lib "$ENV{LJHOME}/cgi-bin";
-require 'ljlib.pl';
+BEGIN {
+ require 'ljlib.pl';
+}
use LJ::Protocol;
use LJ::Lang;
use LJ::Worker::TheSchwartz;
View
4 bin/worker/esn-filter-subs
@@ -14,7 +14,9 @@
use strict;
use lib "$ENV{LJHOME}/cgi-bin";
-require 'ljlib.pl';
+BEGIN {
+ require 'ljlib.pl';
+}
use LJ::Protocol;
use LJ::Lang;
use LJ::Worker::TheSchwartz;
View
4 bin/worker/esn-filter-subs-mass
@@ -14,7 +14,9 @@
use strict;
use lib "$ENV{LJHOME}/cgi-bin";
-require 'ljlib.pl';
+BEGIN {
+ require 'ljlib.pl';
+}
use LJ::Protocol;
use LJ::Lang;
use LJ::Worker::TheSchwartz;
View
4 bin/worker/esn-fired-event
@@ -14,7 +14,9 @@
use strict;
use lib "$ENV{LJHOME}/cgi-bin";
-require 'ljlib.pl';
+BEGIN {
+ require 'ljlib.pl';
+}
use LJ::Protocol;
use LJ::Lang;
use LJ::Worker::TheSchwartz;
View
4 bin/worker/esn-fired-event-mass
@@ -14,7 +14,9 @@
use strict;
use lib "$ENV{LJHOME}/cgi-bin";
-require 'ljlib.pl';
+BEGIN {
+ require 'ljlib.pl';
+}
use LJ::Protocol;
use LJ::Lang;
use LJ::Worker::TheSchwartz;
View
4 bin/worker/esn-process-sub
@@ -14,7 +14,9 @@
use strict;
use lib "$ENV{LJHOME}/cgi-bin";
-require 'ljlib.pl';
+BEGIN {
+ require 'ljlib.pl';
+}
use LJ::Protocol;
use LJ::Lang;
use LJ::Worker::TheSchwartz;
View
4 bin/worker/esn-process-sub-mass
@@ -14,7 +14,9 @@
use strict;
use lib "$ENV{LJHOME}/cgi-bin";
-require 'ljlib.pl';
+BEGIN {
+ require 'ljlib.pl';
+}
use LJ::Protocol;
use LJ::Lang;
use LJ::Worker::TheSchwartz;
View
4 bin/worker/import-scheduler
@@ -17,7 +17,9 @@
use strict;
use lib "$ENV{LJHOME}/cgi-bin";
-require 'ljlib.pl';
+BEGIN {
+ require 'ljlib.pl';
+}
use Time::HiRes qw/ gettimeofday tv_interval /;
use Getopt::Long;
View
5 bin/worker/incoming-email
@@ -15,8 +15,9 @@
use strict;
use lib "$ENV{LJHOME}/cgi-bin";
use LJ::Worker::TheSchwartz;
-
-require "ljlib.pl";
+BEGIN {
+ require "ljlib.pl";
+}
use LJ::Emailpost;
use LJ::Support;
use LJ::Sysban;
View
5 bin/worker/latest-feed
@@ -16,8 +16,9 @@
use strict;
use lib "$ENV{LJHOME}/cgi-bin";
-
-require 'ljlib.pl';
+BEGIN {
+ require 'ljlib.pl';
+}
use LJ::Worker::TheSchwartz;
use DW::Worker::LatestFeed;
View
4 bin/worker/lazy-cleanup
@@ -14,7 +14,9 @@
use strict;
use lib "$ENV{LJHOME}/cgi-bin";
-require 'ljlib.pl';
+BEGIN {
+ require 'ljlib.pl';
+}
use LJ::Worker::TheSchwartz;
use LJ::Entry;
View
4 bin/worker/paidstatus
@@ -20,7 +20,9 @@ use lib "$ENV{LJHOME}/cgi-bin";
use Time::HiRes qw/ gettimeofday tv_interval /;
-require 'ljlib.pl';
+BEGIN {
+ require 'ljlib.pl';
+}
use LJ::Sendmail;
use LJ::Lang;
use DW::Shop;
View
4 bin/worker/ping-hubbub
@@ -3,7 +3,9 @@
use strict;
use lib "$ENV{LJHOME}/cgi-bin";
-require 'ljlib.pl';
+BEGIN {
+ require 'ljlib.pl';
+}
use LJ::Worker::TheSchwartz;
use TheSchwartz::Worker::PubSubHubbubPublish;
View
4 bin/worker/process-esn
@@ -14,7 +14,9 @@
use strict;
use lib "$ENV{LJHOME}/cgi-bin";
-require 'ljlib.pl';
+BEGIN {
+ require 'ljlib.pl';
+}
use LJ::Protocol;
use LJ::Lang;
use LJ::Worker::TheSchwartz;
View
4 bin/worker/process-esn-mass
@@ -14,7 +14,9 @@
use strict;
use lib "$ENV{LJHOME}/cgi-bin";
-require 'ljlib.pl';
+BEGIN {
+ require 'ljlib.pl';
+}
use LJ::Protocol;
use LJ::Lang;
use LJ::Worker::TheSchwartz;
View
4 bin/worker/process-eventlogrecord
@@ -14,7 +14,9 @@
use strict;
use lib "$ENV{LJHOME}/cgi-bin";
-require 'ljlib.pl';
+BEGIN {
+ require 'ljlib.pl';
+}
use LJ::Protocol;
use LJ::Worker::TheSchwartz;
use LJ::EventLogRecord;
View
4 bin/worker/resolve-extacct
@@ -17,7 +17,9 @@
use strict;
use warnings;
use lib "$ENV{LJHOME}/cgi-bin";
-require "ljlib.pl";
+BEGIN {
+ require "ljlib.pl";
+}
use LJ::Worker::Gearman;
use Storable qw/ thaw /;
View
4 bin/worker/schedule-synsuck
@@ -16,7 +16,9 @@
#
use lib "$ENV{LJHOME}/cgi-bin";
-require 'ljlib.pl';
+BEGIN {
+ require 'ljlib.pl';
+}
use Getopt::Long;
View
4 bin/worker/search-constraints
@@ -14,7 +14,9 @@
use strict;
use lib "$ENV{LJHOME}/cgi-bin";
-require "ljlib.pl";
+BEGIN {
+ require "ljlib.pl";
+}
use Gearman::Worker;
use Storable;
use LJ::Worker::Gearman;
View
4 bin/worker/search-lookup
@@ -14,7 +14,9 @@
use strict;
use lib "$ENV{LJHOME}/cgi-bin";
-require "ljlib.pl";
+BEGIN {
+ require "ljlib.pl";
+}
use Gearman::Worker;
use Storable;
use LJ::Worker::Gearman;
View
4 bin/worker/search-updater
@@ -16,7 +16,9 @@ package LJ::Worker::UserSearch::Updater;
use strict;
use warnings;
use lib "$ENV{LJHOME}/cgi-bin";
-require "ljlib.pl";
+BEGIN {
+ require "ljlib.pl";
+}
use base 'LJ::Worker::Manual';
use LJ::UserSearch::MetaUpdater;
use Carp;
View
4 bin/worker/shop-creditcard-charge
@@ -17,7 +17,9 @@
use strict;
use lib "$ENV{LJHOME}/cgi-bin";
-require "ljlib.pl";
+BEGIN {
+ require "ljlib.pl";
+}
use Gearman::Worker;
use Storable qw/ thaw /;
View
4 bin/worker/spellcheck-gm
@@ -16,7 +16,9 @@
use strict;
use lib "$ENV{LJHOME}/cgi-bin";
-require "ljlib.pl";
+BEGIN {
+ require "ljlib.pl";
+}
use Gearman::Worker;
use LJ::Worker::Gearman;
View
4 bin/worker/sphinx-search-gm
@@ -17,7 +17,9 @@
use strict;
use lib "$ENV{LJHOME}/cgi-bin";
-require "ljlib.pl";
+BEGIN {
+ require "ljlib.pl";
+}
use Encode;
use Gearman::Worker;
View
4 bin/worker/subscribe-hubbub
@@ -17,7 +17,9 @@
#
use lib "$ENV{LJHOME}/cgi-bin";
-require 'ljlib.pl';
+BEGIN {
+ require 'ljlib.pl';
+}
use Getopt::Long;
use LWPx::ParanoidAgent;
View
4 bin/worker/support-notify
@@ -14,7 +14,9 @@
use strict;
use lib "$ENV{LJHOME}/cgi-bin";
-require 'ljlib.pl';
+BEGIN {
+ require 'ljlib.pl';
+}
use LJ::Support;
use LJ::Sendmail;
View
4 bin/worker/sysban-gm
@@ -14,7 +14,9 @@
use strict;
use lib "$ENV{LJHOME}/cgi-bin";
-require 'ljlib.pl';
+BEGIN {
+ require 'ljlib.pl';
+}
use LJ::Sysban;
use LJ::Worker::Gearman;
View
4 bin/worker/taglib-gm
@@ -14,7 +14,9 @@
use strict;
use lib "$ENV{LJHOME}/cgi-bin";
-require 'ljlib.pl';
+BEGIN {
+ require 'ljlib.pl';
+}
use LJ::Worker::Gearman;
use Storable;
View
6 bin/worker/talklib-gm
@@ -14,8 +14,10 @@
use strict;
use lib "$ENV{LJHOME}/cgi-bin";
-require 'ljlib.pl';
-require 'talklib.pl';
+BEGIN {
+ require 'ljlib.pl';
+ require 'talklib.pl';
+}
use LJ::Worker::Gearman;
use Storable;
View
4 bin/worker/userpic-resize-gm
@@ -14,7 +14,9 @@
use strict;
use lib "$ENV{LJHOME}/cgi-bin";
-require "ljlib.pl";
+BEGIN {
+ require "ljlib.pl";
+}
use Image::Magick;
use Gearman::Worker;
use Storable;

0 comments on commit 8928be8

Please sign in to comment.
Something went wrong with that request. Please try again.