From 3d79b8b26c35d439e055f601ddba0f50ba732ad9 Mon Sep 17 00:00:00 2001 From: Arjan Widlaak Date: Fri, 17 Dec 2010 23:06:27 +0100 Subject: [PATCH 1/6] - fixed bug 11997: maximumAssets is ignored - fixed bug 11998: maximumAssets prevents editing existing assets if maximum is reached --- docs/changelog/7.x.x.txt | 2 ++ lib/WebGUI/Asset.pm | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index c056ae177..2aaffe01d 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -2,6 +2,8 @@ - added #11968: use the language override in the registration form (Jukka Raimovaara / Mentalhouse Oy) - Changed Carousel to use TinyMCE with WebGUI plugins - fixed #11984: No JS allows invalid dates in Event asset + - fixed #11997: maximumAssets in config is ignored (Arjan Widlak / United Knowledge) + - fixed #11998: maximumAssets affects not only new assets, but als prevents editing existing assets if maximum is reached 7.10.6 - fixed #11974: Toolbar icons unclickable in Webkit using HTML5 diff --git a/lib/WebGUI/Asset.pm b/lib/WebGUI/Asset.pm index 0865c74c7..020bd95a7 100644 --- a/lib/WebGUI/Asset.pm +++ b/lib/WebGUI/Asset.pm @@ -2999,10 +2999,10 @@ sub www_editSave { my $isNewAsset = $session->form->process("assetId") eq "new" ? 1 : 0; return $session->privilege->locked() if (!$self->canEditIfLocked and !$isNewAsset); return $session->privilege->insufficient() unless $self->canEdit && $session->form->validToken; - if ($self->session->config("maximumAssets")) { + if ($self->session->config->get("maximumAssets")) { my ($count) = $self->session->db->quickArray("select count(*) from asset"); my $i18n = WebGUI::International->new($self->session, "Asset"); - return $self->session->style->userStyle($i18n->get("over max assets")) if ($self->session->config("maximumAssets") <= $count); + return $self->session->style->userStyle($i18n->get("over max assets")) if ( $self->session->config->get("maximumAssets") <= $count && $isNewAsset ); } my $object; if ($isNewAsset) { From 196d3b0437fd4007e87ea928068014f4fe025868 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Wed, 22 Dec 2010 11:26:55 -0800 Subject: [PATCH 2/6] Uncaching the user should be last thing that is done before removing data from the database. --- lib/WebGUI/User.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/WebGUI/User.pm b/lib/WebGUI/User.pm index 867fed90f..aed33918c 100644 --- a/lib/WebGUI/User.pm +++ b/lib/WebGUI/User.pm @@ -380,7 +380,6 @@ sub delete { my $userId = $self->userId; my $session = $self->session; my $db = $session->db; - $self->uncache; foreach my $groupId ( @{ $self->getGroups } ) { my $group = WebGUI::Group->new($session, $groupId); @@ -429,6 +428,7 @@ sub delete { $credit->purge; # remove user itself + $self->uncache; $db->write("DELETE FROM userProfileData WHERE userId=?",[$userId]); $db->write("DELETE FROM users WHERE userId=?",[$userId]); } From 21e1c41596bd6f74e60aa73966a2a8df95283edf Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Wed, 22 Dec 2010 13:47:40 -0800 Subject: [PATCH 3/6] Document the delete user bug fix. --- docs/changelog/7.x.x.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 2aaffe01d..5e451c118 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -4,6 +4,7 @@ - fixed #11984: No JS allows invalid dates in Event asset - fixed #11997: maximumAssets in config is ignored (Arjan Widlak / United Knowledge) - fixed #11998: maximumAssets affects not only new assets, but als prevents editing existing assets if maximum is reached + - fixed #12003: WebGUI::User->delete leaves around cache data 7.10.6 - fixed #11974: Toolbar icons unclickable in Webkit using HTML5 From 4e0e62b2022cee1a1b39a790e88bb54db5076793 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Wed, 22 Dec 2010 14:10:58 -0800 Subject: [PATCH 4/6] Fix tests that were broken due to the language override merge. --- t/Auth.t | 23 ++++++++++++++++++++++- t/ProfileField.t | 27 ++++++++++++++++++++++++++- 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/t/Auth.t b/t/Auth.t index 35aa8db63..32b9ef6fe 100644 --- a/t/Auth.t +++ b/t/Auth.t @@ -47,8 +47,15 @@ $session->{_request} = $request; $auth = WebGUI::Auth->new( $session, $AUTH_METHOD ); my $username = $session->id->generate; -my $language = "German"; +my $language = "PigLatin"; push @cleanupUsernames, $username; +installPigLatin(); +WebGUI::Test->addToCleanup(sub { + unlink File::Spec->catfile(WebGUI::Test->lib, qw/WebGUI i18n PigLatin WebGUI.pm/); + unlink File::Spec->catfile(WebGUI::Test->lib, qw/WebGUI i18n PigLatin.pm/); + rmdir File::Spec->catdir(WebGUI::Test->lib, qw/WebGUI i18n PigLatin/); +}); + $session->scratch->setLanguageOverride($language); $output = $auth->createAccountSave( $username, { }, "PASSWORD" ); WebGUI::Test->addToCleanup(sub { @@ -77,6 +84,7 @@ is( ); is $session->user->profileField('language'), $language, 'languageOverride is taken in to account in createAccountSave'; +$session->scratch->delete('language'); ##Remove language override # Session Cleanup $session->{_request} = $oldRequest; @@ -106,4 +114,17 @@ is $output, undef, 'login returns undef when showMessageOnLogin is false'; # Session Cleanup $session->{_request} = $oldRequest; +sub installPigLatin { + use File::Copy; + mkdir File::Spec->catdir(WebGUI::Test->lib, 'WebGUI', 'i18n', 'PigLatin'); + copy( + WebGUI::Test->getTestCollateralPath('WebGUI.pm'), + File::Spec->catfile(WebGUI::Test->lib, qw/WebGUI i18n PigLatin WebGUI.pm/) + ); + copy( + WebGUI::Test->getTestCollateralPath('PigLatin.pm'), + File::Spec->catfile(WebGUI::Test->lib, qw/WebGUI i18n PigLatin.pm/) + ); +} + diff --git a/t/ProfileField.t b/t/ProfileField.t index 5a35f24ae..82d530d19 100644 --- a/t/ProfileField.t +++ b/t/ProfileField.t @@ -18,6 +18,7 @@ use strict; use lib "$FindBin::Bin/lib"; use Test::More; use Data::Dumper; +use File::Spec; use WebGUI::Test; # Must use this before any other WebGUI modules use WebGUI::Session; use WebGUI::Form::Text; @@ -92,11 +93,19 @@ ok( $ff = $langField->formField, 'formField method returns something, langua $ffvalue = $session->user->profileField('language'); like( $ff, qr/value="$ffvalue"[^>]+selected/, 'html returned contains value, language field, session user' ); +installPigLatin(); +WebGUI::Test->addToCleanup(sub { + unlink File::Spec->catfile(WebGUI::Test->lib, qw/WebGUI i18n PigLatin WebGUI.pm/); + unlink File::Spec->catfile(WebGUI::Test->lib, qw/WebGUI i18n PigLatin.pm/); + rmdir File::Spec->catdir(WebGUI::Test->lib, qw/WebGUI i18n PigLatin/); +}); + $ff = undef; -$ffvalue = "German"; +$ffvalue = "PigLatin"; $session->scratch->setLanguageOverride($ffvalue); ok( $ff = $langField->formField, 'formField method returns something, language field, session user, languageOverride' ); like( $ff, qr/value="$ffvalue"[^>]+selected/, 'html returned contains value, language field, session user, languageOverride' ); +$session->scratch->delete('language'); ########################################################### # @@ -204,3 +213,19 @@ $newProfileField3->set({ required => 1}); is ($newProfileField3->get('required'), 1, 'set required = 1'); is ($newProfileField3->get('editable'), 1, '... editable = 1'); $newProfileField3->delete; + + +sub installPigLatin { + use File::Copy; + mkdir File::Spec->catdir(WebGUI::Test->lib, 'WebGUI', 'i18n', 'PigLatin'); + copy( + WebGUI::Test->getTestCollateralPath('WebGUI.pm'), + File::Spec->catfile(WebGUI::Test->lib, qw/WebGUI i18n PigLatin WebGUI.pm/) + ); + copy( + WebGUI::Test->getTestCollateralPath('PigLatin.pm'), + File::Spec->catfile(WebGUI::Test->lib, qw/WebGUI i18n PigLatin.pm/) + ); +} + + From b80b04420284ab5482a1702e8d4a86c26dee8e6f Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Thu, 23 Dec 2010 00:24:56 -0800 Subject: [PATCH 5/6] Ham handed attempt to try and find the maximum revision date. --- sbin/findBrokenAssets.pl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sbin/findBrokenAssets.pl b/sbin/findBrokenAssets.pl index 048f00c2e..9186a1ae3 100644 --- a/sbin/findBrokenAssets.pl +++ b/sbin/findBrokenAssets.pl @@ -65,11 +65,14 @@ my $totalAsset = $session->db->quickScalar('SELECT COUNT(*) FROM asset'); my $totalAssetData = $session->db->quickScalar('SELECT COUNT( DISTINCT( assetId ) ) FROM assetData' ); my $total = $totalAsset >= $totalAssetData ? $totalAsset : $totalAssetData; -# Order by to put corrupt parents before corrupt children +# Order by lineage to put corrupt parents before corrupt children # Join assetData to get all asset and assetData my $sql = "SELECT * FROM asset LEFT JOIN assetData USING ( assetId ) GROUP BY assetId ORDER BY lineage ASC"; my $sth = $session->db->read($sql); +##Guarantee that we get the most recent revisionDate +my $max_revision = $session->db->prepare('select max(revisionDate) from assetData where assetId=?'); + my $count = 1; my %classTables; # Cache definition lookups while ( my %row = $sth->hash ) { @@ -85,6 +88,8 @@ while ( my %row = $sth->hash ) { eval "require $row{className}"; [ map { $_->{tableName} } reverse @{ $row{className}->definition($session) } ]; }; + $max_revision->execute([$row{assetId}]); + ($row{revisionDate}) = $max_revision->array(); $row{revisionDate} ||= time; for my $table ( @{$classTables} ) { From 43903a9e0e1c796de045ff86cafc7d620879b4bf Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Thu, 23 Dec 2010 00:32:16 -0800 Subject: [PATCH 6/6] Close all statement handles. --- sbin/findBrokenAssets.pl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sbin/findBrokenAssets.pl b/sbin/findBrokenAssets.pl index 9186a1ae3..2a162a2d8 100644 --- a/sbin/findBrokenAssets.pl +++ b/sbin/findBrokenAssets.pl @@ -201,6 +201,8 @@ while ( my %row = $sth->hash ) { } ## end if ( !$asset ) progress( $total, $count++ ); } ## end while ( my %row = $sth->hash) +$sth->finish; +$max_revision->finish; finish($session); print "\n";