[Rt-commit] rt branch, 3.8-trunk, updated. rt-3.8.5-208-gdad6906

Ruslan Zakirov ruz at bestpractical.com
Wed Sep 30 23:09:53 EDT 2009


The branch, 3.8-trunk has been updated
       via  dad6906d7755d49d0ff0f423f744b563daeb3e35 (commit)
       via  e3b1b2d337824aae8b53a58d897a70ac168dfb10 (commit)
       via  9a20562a369273396e298264e24792bcc23932e1 (commit)
      from  43adaaf5fc05d5c0beccf5767521ecd0547be821 (commit)

Summary of changes:
 lib/RT/Test.pm                            |  100 ++++++++++++++++++++-----
 share/html/User/Prefs.html                |  117 ++++++++++++++++-------------
 t/data/configs/apache2.2+mod_perl.conf.in |   66 +---------------
 3 files changed, 149 insertions(+), 134 deletions(-)

- Log -----------------------------------------------------------------
commit 9a20562a369273396e298264e24792bcc23932e1
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Wed Sep 30 02:45:30 2009 +0400

    retab, refactor, no functionality changes

diff --git a/share/html/User/Prefs.html b/share/html/User/Prefs.html
index c0fb63c..5d8df85 100755
--- a/share/html/User/Prefs.html
+++ b/share/html/User/Prefs.html
@@ -48,7 +48,7 @@
 <& /Elements/Header, Title=>loc("Preferences") &>
 <& /User/Elements/Tabs, 
     current_tab => 'User/Prefs.html', 
-    Title=>loc("Preferences") &>
+    Title => loc("Preferences") &>
 
 <& /Elements/ListActions, actions => \@results &>
 
@@ -195,71 +195,68 @@
 
 <%INIT>
 
-my $UserObj = new RT::User($session{'CurrentUser'});
-my ($title, $PrivilegedChecked, $EnabledChecked, $Disabled, $result, @results);
-
-my ($val, $msg);
-
-
-	$UserObj->Load($id) || $UserObj->Load($Name) || Abort("Couldn't load user '$Name'");
-	$val = $UserObj->Id();
-    
-
-
-
-
-
-# If we have a user to modify, lets try. 
-if ($UserObj->Id) {
-    
-    my @fields = qw(Name Comments Signature EmailAddress FreeformContactInfo 
-		    Organization RealName NickName Lang EmailEncoding WebEncoding 
-		    ExternalContactInfoId ContactInfoSystem Gecos ExternalAuthId 
-		    AuthSystem HomePhone WorkPhone MobilePhone PagerPhone Address1
-		Address2 City State Zip Country Lang Timezone
-		   );
-
-    $m->callback(
-        CallbackName => 'UpdateLogic',
-        fields       => \@fields,
-        results      => \@results,
-        UserObj      => $UserObj,
-        ARGSRef      => \%ARGS,
-    );
-    
-    my @fieldresults = UpdateRecordObject ( AttributesRef => \@fields,
-					    Object => $UserObj,
-					    ARGSRef => \%ARGS );
-    if ($Lang) {
-	$session{'CurrentUser'}->LanguageHandle($Lang);
-	$session{'CurrentUser'} = $session{'CurrentUser'}; # force writeback
-    }
-
-    push (@results, at fieldresults);
+my $UserObj = RT::User->new( $session{'CurrentUser'} );
+$UserObj->Load($id) if $id;
+$UserObj->Load($Name) if $Name && !$UserObj->id;
+unless ( $UserObj->id ) {
+    Abort(loc("Couldn't load user #[_1] or user '[_2]'", $id, $Name))
+        if $id && $Name;
+    Abort(loc("Couldn't load user #[_1]", $id))
+        if $id;
+    Abort(loc("Couldn't load user '[_1]'", $Name))
+        if $Name;
+    Abort(loc("Couldn't load user"));
+}
 
+my @results;
+
+my @fields = qw(
+    Name Comments Signature EmailAddress FreeformContactInfo 
+    Organization RealName NickName Lang EmailEncoding WebEncoding 
+    ExternalContactInfoId ContactInfoSystem Gecos ExternalAuthId 
+    AuthSystem HomePhone WorkPhone MobilePhone PagerPhone Address1
+    Address2 City State Zip Country Lang Timezone
+);
+
+$m->callback(
+    CallbackName => 'UpdateLogic',
+    fields       => \@fields,
+    results      => \@results,
+    UserObj      => $UserObj,
+    ARGSRef      => \%ARGS,
+);
+
+push @results, UpdateRecordObject (
+    AttributesRef => \@fields,
+    Object => $UserObj,
+    ARGSRef => \%ARGS,
+);
+
+if ( $Lang ) {
+    $session{'CurrentUser'}->LanguageHandle($Lang);
+    $session{'CurrentUser'} = $session{'CurrentUser'}; # force writeback
+}
 
 # Deal with special fields: Privileged, Enabled, and Password
-if  ( ($SetPrivileged) and ( $Privileged != $UserObj->Privileged) ) {
-my  ($code, $msg) = $UserObj->SetPrivileged($Privileged);
-     push @results, loc('Privileged status: [_1]', loc_fuzzy($msg));
+if  ( $SetPrivileged and $Privileged != $UserObj->Privileged ) {
+    my ($code, $msg) = $UserObj->SetPrivileged( $Privileged );
+    push @results, loc('Privileged status: [_1]', loc_fuzzy($msg));
 }
 
 #TODO: make this report errors properly
-if ((defined $Pass1) and ($Pass1 ne '') and ($Pass1 eq $Pass2) and (!$UserObj->IsPassword($Pass1))) {
+if ( defined $Pass1 and length $Pass1 and $Pass1 eq $Pass2 and !$UserObj->IsPassword($Pass1) ) {
     my ($code, $msg);
     ($code, $msg) = $UserObj->SetPassword($Pass1);
     push @results, loc('Password: [_1]', loc_fuzzy($msg));
-} elsif ( $Pass1 && ($Pass1 ne $Pass2)) {
+} elsif ( defined $Pass1 && length $Pass1 && $Pass1 ne $Pass2 ) {
     push @results, loc("Passwords do not match. Your password has not been changed");
 }
 
-    if ( $ARGS{'ResetAuthToken'} ) {
-        my ($status, $msg) = $UserObj->GenerateAuthToken;
-        push @results, $msg;
-    }
+if ( $ARGS{'ResetAuthToken'} ) {
+    my ($status, $msg) = $UserObj->GenerateAuthToken;
+    push @results, $msg;
 }
 
-
 </%INIT>
 
 

commit e3b1b2d337824aae8b53a58d897a70ac168dfb10
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Wed Sep 30 02:53:42 2009 +0400

    show custom fields on user's preferences page

diff --git a/share/html/User/Prefs.html b/share/html/User/Prefs.html
index 5d8df85..f52fdcb 100755
--- a/share/html/User/Prefs.html
+++ b/share/html/User/Prefs.html
@@ -161,6 +161,20 @@
   </tr>
 </table>
 </&>
+
+<&| /Widgets/TitleBox, title => loc('Custom Fields') &>
+<table>
+% my $CustomFields = $UserObj->CustomFields;
+% while ( my $CF = $CustomFields->Next ) {
+<tr valign="top">
+<td align="right"><% loc( $CF->Name ) %>:</td>
+<td><& /Elements/EditCustomField,
+    %ARGS, Object => $UserObj, CustomField => $CF
+&></td></tr>
+% }
+</table>
+</&>
+
 % $m->callback( %ARGS, UserObj => $UserObj, CallbackName => 'FormRightColumn' );
 </td>
 </tr>
@@ -232,6 +246,8 @@ push @results, UpdateRecordObject (
     ARGSRef => \%ARGS,
 );
 
+push @results, ProcessObjectCustomFieldUpdates( ARGSRef => \%ARGS, Object => $UserObj );
+
 if ( $Lang ) {
     $session{'CurrentUser'}->LanguageHandle($Lang);
     $session{'CurrentUser'} = $session{'CurrentUser'}; # force writeback

commit dad6906d7755d49d0ff0f423f744b563daeb3e35
Author: Ruslan Zakirov <ruz at bestpractical.com>
Date:   Thu Oct 1 07:08:51 2009 +0400

    make it possible to really run tests under mod_perl

diff --git a/lib/RT/Test.pm b/lib/RT/Test.pm
index 649d1b8..d0cf9cf 100644
--- a/lib/RT/Test.pm
+++ b/lib/RT/Test.pm
@@ -950,44 +950,107 @@ use File::Temp qw(tempfile);
 
 sub start_apache_server {
     my $self = shift;
-    my $variant = shift || 'mod_perl2';
+    my $variant = shift || 'mod_perl';
 
-    my $apache_bin = $ENV{'RT_TEST_APACHE'} || $self->find_apache_server
-        || Test::More::BAIL_OUT("Couldn't find apache server, use RT_TEST_APACHE");
-
-    Test::More::diag("Using apache - '$apache_bin'") if $ENV{'TEST_VERBOSE'};
-
-    my $apache_info = `$apache_bin -V`;
-    my ($version) = ($apache_info =~ m{Server\s+version:\s+Apache/(\d+\.\d+)\.});
-    die "Couldn't figure out version of the server" unless $version;
-
-    my %apache_opts = ($apache_info =~ m/^\s*-D\s+([A-Z_]+)="(.*)"$/mg);
+    my %info = $self->apache_server_info( variant => $variant );
 
     my ($log_fh, $log_fn) = tempfile();
+    my $pid_fn = File::Spec->rel2abs( File::Spec->catfile(
+        't', "apache.$$.pid"
+    ) );
     my $tmpl = File::Spec->rel2abs( File::Spec->catfile(
-        't', 'data', 'configs', 'apache'. $version .'+'. $variant .'.conf'
+        't', 'data', 'configs',
+        'apache'. $info{'version'} .'+'. $variant .'.conf'
     ) );
     my %opt = (
-        listen => $port,
-        server_root   => $apache_opts{'HTTPD_ROOT'}
+        listen        => $port,
+        server_root   => $info{'HTTPD_ROOT'}
             || Test::More::BAIL_OUT("Couldn't figure out server root"),
+        pid_file      => $pid_fn,
         document_root => $RT::MasonComponentRoot,
         rt_bin_path   => $RT::BinPath,
         log_file      => $log_fn,
     );
+    {
+        my $method = 'apache_'.$variant.'_server_options';
+        $self->$method( \%info, \%opt );
+    }
     my ($conf_fh, $conf_fn) = $self->process_in_file(
         in => $tmpl, options => \%opt, out => $tmpl .'.final',
     );
 
-    my $pid = $self->fork_exec($apache_bin, '-f', $conf_fn);
-    Test::More::diag("Started apache server #$pid");
-    push @SERVERS, $pid;
+    $self->fork_exec($info{'executable'}, '-f', $conf_fn);
+    my $pid = do {
+        my $tries = 60;
+        while ( !-e $pid_fn ) {
+            $tries--;
+            last unless $tries;
+            sleep 1;
+        }
+        Test::More::BAIL_OUT("Couldn't start apache server, no pid file")
+            unless -e $pid_fn;
+        open my $pid_fh, '<', $pid_fn
+            or Test::More::BAIL_OUT("Couldn't open pid file: $!");
+        my $pid = <$pid_fh>;
+        chomp $pid;
+        $pid;
+    };
 
-    sleep 1;
+    Test::More::ok($pid, "Started apache server #$pid");
+
+    push @SERVERS, $pid;
 
     return (RT->Config->Get('WebURL'), RT::Test::Web->new);
 }
 
+sub apache_server_info {
+    my $self = shift;
+    my %res = @_;
+
+    my $bin = $res{'executable'} = $ENV{'RT_TEST_APACHE'} || $self->find_apache_server
+        || Test::More::BAIL_OUT("Couldn't find apache server, use RT_TEST_APACHE");
+
+    Test::More::diag("Using '$bin' apache executable for testing")
+        if $ENV{'TEST_VERBOSE'};
+
+    my $info = `$bin -V`;
+    ($res{'version'}) = ($info =~ m{Server\s+version:\s+Apache/(\d+\.\d+)\.});
+    Test::More::BAIL_OUT(
+        "Couldn't figure out version of the server"
+    ) unless $res{'version'};
+
+    my %opts = ($info =~ m/^\s*-D\s+([A-Z_]+?)(?:="(.*)")$/mg);
+    %res = (%res, %opts);
+
+    $res{'modules'} = [
+        map {s/^\s+//; s/\s+$//; $_}
+        grep $_ !~ /Compiled in modules/i,
+        split /\r*\n/, `$bin -l`
+    ];
+
+    return %res;
+}
+
+sub apache_mod_perl_server_options {
+    my $self = shift;
+    my %info = %{ shift() };
+    my $current = shift;
+
+    my %required_modules = (
+        '2.2' => [qw(authz_host log_config env alias perl)],
+    );
+    my @mlist = @{ $required_modules{ $info{'version'} } };
+
+    $current->{'load_modules'} = '';
+    foreach my $mod ( @mlist ) {
+        next if grep "$mod.c" eq $_, @{ $info{'modules'} };
+
+        $current->{'load_modules'} .=
+            "LoadModule ${mod}_module modules/mod_${mod}.so\n";
+    }
+    return;
+}
+
 sub find_apache_server {
     my $self = shift;
     return $_ foreach grep defined,
@@ -1068,7 +1131,6 @@ sub process_in_file {
 END {
     my $Test = RT::Test->builder;
     return if $Test->{Original_Pid} != $$;
-    Test::More::diag("Cleaning");
 
     RT::Test->stop_server;
 
diff --git a/t/data/configs/apache2.2+mod_perl.conf.in b/t/data/configs/apache2.2+mod_perl.conf.in
index d347efa..7ccf3a8 100644
--- a/t/data/configs/apache2.2+mod_perl.conf.in
+++ b/t/data/configs/apache2.2+mod_perl.conf.in
@@ -1,68 +1,8 @@
 ServerRoot %%SERVER_ROOT%%
+PidFile %%PID_FILE%%
 ServerAdmin root at localhost
-#LoadModule authn_file_module modules/mod_authn_file.so
-#LoadModule authn_dbm_module modules/mod_authn_dbm.so
-#LoadModule authn_anon_module modules/mod_authn_anon.so
-#LoadModule authn_dbd_module modules/mod_authn_dbd.so
-#LoadModule authn_default_module modules/mod_authn_default.so
-LoadModule authz_host_module modules/mod_authz_host.so
-#LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
-#LoadModule authz_user_module modules/mod_authz_user.so
-#LoadModule authz_dbm_module modules/mod_authz_dbm.so
-#LoadModule authz_owner_module modules/mod_authz_owner.so
-#LoadModule authz_default_module modules/mod_authz_default.so
-#LoadModule auth_basic_module modules/mod_auth_basic.so
-#LoadModule auth_digest_module modules/mod_auth_digest.so
-#LoadModule file_cache_module modules/mod_file_cache.so
-#LoadModule cache_module modules/mod_cache.so
-#LoadModule disk_cache_module modules/mod_disk_cache.so
-#LoadModule mem_cache_module modules/mod_mem_cache.so
-#LoadModule dbd_module modules/mod_dbd.so
-#LoadModule dumpio_module modules/mod_dumpio.so
-#LoadModule ext_filter_module modules/mod_ext_filter.so
-#LoadModule include_module modules/mod_include.so
-#LoadModule filter_module modules/mod_filter.so
-#LoadModule substitute_module modules/mod_substitute.so
-#LoadModule deflate_module modules/mod_deflate.so
-LoadModule log_config_module modules/mod_log_config.so
-#LoadModule log_forensic_module modules/mod_log_forensic.so
-#LoadModule logio_module modules/mod_logio.so
-LoadModule env_module modules/mod_env.so
-#LoadModule mime_magic_module modules/mod_mime_magic.so
-#LoadModule cern_meta_module modules/mod_cern_meta.so
-#LoadModule expires_module modules/mod_expires.so
-#LoadModule headers_module modules/mod_headers.so
-#LoadModule ident_module modules/mod_ident.so
-#LoadModule usertrack_module modules/mod_usertrack.so
-#LoadModule unique_id_module modules/mod_unique_id.so
-#LoadModule setenvif_module modules/mod_setenvif.so
-#LoadModule version_module modules/mod_version.so
-#LoadModule proxy_module modules/mod_proxy.so
-#LoadModule proxy_connect_module modules/mod_proxy_connect.so
-#LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
-#LoadModule proxy_http_module modules/mod_proxy_http.so
-#LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
-#LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
-#LoadModule ssl_module modules/mod_ssl.so
-#LoadModule mime_module modules/mod_mime.so
-#LoadModule dav_module modules/mod_dav.so
-#LoadModule status_module modules/mod_status.so
-#LoadModule autoindex_module modules/mod_autoindex.so
-#LoadModule asis_module modules/mod_asis.so
-#LoadModule info_module modules/mod_info.so
-#LoadModule cgi_module modules/mod_cgi.so
-#LoadModule dav_fs_module modules/mod_dav_fs.so
-#LoadModule vhost_alias_module modules/mod_vhost_alias.so
-#LoadModule negotiation_module modules/mod_negotiation.so
-#LoadModule dir_module modules/mod_dir.so
-#LoadModule imagemap_module modules/mod_imagemap.so
-#LoadModule actions_module modules/mod_actions.so
-#LoadModule speling_module modules/mod_speling.so
-#LoadModule userdir_module modules/mod_userdir.so
-LoadModule alias_module modules/mod_alias.so
-#LoadModule rewrite_module modules/mod_rewrite.so
-#LoadModule rewrite_module modules/mod_rewrite.so
-LoadModule perl_module modules/mod_perl.so
+
+%%LOAD_MODULES%%
 
 <IfModule !mpm_netware_module>
 <IfModule !mpm_winnt_module>

-----------------------------------------------------------------------


More information about the Rt-commit mailing list