]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 662070: Use say() instead of print() where appropriate
authorFrédéric Buclin <LpSolit@gmail.com>
Wed, 17 Aug 2011 11:18:47 +0000 (13:18 +0200)
committerFrédéric Buclin <LpSolit@gmail.com>
Wed, 17 Aug 2011 11:18:47 +0000 (13:18 +0200)
r=glob a=LpSolit

Bugzilla/Chart.pm
Bugzilla/DB.pm
Bugzilla/Field.pm
Bugzilla/Install.pm
Bugzilla/Migrate.pm
Bugzilla/Util.pm
report.cgi
sanitycheck.cgi
testserver.pl
whineatnews.pl

index 760db135dfb67e51409db891955450f3ffe83d09..5022723ddd7c3d669d1a333faff8eb77ec7d61b5 100644 (file)
@@ -437,7 +437,7 @@ sub dump {
     my $data = $self->data;
     
     require Data::Dumper;
-    print "<pre>Bugzilla::Chart object:\n";
+    say "<pre>Bugzilla::Chart object:";
     print Data::Dumper::Dumper($self);
     print "</pre>";
 }
index 8d1cf32a0b01ac39a1dce24a3ad94c346e32b4d7..3c37c0dbd087e8c109708de6246858f4703c6a1a 100644 (file)
@@ -250,7 +250,7 @@ sub bz_create_database {
 
     if (!$conn_success) {
         $dbh = _get_no_db_connection();
-        print "Creating database $db_name...\n";
+        say "Creating database $db_name...";
 
         # Try to create the DB, and if we fail print a friendly error.
         my $success  = eval {
@@ -483,7 +483,7 @@ sub bz_setup_database {
     my @desired_tables = $self->_bz_schema->get_table_list();
     my $bugs_exists = $self->bz_table_info('bugs');
     if (!$bugs_exists) {
-        print install_string('db_table_setup'), "\n";
+        say install_string('db_table_setup');
     }
 
     foreach my $table_name (@desired_tables) {
@@ -520,7 +520,7 @@ sub bz_setup_foreign_keys {
     my $activity_fk = $self->bz_fk_info('profiles_activity', 'userid');
     my $any_fks = $activity_fk && $activity_fk->{created};
     if (!$any_fks) {
-        print get_text('install_fk_setup'), "\n";
+        say get_text('install_fk_setup');
     }
 
     my @tables = $self->bz_table_list();
@@ -711,12 +711,12 @@ sub bz_alter_column_raw {
         $table, $name, $new_def,
         defined $set_nulls_to ? $self->quote($set_nulls_to) : undef);
     my $new_ddl = $self->_bz_schema->get_type_ddl($new_def);
-    print "Updating column $name in table $table ...\n";
+    say "Updating column $name in table $table ...";
     if (defined $current_def) {
         my $old_ddl = $self->_bz_schema->get_type_ddl($current_def);
-        print "Old: $old_ddl\n";
+        say "Old: $old_ddl";
     }
-    print "New: $new_ddl\n";
+    say "New: $new_ddl";
     $self->do($_) foreach (@statements);
 }
 
@@ -810,7 +810,7 @@ sub _bz_add_table_raw {
     if (Bugzilla->usage_mode == USAGE_MODE_CMDLINE
         and !$options->{silently})
     {
-        print install_string('db_table_new', { table => $name }), "\n";
+        say install_string('db_table_new', { table => $name });
     }
     $self->do($_) foreach (@statements);
 }
@@ -1317,7 +1317,7 @@ sub _bz_init_schema_storage {
             $self->_bz_add_table_raw('bz_schema');
         }
 
-        print install_string('db_schema_init'), "\n";
+        say install_string('db_schema_init');
         my $sth = $self->prepare("INSERT INTO bz_schema "
                                  ." (schema_data, version) VALUES (?,?)");
         $sth->bind_param(1, $store_me, $self->BLOB_TYPE);
index 219172094fd4db1561a143fd051c3e42ca9ec155..aa35511824c01dc606083d710eed8fb380cf6db1 100644 (file)
@@ -47,7 +47,7 @@ Bugzilla::Field - a particular piece of information about bugs
   # Instantiate a Field object for an existing field.
   my $field = new Bugzilla::Field({name => 'qacontact_accessible'});
   if ($field->obsolete) {
-      print $field->description . " is obsolete\n";
+      say $field->description . " is obsolete";
   }
 
   # Validation Routines
@@ -1173,8 +1173,8 @@ sub populate_field_definitions {
                               undef, $field_description);
 
     if ($old_field_id && ($old_field_name ne $new_field_name)) {
-        print "SQL fragment found in the 'fielddefs' table...\n";
-        print "Old field name: " . $old_field_name . "\n";
+        say "SQL fragment found in the 'fielddefs' table...";
+        say "Old field name: $old_field_name";
         # We have to fix saved searches first. Queries have been escaped
         # before being saved. We have to do the same here to find them.
         $old_field_name = url_quote($old_field_name);
@@ -1211,8 +1211,8 @@ sub populate_field_definitions {
             $sth_UpdateSeries->execute($query, $series_id);
         }
         # Now that saved searches have been fixed, we can fix the field name.
-        print "Fixing the 'fielddefs' table...\n";
-        print "New field name: " . $new_field_name . "\n";
+        say "Fixing the 'fielddefs' table...";
+        say "New field name: $new_field_name";
         $dbh->do('UPDATE fielddefs SET name = ? WHERE id = ?',
                   undef, ($new_field_name, $old_field_id));
     }
index ce8fe6bad8c385a72c9fc0a67b25fdcbdfdf3a17..642165a43e3de9a15d66b7a00ef58c9865fb7405 100644 (file)
@@ -34,7 +34,7 @@ use Bugzilla::Group;
 use Bugzilla::Product;
 use Bugzilla::User;
 use Bugzilla::User::Setting;
-use Bugzilla::Util qw(get_text);
+use Bugzilla::Util qw(get_text say);
 use Bugzilla::Version;
 
 use constant STATUS_WORKFLOW => (
@@ -188,7 +188,7 @@ sub update_settings {
     my $any_settings = $dbh->selectrow_array(
         'SELECT 1 FROM setting ' . $dbh->sql_limit(1));
     if (!$any_settings) {
-        print get_text('install_setting_setup'), "\n";
+        say get_text('install_setting_setup');
     }
 
     my %settings = %{SETTINGS()};
@@ -210,7 +210,7 @@ sub update_system_groups {
     # adding groups.
     my $editbugs_exists = new Bugzilla::Group({ name => 'editbugs' });
     if (!$editbugs_exists) {
-        print get_text('install_groups_setup'), "\n";
+        say get_text('install_groups_setup');
     }
 
     # Create most of the system groups
@@ -281,7 +281,7 @@ sub init_workflow {
     my $has_workflow = $dbh->selectrow_array('SELECT 1 FROM status_workflow');
     return if $has_workflow;
 
-    print get_text('install_workflow_init'), "\n";
+    say get_text('install_workflow_init');
 
     my %status_ids = @{ $dbh->selectcol_arrayref(
         'SELECT value, id FROM bug_status', {Columns=>[1,2]}) };
@@ -316,7 +316,7 @@ sub create_admin {
     my $full_name = $answer{'ADMIN_REALNAME'};
 
     if (!$login || !$password || !$full_name) {
-        print "\n" . get_text('install_admin_setup') . "\n\n";
+        say "\n" . get_text('install_admin_setup') . "\n";
     }
 
     while (!$login) {
@@ -325,7 +325,7 @@ sub create_admin {
         chomp $login;
         eval { Bugzilla::User->check_login_name_for_creation($login); };
         if ($@) {
-            print $@ . "\n";
+            say $@;
             undef $login;
         }
     }
@@ -383,7 +383,7 @@ sub make_admin {
     }
 
     if (Bugzilla->usage_mode == USAGE_MODE_CMDLINE) {
-        print "\n", get_text('install_admin_created', { user => $user }), "\n";
+        say "\n", get_text('install_admin_created', { user => $user });
     }
 }
 
@@ -408,7 +408,7 @@ sub _prompt_for_password {
         chomp $pass2;
         eval { validate_password($password, $pass2); };
         if ($@) {
-            print "\n$@\n";
+            say "\n$@";
             undef $password;
         }
         system("stty","echo") unless ON_WINDOWS;
@@ -430,7 +430,7 @@ sub reset_password {
     my $password = _prompt_for_password($prompt);
     $user->set_password($password);
     $user->update();
-    print "\n", get_text('install_reset_password_done'), "\n";
+    say "\n", get_text('install_reset_password_done');
 }
 
 1;
index 4d76375278cfbc6f4fcc73ebe5492fa5dedcece9..ee4f1d6a6f73e1b56feb4c3dc79a31d26e0f1b63 100644 (file)
@@ -30,7 +30,7 @@ use Bugzilla::Error;
 use Bugzilla::Install::Requirements ();
 use Bugzilla::Install::Util qw(indicate_progress);
 use Bugzilla::Product;
-use Bugzilla::Util qw(get_text trim generate_random_password);
+use Bugzilla::Util qw(get_text trim generate_random_password say);
 use Bugzilla::User ();
 use Bugzilla::Status ();
 use Bugzilla::Version;
@@ -261,7 +261,7 @@ sub bug_fields {
 sub users {
     my $self = shift;
     if (!exists $self->{users}) {
-        print get_text('migrate_reading_users'), "\n";
+        say get_text('migrate_reading_users');
         $self->{users} = $self->_read_users();
     }
     return $self->{users};
@@ -270,7 +270,7 @@ sub users {
 sub products {
     my $self = shift;
     if (!exists $self->{products}) {
-        print get_text('migrate_reading_products'), "\n";
+        say get_text('migrate_reading_products');
         $self->{products} = $self->_read_products();
     }
     return $self->{products};
@@ -279,7 +279,7 @@ sub products {
 sub bugs {
     my $self = shift;
     if (!exists $self->{bugs}) {
-        print get_text('migrate_reading_bugs'), "\n";
+        say get_text('migrate_reading_bugs');
         $self->{bugs} = $self->_read_bugs();
     }
     return $self->{bugs};
@@ -340,7 +340,7 @@ sub reset_serial_values {
 
 sub translate_all_bugs {
     my ($self, $bugs) = @_;
-    print get_text('migrate_translating_bugs'), "\n";
+    say get_text('migrate_translating_bugs');
     # We modify the array in place so that $self->bugs will return the
     # modified bugs, in case $self->before_insert wants them.
     my $num_bugs = scalar(@$bugs);
@@ -608,7 +608,7 @@ sub create_custom_fields {
         if (!$self->dry_run) {
             $created = Bugzilla::Field->create($created);
         }
-        print get_text('migrate_field_created', { field => $created }), "\n";
+        say get_text('migrate_field_created', { field => $created });
     }
     delete $self->{bug_fields};
 }
@@ -680,7 +680,7 @@ sub create_legal_values {
 sub insert_bugs {
     my ($self, $bugs) = @_;
     my $dbh = Bugzilla->dbh;
-    print get_text('migrate_creating_bugs'), "\n";
+    say get_text('migrate_creating_bugs');
 
     my $init_statuses = Bugzilla::Status->can_change_to();
     my %allowed_statuses = map { lc($_->name) => 1 } @$init_statuses;
index ac6848bfa9b69c292bd47baeb7773727549ae242..d158be1e1bd7609ff6e3f33e0cd49fe0412bdc0c 100644 (file)
@@ -31,13 +31,12 @@ package Bugzilla::Util;
 use strict;
 
 use base qw(Exporter);
-@Bugzilla::Util::EXPORT = qw(trick_taint detaint_natural
-                             detaint_signed
+@Bugzilla::Util::EXPORT = qw(trick_taint detaint_natural detaint_signed
                              html_quote url_quote xml_quote
                              css_class_quote html_light_quote url_decode
                              i_am_cgi correct_urlbase remote_ip
                              do_ssl_redirect_if_required use_attachbase
-                             diff_arrays on_main_db
+                             diff_arrays on_main_db say
                              trim wrap_hard wrap_comment find_wrap_point
                              format_time validate_date validate_time datetime_from
                              file_mod_time is_7bit_clean
@@ -341,6 +340,13 @@ sub diff_arrays {
     return (\@removed, \@added);
 }
 
+# XXX - This is a temporary subroutine till we require Perl 5.10.1.
+# This will happen before Bugzilla 5.0rc1.
+sub say (@) {
+    print @_;
+    print "\n";
+}
+
 sub trim {
     my ($str) = @_;
     if ($str) {
index a71776bfe6a1eac41f8e01e4bc8a8a279cdf8a9b..20e899a6b9913c9b74892940e3c2fba930cedf1e 100755 (executable)
@@ -287,10 +287,10 @@ print $cgi->header(-type => $format->{'ctype'},
 # prints out both data structures.
 if ($cgi->param('debug')) {
     require Data::Dumper;
-    print "<pre>data hash:\n";
-    print Data::Dumper::Dumper(%data) . "\n\n";
-    print "data array:\n";
-    print Data::Dumper::Dumper(@image_data) . "\n\n</pre>";
+    say "<pre>data hash:";
+    say Data::Dumper::Dumper(%data);
+    say "\ndata array:";
+    say Data::Dumper::Dumper(@image_data) . "\n\n</pre>";
 }
 
 # All formats point to the same section of the documentation.
index 7b8177d8327305ce0d3b5ac5c54f9fa0926b37b1..1f6740e7725ab3a60d11eb7ce7752edea6ec0a7d 100755 (executable)
@@ -60,7 +60,7 @@ sub Status {
     }
     else {
         my $start_tag = $alert ? '<p class="alert">' : '<p>';
-        print $start_tag . get_string($san_tag, $vars) . "</p>\n";
+        say $start_tag . get_string($san_tag, $vars) . "</p>";
     }
 }
 
index 3142685bc9b68646fdb0751fdb44cb2b30cdc1fe..c845aa493eead53e3e53b45993874e5ac0d6a9da 100755 (executable)
@@ -23,6 +23,7 @@ use lib qw(. lib);
 
 use Bugzilla;
 use Bugzilla::Constants;
+use Bugzilla::Util qw(say);
 
 use Socket;
 
@@ -33,8 +34,8 @@ my $lwp = $@ ? 0 : 1;
 
 if ((@ARGV != 1) || ($ARGV[0] !~ /^https?:/))
 {
-    print "Usage: $0 <URL to this Bugzilla installation>\n";
-    print "e.g.:  $0 http://www.mycompany.com/bugzilla\n";
+    say "Usage: $0 <URL to this Bugzilla installation>";
+    say "e.g.:  $0 http://www.mycompany.com/bugzilla";
     exit(1);
 }
 
@@ -67,26 +68,26 @@ else {
 # Check $webservergroup against the server's GID
 if ($sgid > 0) {
     if ($webservergroup eq "") {
-        print 
+        say 
 "WARNING \$webservergroup is set to an empty string.
 That is a very insecure practice. Please refer to the
-Bugzilla documentation.\n";
+Bugzilla documentation.";
     }
     elsif ($webgroupnum == $sgid || Bugzilla->localconfig->{use_suexec}) {
-        print "TEST-OK Webserver is running under group id in \$webservergroup.\n";
+        say "TEST-OK Webserver is running under group id in \$webservergroup.";
     }
     else {
-        print 
+        say 
 "TEST-WARNING Webserver is running under group id not matching \$webservergroup.
 This if the tests below fail, this is probably the problem.
 Please refer to the web server configuration section of the Bugzilla guide. 
-If you are using virtual hosts or suexec, this warning may not apply.\n";
+If you are using virtual hosts or suexec, this warning may not apply.";
     }
 }
 elsif (!ON_WINDOWS) {
-   print
+   say
 "TEST-WARNING Failed to find the GID for the 'httpd' process, unable
-to validate webservergroup.\n";
+to validate webservergroup.";
 }
 
 
@@ -94,26 +95,26 @@ to validate webservergroup.\n";
 $ARGV[0] =~ s/\/$//;
 my $url = $ARGV[0] . "/images/padlock.png";
 if (fetch($url)) {
-    print "TEST-OK Got padlock picture.\n";
+    say "TEST-OK Got padlock picture.";
 } else {
-    print 
+    say 
 "TEST-FAILED Fetch of images/padlock.png failed
 Your web server could not fetch $url.
-Check your web server configuration and try again.\n";
+Check your web server configuration and try again.";
     exit(1);
 }
 
 # Try to execute a cgi script
 my $response = fetch($ARGV[0] . "/testagent.cgi");
 if ($response =~ /^OK (.*)$/) {
-    print "TEST-OK Webserver is executing CGIs via $1.\n";
+    say "TEST-OK Webserver is executing CGIs via $1.";
 } elsif ($response =~ /^#!/) {
-    print 
+    say
 "TEST-FAILED Webserver is fetching rather than executing CGI files.
-Check the AddHandler statement in your httpd.conf file.\n";
+Check the AddHandler statement in your httpd.conf file.";
     exit(1);
 } else {
-    print "TEST-FAILED Webserver is not executing CGI files.\n"; 
+    say "TEST-FAILED Webserver is not executing CGI files.";
 }
 
 # Make sure that the web server is honoring .htaccess files
@@ -122,13 +123,13 @@ $localconfig =~ s~^\./~~;
 $url = $ARGV[0] . "/$localconfig";
 $response = fetch($url);
 if ($response) {
-    print 
+    say
 "TEST-FAILED Webserver is permitting fetch of $url.
 This is a serious security problem.
-Check your web server configuration.\n";
+Check your web server configuration.";
     exit(1);
 } else {
-    print "TEST-OK Webserver is preventing fetch of $url.\n";
+    say "TEST-OK Webserver is preventing fetch of $url.";
 }
 
 # Test chart generation
@@ -142,8 +143,8 @@ if ($@ eq '') {
         my $gdlib = `gdlib-config --version 2>&1` || "";
         $gdlib =~ s/\n$//;
         if (!$gdlib) {
-            print "TEST-WARNING Failed to run gdlib-config; can't compare " .
-                  "GD versions.\n";
+            say "TEST-WARNING Failed to run gdlib-config; can't compare " .
+                  "GD versions.";
         }
         else {
             my $gd = $GD::VERSION;
@@ -154,9 +155,9 @@ if ($@ eq '') {
             $gd =~ s/^([^\.]+)\..*/$1/;
     
             if ($gdlib == $gd) {
-                print "TEST-OK $verstring; Major versions match.\n";
+                say "TEST-OK $verstring; Major versions match.";
             } else {
-                print "TEST-FAILED $verstring; Major versions do not match.\n";
+                say "TEST-FAILED $verstring; Major versions do not match.";
             }
         }
     }
@@ -177,17 +178,17 @@ if ($@ eq '') {
             create_file("$datadir/testgd-local.png", $image->png);
             check_image("$datadir/testgd-local.png", 'GD');
         } else {
-            print "TEST-FAILED GD doesn't support PNG generation.\n";
+            say "TEST-FAILED GD doesn't support PNG generation.";
         }
     };
     if ($@ ne '') {
-        print "TEST-FAILED GD returned: $@\n";
+        say "TEST-FAILED GD returned: $@";
     }
 
     # Test Chart
     eval 'use Chart::Lines';
     if ($@) {
-        print "TEST-FAILED Chart::Lines is not installed.\n";
+        say "TEST-FAILED Chart::Lines is not installed.";
     } else {
         eval {
             my $chart = Chart::Lines->new(400, 400);
@@ -199,16 +200,16 @@ if ($@ eq '') {
             check_image("$datadir/testchart-local.png", "Chart");
         };
         if ($@ ne '') {
-            print "TEST-FAILED Chart returned: $@\n";
+            say "TEST-FAILED Chart returned: $@";
         }
     }
 
     eval 'use Template::Plugin::GD::Image';
     if ($@) {
-        print "TEST-FAILED Template::Plugin::GD is not installed.\n";
+        say "TEST-FAILED Template::Plugin::GD is not installed.";
     }
     else {
-        print "TEST-OK Template::Plugin::GD is installed.\n";
+        say "TEST-OK Template::Plugin::GD is installed.";
     }
 }
 
@@ -262,10 +263,10 @@ sub check_image {
     my ($local_file, $library) = @_;
     my $filedata = read_file($local_file);
     if ($filedata =~ /^\x89\x50\x4E\x47\x0D\x0A\x1A\x0A/) {
-        print "TEST-OK $library library generated a good PNG image.\n";
+        say "TEST-OK $library library generated a good PNG image.";
         unlink $local_file;
     } else {
-        print "TEST-WARNING $library library did not generate a good PNG.\n";
+        say "TEST-WARNING $library library did not generate a good PNG.";
     }
 }
 
index 3bfe298714ab7b657b952bae7d7cff5d3582102c..76be17f11e9de22321d2229f5344c219d6f1c0ed 100755 (executable)
@@ -94,5 +94,5 @@ foreach my $email (sort (keys %bugs)) {
 
     MessageToMTA($msg);
 
-    print "$email      " . join(" ", @{$bugs{$email}}) . "\n";
+    say "$email      " . join(" ", @{$bugs{$email}});
 }