From e4bf3c60b016074df2fd35ba4de3e149089f1c59 Mon Sep 17 00:00:00 2001 From: Matthew Wilson Date: Tue, 3 Jan 2006 05:12:51 +0000 Subject: [PATCH] fixing some typos. also the File/Storage bug. also fixing the changelogs. --- docs/changelog/6.x.x.txt | 5 ++--- lib/WebGUI.pm | 13 +++++++------ lib/WebGUI/Asset/File.pm | 8 ++++---- lib/WebGUI/SQL.pm | 11 ++++++----- lib/WebGUI/Session.pm | 4 ++-- lib/WebGUI/Storage.pm | 10 +++------- 6 files changed, 24 insertions(+), 27 deletions(-) diff --git a/docs/changelog/6.x.x.txt b/docs/changelog/6.x.x.txt index 7e7dab096..1ac5da97a 100644 --- a/docs/changelog/6.x.x.txt +++ b/docs/changelog/6.x.x.txt @@ -1,8 +1,6 @@ 6.9.0 - Converted WebGUI to use a new object oriented session system. More details in migation.txt. - - fix [ 1379384 ] image uploads to non-public pages - - fixed a problem with SynchFileToLDAP hourly script. 6.8.4 @@ -10,7 +8,7 @@ ilance.nl) - fix [ 1379915 ] Survey can only be completed once per user - Fixed broken UI Level examples in the config file. - - fixed a bug in SyncProfilesToLDAP + - fixed a bug in SyncProfilesToLDAP script - fix [ 1387242 ] uploadsHandler fails - fix [ 1389086 ] 6.8.3 RichEdit buttons disappear - fix [ 1379915 ] Survey can only be completed once per user @@ -20,6 +18,7 @@ - fix [ 1387505 ] Hover help not working on Matrix - fix [ 1393867 ] Data Form Not Emailing - fix [ 1392643 ] 2006 Calendar dates are not correct? + - fix [ 1384794 ] editSave on an existing File or Image asset loses storageId. - Removed the If macro, since it was scheduled for removal in 6.8.0. diff --git a/lib/WebGUI.pm b/lib/WebGUI.pm index 998fff388..f0393cf2e 100644 --- a/lib/WebGUI.pm +++ b/lib/WebGUI.pm @@ -67,8 +67,8 @@ sub contentHandler { ### Open new or existing user session based on user-agent's cookie. my $session = WebGUI::Session->open($s->dir_config('WebguiRoot'),$r->dir_config('WebguiConfig'),$r, $s); ### form variables - foreach ($session{req}->param) { - $session{form}{$_} = $session{req}->body($_) || $session{req}->param($_); + foreach ($session->{_request}->param) { + $session{form}{$_} = $session->{_request}->body($_) || $session->{_request}->param($_); } if ($session->env->get("HTTP_X_MOZ") eq "prefetch") { # browser prefetch is a bad thing $session->http->setStatus("403","We don't allow prefetch, because it increases bandwidth, hurts stats, and can break web sites."); @@ -114,8 +114,8 @@ sub page { $method = "view"; } } - $output = tryAssetMethod($asset,$method); - $output = tryAssetMethod($asset,"view") unless ($method eq "view" || $output); + $output = tryAssetMethod($session,$asset,$method); + $output = tryAssetMethod($session,$asset,"view") unless ($method eq "view" || $output); } } if ($output eq "") { @@ -167,14 +167,15 @@ sub setup { #------------------------------------------------------------------- sub tryAssetMethod { + my $session = shift; my $asset = shift; my $method = shift; $session{asset} = $asset; my $methodToTry = "www_".$method; my $output = eval{$asset->$methodToTry()}; if ($@) { - WebGUI::ErrorHandler::warn("Couldn't call method ".$method." on asset for url: ".$session{requestedUrl}." Root cause: ".$@); - $output = tryAssetMethod($asset,'view') if ($method ne "view"); + $session->errorHandler->warn("Couldn't call method ".$method." on asset for url: ".$session{requestedUrl}." Root cause: ".$@); + $output = tryAssetMethod($session,$asset,'view') if ($method ne "view"); } return $output; } diff --git a/lib/WebGUI/Asset/File.pm b/lib/WebGUI/Asset/File.pm index 74dcb33c2..9a444db2d 100644 --- a/lib/WebGUI/Asset/File.pm +++ b/lib/WebGUI/Asset/File.pm @@ -198,13 +198,13 @@ sub processPropertiesFromFormPost { delete $self->{_storageLocation}; my $storage = $self->getStorageLocation; my $filename = $storage->addFileFromFormPost("file",1); - if (defined $filename) { + if (defined $filename && $filename ne $self->get("filename")) { my %data; $data{filename} = $filename; $data{storageId} = $storage->getId; - $data{title} = $filename unless ($self->session->form->process("title")); - $data{menuTitle} = $filename unless ($self->session->form->process("menuTitle")); - $data{url} = $self->getParent->get('url').'/'.$filename unless ($self->session->form->process("url")); + $data{title} = $filename unless ($session{form}{title}); + $data{menuTitle} = $filename unless ($session{form}{menuTitle}); + $data{url} = $self->getParent->get('url').'/'.$filename unless ($session{form}{url}); $self->update(\%data); } } diff --git a/lib/WebGUI/SQL.pm b/lib/WebGUI/SQL.pm index a10b12f7f..1e290fe19 100644 --- a/lib/WebGUI/SQL.pm +++ b/lib/WebGUI/SQL.pm @@ -18,7 +18,6 @@ use DBI; use Exporter; use strict; use Tie::IxHash; -use WebGUI::ErrorHandler; use WebGUI::Id; use WebGUI::Session; use WebGUI::Utility; @@ -301,7 +300,8 @@ Returns an error code for the current handler. =cut sub errorCode { - return $self->dbh->err; + my $self = shift; + return $self->dbh->err; } @@ -314,7 +314,8 @@ Returns a text error message for the current handler. =cut sub errorMessage { - return $self->dbh->errstr; + my $self = shift; + return $self->dbh->errstr; } @@ -644,7 +645,7 @@ sub setRow { my ($self, $table, $keyColumn, $data, $id) = @_; if ($data->{$keyColumn} eq "new" || $id) { $data->{$keyColumn} = $id || WebGUI::Id::generate(); - $self->write("insert into $table ($keyColumn) values (".$self->quote($data->{$keyColumn}).")", $dbh); + $self->write("insert into $table ($keyColumn) values (".$self->quote($data->{$keyColumn}).")"); } my (@pairs); foreach my $key (keys %{$data}) { @@ -653,7 +654,7 @@ sub setRow { } } if ($pairs[0] ne "") { - $self->write("update $table set ".join(", ", @pairs)." where ".$keyColumn."=".$self->quote($data->{$keyColumn}), $dbh); + $self->write("update $table set ".join(", ", @pairs)." where ".$keyColumn."=".$self->quote($data->{$keyColumn})); } return $data->{$keyColumn}; } diff --git a/lib/WebGUI/Session.pm b/lib/WebGUI/Session.pm index b6e307bbe..443b876ca 100644 --- a/lib/WebGUI/Session.pm +++ b/lib/WebGUI/Session.pm @@ -39,7 +39,7 @@ Package WebGUI::Session =head1 DESCRIPTION -This package is the heart and lifeblood of WebGUI; it is the glue that holds WebGUI together. When you create a session object, you'll immidiately have access to all sorts of other objects. By passing the session object around in code you'll have access to the default database connection, error handler, user and more without having to create it each time. The lends much speed to WebGUI. +This package is the heart and lifeblood of WebGUI; it is the glue that holds WebGUI together. When you create a session object, you'll immediately have access to all sorts of other objects. By passing the session object around in code you'll have access to the default database connection, error handler, user and more without having to create it each time. The lends much speed to WebGUI. B It is important to distinguish the difference between a WebGUI session and a user session. A user session is just part of a WebGUI session. A WebGUI session is all of the basic data the WebGUI needs to operate. @@ -204,7 +204,7 @@ sub errorHandler { unless (exists $self->{_errorHandler}) { $self->{_errorHandler} = WebGUI::Session::ErrorHandler->new($self); } - return $self-{_errorHandler}; + return $self->{_errorHandler}; } #------------------------------------------------------------------- diff --git a/lib/WebGUI/Storage.pm b/lib/WebGUI/Storage.pm index 240165ba9..fa950f3f6 100644 --- a/lib/WebGUI/Storage.pm +++ b/lib/WebGUI/Storage.pm @@ -203,14 +203,9 @@ sub addFileFromFormPost { my $attachmentCount = 1; foreach my $upload ($session{req}->upload($formVariableName)) { return $filename if $attachmentCount > $attachmentLimit; - my $tempPath = $upload->tempname(); $filename = $upload->filename(); next unless $filename; - if ($tempPath =~ /([^\/\\]+)$/) { - $filename = $1; - } else { - $filename = $tempPath; - } + if ($filename =~ /([^\/\\]+)$/) { $filename = $1; } my $type = $self->getFileExtension($filename); if (isIn($type, qw(pl perl sh cgi php asp))) { # make us safe from malicious uploads $filename =~ s/\./\_/g; @@ -233,7 +228,8 @@ sub addFileFromFormPost { return undef; } } - return $filename; + return $filename if $filename; + return undef; }