Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Webgui 7.10 -- the cookie jar cleanup activity #28

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
3a3227c
Fix a typo in the documentation for the list of assets in the Admin C…
perlDreamer Jan 19, 2012
20e49b5
Try to trap errors while loading classes. Fixes bug #12321.
perlDreamer Jan 27, 2012
78159c9
Fix typo introduced into Group.pm
perlDreamer Jan 31, 2012
2dbd38f
Make a safe copy of the config file before modifying it. Fixes bug #…
perlDreamer Feb 4, 2012
80ec20b
Fix a typo in a used module name.
perlDreamer Feb 14, 2012
82554ad
Make sure that HttpProxy cleans up after itself when purging assets o…
perlDreamer Feb 14, 2012
e86b7bb
Fix the FlatDiscount, so that it actually discounts all the time.
perlDreamer Feb 16, 2012
aa76dc5
Document the bug fix for the flat discount asset.
perlDreamer Feb 16, 2012
3b544ee
Fix a problem with fixing parents. Better handling of potential prob…
perlDreamer Feb 18, 2012
ff28ef9
#13787 issue -- and general core repair
pbdavidn Feb 23, 2012
99fa73a
Document bugfix.
perlDreamer Feb 25, 2012
d2f157d
Provide a fallback for contents of .wgaccess files. Fixes bug #12328
perlDreamer Feb 25, 2012
92f4a5f
Document a template variable that already existed to fulfill RFE #9730.
perlDreamer Mar 1, 2012
4a8c63e
Make sure that lastUpdated in updated in the database as well as in t…
perlDreamer Mar 6, 2012
d55f8ee
Document the bugfix for Crud form handling.
perlDreamer Mar 7, 2012
b39a7d5
Fixed bug 12297 - keywords.form help text
pbchrisliu Mar 9, 2012
9a09ec0
sslEnabled in the config file trumps encryptLogin in the settings.
perlDreamer Mar 10, 2012
4f85ad5
Do not build a massive array of users when giving each user an addres…
perlDreamer Mar 11, 2012
275fcd0
Do not return content from cacheByHTTP if the request errors, otherwi…
perlDreamer Mar 14, 2012
1eb5579
Update test for change in USPS International service options.
perlDreamer Mar 18, 2012
fcd9334
Fix the duplicating of events with related links that have restrictiv…
perlDreamer Mar 20, 2012
ecc9a60
cleanup cookie jars workflow
daviddelikat Mar 20, 2012
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions docs/changelog/7.x.x.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
7.10.25
- fixed #12010 related link duplication where links have group view restrictions
- fixed #12297: keywords.form missing from Post template help
- fixed #12321: Error while deleting a group.
- fixed #12322: Cache/CHI stomps on the config file
- fixed #12327: HttpProxy does not clean up cookie jar storage locations
- fixed #12329: FlatDiscount Sku forces you to enter in negative numbers for price
- fixed #12334: Company name with : in it breaks email sender identity
- fixed #12328: invalid wgaccess file in uploads
- RFE: 9730 (actually missing documentation)
- fixed: Crud updateFromFormPost
- fixed: encryptLogin and sslEnabled both need to be true
- fixed: Cache's setByHTTP method returns content, even when it gets an error in the request. This gives the SC asset fits.

7.10.24
- fixed #12318: asset error causes asset manager to fail
Expand Down
8 changes: 8 additions & 0 deletions docs/gotcha.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ upgrading from one version to the next, or even between multiple
versions. Be sure to heed the warnings contained herein as they will
save you many hours of grief.

7.10.25
--------------------------------------------------------------------
* Custom WebGUI plugins written using WebGUI::Crud with hand built forms
should be reviewed. A serious bug in how Crud handles forms has been fixed,
and the side-effect of the bug is now that forms processed by updateFromFormPost
must include ALL fields, otherwise the data in fields which are missing from the
form will be lost.

7.10.24
--------------------------------------------------------------------
* WebGUI now depends on Business::OnlinePayment::AuthorizeNet. This version
Expand Down
10 changes: 6 additions & 4 deletions docs/upgrades/upgrade_7.10.21-7.10.22.pl
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,14 @@ sub addLinkedProfileAddress {
my $session = shift;
print "\tAdding linked profile addresses for existing users... " unless $quiet;

my $users = $session->db->buildArrayRef( q{
select userId from users where userId not in ('1','3')
} );
my $users = $session->db->read( q{ select userId from users } );

foreach my $userId (@$users) {
use WebGUI::User;
use WebGUI::Shop::AddressBook;
while (my ($userId) = $users->array()) {
#check to see if there is user profile information available
next if $userId eq '1' or $userId eq '3';
last unless $userId;
my $u = WebGUI::User->new($session,$userId);
#skip if user does not have any homeAddress fields filled in
next unless (
Expand Down
9 changes: 5 additions & 4 deletions docs/upgrades/upgrade_7.9.34-7.10.22.pl
Original file line number Diff line number Diff line change
Expand Up @@ -433,14 +433,15 @@ sub addLinkedProfileAddress {
my $session = shift;
print "\tAdding linked profile addresses for existing users... " unless $quiet;

my $users = $session->db->buildArrayRef( q{
select userId from users where userId not in ('1','3')
} );
my $users = $session->db->read( q{ select userId from users } );

use WebGUI::User;
use WebGUI::Shop::AddressBook;
foreach my $userId (@$users) {

while (my ($userId) = $users->array()) {
#check to see if there is user profile information available
next if $userId eq '1' or $userId eq '3';
last unless $userId;
my $u = WebGUI::User->new($session,$userId);
#skip if user does not have any homeAddress fields filled in
next unless (
Expand Down
2 changes: 1 addition & 1 deletion etc/WebGUI.conf.original
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@
}
},

# Specify a the list of assets you want to appear in your
# Specify the list of assets you want to appear in your
# "New Content" menu categories. See "assetCategories" for details
# about categories. Each listing has a key of class name, and then
# has several properties, which are:
Expand Down
106 changes: 106 additions & 0 deletions lib/WebGUI/Account/CleanCookieJars.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
package WebGUI::Workflow::Activity::CleanCookieJars;


=head1 LEGAL

-------------------------------------------------------------------
WebGUI is Copyright 2001-2012 Plain Black Corporation.
-------------------------------------------------------------------
Please read the legal notices (docs/legal.txt) and the license
(docs/license.txt) that came with this distribution before using
this software.
-------------------------------------------------------------------
http://www.plainblack.com [email protected]
-------------------------------------------------------------------

=cut

use strict;
use base 'WebGUI::Workflow::Activity';
use WebGUI::International;
use WebGUI::Storage;
use File::Basename ();
use File::Spec;

=head1 NAME

Package WebGUI::Workflow::Activity::CleanCookieJars

=head1 DESCRIPTION

Cleans up stale cookie jars

=head1 SYNOPSIS

See WebGUI::Workflow::Activity for details on how to use any activity.

=head1 METHODS

These methods are available from this class:

=cut


#-------------------------------------------------------------------

=head2 definition ( session, definition )

See WebGUI::Workflow::Activity::defintion() for details.

=cut

sub definition {
my $class = shift;
my $session = shift;
my $definition = shift;
my $i18n = WebGUI::International->new( $session, "WorkFlow_Activity_CleanCookieJars" );
push(@{$definition}, {
name => $i18n->get("activity cleanup cookie jars"),
properties => {}
});
return $class->SUPER::definition($session,$definition);
}


#-------------------------------------------------------------------

=head2 execute ( )

See WebGUI::Workflow::Activity::execute() for details.

=cut

sub execute {
my $self = shift;
my $session = $self->session;
# keep track of how much time it's taking
my $start = time;
my $limit = 2_500; # may need tweeking
my $timeLimit = $self->getTTL;

my $get_proxy = $session->db->read('select assetId, revisionDate, cookieJarStorageId from HttpProxy');
STORAGEID: while (1) {
my ($assetId, $revisionDate, $storageId,) = $get_proxy->array();
last STORAGEID unless $storageId;
print "Working on $assetId, $revisionDate, $storageId\n";
my $storage = WebGUI::Storage->get($session, $storageId);
next unless $storage;
opendir my $directory, $storage->getPath;
FILE: while (my $file = readdir($directory)) {
next FILE if $file =~ /^\./;
my $whole_file = $storage->getPath($file);
if (-M $whole_file >=1) {
unlink $whole_file;
}
$limit--;
last if ! $limit or time > $start + $timeLimit;
}

}
return $self->WAITING(1) if ! $limit or time > $start + $timeLimit;
return $self->COMPLETE;
}

1;


6 changes: 5 additions & 1 deletion lib/WebGUI/Asset/Event.pm
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ sub duplicate {
my $newAsset = $self->SUPER::duplicate(@_);
my $newStorage = $self->getStorageLocation->copy;
$newAsset->update({storageId=>$newStorage->getId});
my $links = $self->getRelatedLinks();
my $links = $self->getRelatedLinks('nolimit');
my $id = $self->session->id;
foreach my $link (@{ $links }) {
$link->{new_event} = 1;
Expand Down Expand Up @@ -1076,12 +1076,16 @@ Gets an arrayref of hashrefs of related links.

sub getRelatedLinks {
my $self = shift;
my $limitflag = shift || 'yes';

my $sth
= $self->session->db->prepare(
"SELECT * FROM Event_relatedlink WHERE assetId=? ORDER BY sequenceNumber",
);
$sth->execute([ $self->getId ]);
if( $limitflag eq 'nolimit' ) {
return [ map { $sth->hashRef } ( 1..$sth->rows ) ];
}

my @links;
while ( my $link = $sth->hashRef ) {
Expand Down
2 changes: 1 addition & 1 deletion lib/WebGUI/Asset/Sku/FlatDiscount.pm
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ sub getPrice {
return $subtotal * $self->get('percentageDiscount') / -100;
}
else {
return $self->get('priceDiscount');
return -1 * abs($self->get('priceDiscount'));
}
}
return 0;
Expand Down
26 changes: 24 additions & 2 deletions lib/WebGUI/Asset/Wobject/HttpProxy.pm
Original file line number Diff line number Diff line change
Expand Up @@ -256,14 +256,36 @@ sub prepareView {

=head2 purge

Extend the base method to delete the cookie jar
Extend the base method to delete all cookie jars for this HttpProxy

=cut

sub purge {
my $self = shift;
my $id = $self->getId;
my $session = $self->session;
my @storageIds = $session->db->buildArray("select cookieJarStorageId from HttpProxy where assetId=?",[$id]);
my $success = $self->SUPER::purge;
return 0 unless $success;
foreach my $storageId (@storageIds) {
my $storage = WebGUI::Storage->get($session, $storageId);
$storage->delete if defined $storage;
}
return 1;
}

#-------------------------------------------------------------------

=head2 purgeRevision

Extend the base method to delete the cookie jar for this revision.

=cut

sub purgeRevision {
my $self = shift;
$self->getCookieJar->delete;
$self->SUPER::purge;
$self->SUPER::purgeRevision;
}


Expand Down
6 changes: 3 additions & 3 deletions lib/WebGUI/Auth.pm
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ sub displayLogin {
my $i18n = WebGUI::International->new($self->session);
$vars->{title} = $i18n->get(66);
my $action;
if ($self->session->setting->get("encryptLogin")) {
if ($self->session->config->get('sslEnabled') && $self->session->setting->get("encryptLogin")) {
my $uri = URI->new($self->session->url->page(undef,1));
$uri->scheme('https');
$uri->host_port($uri->host);
Expand Down Expand Up @@ -924,7 +924,7 @@ sub login {
$self->session->http->setRedirect($self->session->setting->get("redirectAfterLoginUrl"));
$self->session->scratch->delete("redirectAfterLogin");
}
elsif ($self->session->setting->get('encryptLogin')) {
elsif ($self->session->config->get('sslEnabled') && $self->session->setting->get('encryptLogin')) {
my $currentUrl = URI->new($self->session->url->page(undef,1));
$currentUrl->scheme('http');
$currentUrl->port($self->session->config->get('webServerPort') || 80);
Expand Down Expand Up @@ -1109,7 +1109,7 @@ sub showMessageOnLogin {
|| $session->url->getBackToSiteURL
;

if ($session->setting->get('encryptLogin') && ( ! $redirectUrl =~ /^http/)) {
if ($self->session->config->get('sslEnabled') && $session->setting->get('encryptLogin') && ( ! $redirectUrl =~ /^http/)) {
##A scheme-less URL has been supplied. We need to make it an absolute one
##with a non-encrypted scheme. Otherwise the user will stay in SSL mode.
##We assume that the user put the gateway URL into their URL.
Expand Down
8 changes: 4 additions & 4 deletions lib/WebGUI/Cache.pm
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,11 @@ sub setByHTTP {
my $response = $userAgent->request($request);
if ($response->is_error) {
$self->session->errorHandler->error($url." could not be retrieved.");
return undef;
}
else {
$self->set($response->decoded_content,$ttl);
}
return $response->decoded_content;
my $value = $response->decoded_content;
$self->set($value ,$ttl);
return $value;
}

#-------------------------------------------------------------------
Expand Down
3 changes: 2 additions & 1 deletion lib/WebGUI/Cache/CHI.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package WebGUI::Cache::CHI;
use strict;
use base 'WebGUI::Cache';
use File::Temp qw/tempdir/;
use Clone qw/clone/;
use CHI;

=head1 NAME
Expand Down Expand Up @@ -92,7 +93,7 @@ sub new {
# Create CHI object from config
my $chi;
unless ( $chi = $session->stow->get( "CHI" ) ) {
my $cacheConf = $session->config->get('cache');
my $cacheConf = clone $session->config->get('cache');
$cacheConf->{namespace} = $namespace;
$cacheConf->{is_size_aware} = 1;

Expand Down
2 changes: 1 addition & 1 deletion lib/WebGUI/Crud.pm
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,7 @@ sub update {
}

# set last updated
$data->{lastUpdated} ||= WebGUI::DateTime->new($session, time())->toDatabase;
$dbData->{lastUpdated} = $data->{lastUpdated} ||= WebGUI::DateTime->new($session, time())->toDatabase;

# update memory
my $refId = id $self;
Expand Down
7 changes: 5 additions & 2 deletions lib/WebGUI/Group.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1625,8 +1625,11 @@ sub resetGroupFields {
##Note, I did assets in SQL instead of using the API because you would have to
##instanciate every version of the asset that used the group. This should be much quicker
ASSET: foreach my $assetClass ($db->buildArray('SELECT DISTINCT className FROM asset')) {
next ASSET unless $db->quickScalar( "SELECT COUNT(*) FROM asset WHERE className=?", [$assetClass] );
my $definition = WebGUI::Pluggable::instanciate($assetClass, 'definition', [$session]);
my $definition = eval { WebGUI::Pluggable::instanciate($assetClass, 'definition', [$session]); };
if ($@) {
$session->log->error("Unable to load className: " . $assetClass . " when looking for asset definitions: " . $@);
next ASSET;
}
SUBDEF: foreach my $subdef (@{ $definition }) {
next SUBDEF if exists $tableCache->{$subdef->{tableName}};
PROP: while (my ($fieldName, $properties) = each %{ $subdef->{properties} }) {
Expand Down
1 change: 1 addition & 0 deletions lib/WebGUI/Help/Account.pm
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ our $HELP = {
isa => [ ],
fields => [ ],
variables => [
{ name => "profile_user_id", },
{ name => "user_full_name", },
{ name => "user_member_since", },
{ name => "view_profile_url", },
Expand Down
1 change: 1 addition & 0 deletions lib/WebGUI/Help/Asset_Post.pm
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ our $HELP = {
{ 'name' => 'isNewThread' },
{ 'name' => 'archive.form' },
{ 'name' => 'sticky.form' },
{ 'name' => 'keywords.form' },
{ 'name' => 'lock.form' },
{ 'name' => 'isThread' },
{ 'name' => 'isEdit' },
Expand Down
2 changes: 1 addition & 1 deletion lib/WebGUI/Macro/L_loginBox.pm
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ sub process {
}

my $action;
if ($session->setting->get("encryptLogin")) {
if ($session->config->get('sslEnabled') && $session->setting->get("encryptLogin")) {
my $uri = URI->new($session->url->page(undef,1));
$uri->scheme('https');
$uri->host_port($uri->host);
Expand Down
9 changes: 8 additions & 1 deletion lib/WebGUI/Mail/Send.pm
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,14 @@ sub create {
}
}
}
my $from = $headers->{from} || $session->setting->get('companyName') . " <".$session->setting->get("companyEmail").">";
my $from = $headers->{from};
$from ||= do {
my $CoNa = $session->setting->get('companyName');
my $CoEm = $session->setting->get("companyEmail");
$CoNa =~ s/"//g;
qq{"$CoNa" <$CoEm>}
};

my $type = $headers->{contentType} || "multipart/mixed";
my $replyTo = $headers->{replyTo} || $session->setting->get("mailReturnPath");

Expand Down
6 changes: 3 additions & 3 deletions lib/WebGUI/URL/Uploads.pm
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ sub handler {
}
else {
my $privs = JSON->new->decode($fileContents);
@users = @{ $privs->{users} };
@groups = @{ $privs->{groups} };
@assets = @{ $privs->{assets} };
@users = @{ $privs->{users} || [] };
@groups = @{ $privs->{groups} || [] };
@assets = @{ $privs->{assets} || [] };
$state = $privs->{state};
}

Expand Down
Loading