diff --git a/docs/changelog/6.x.x.txt b/docs/changelog/6.x.x.txt index 9ecb34500..3700df454 100644 --- a/docs/changelog/6.x.x.txt +++ b/docs/changelog/6.x.x.txt @@ -1,4 +1,8 @@ 6.8.2 + - Converted all the max((assetData.)revisionDate) calls to use mysql5/(4.1) + nested queries. + - fix [ 1323184 ] CS Submissions Not Sorting on multiple sites + - fixed some major oversights in the new profile system. - Added macro to return the MIME type to a file, FetchMimeType. - fix [ 1378493 ] 6.7.8 collab post edits (images) - Fixed bug where viewProfile did not show pretty printed values diff --git a/docs/upgrades/upgrade_6.8.1-6.8.2.pl b/docs/upgrades/upgrade_6.8.1-6.8.2.pl index 50b14be0c..79cdaa2d2 100644 --- a/docs/upgrades/upgrade_6.8.1-6.8.2.pl +++ b/docs/upgrades/upgrade_6.8.1-6.8.2.pl @@ -24,10 +24,17 @@ start(); # this line required fixPosts(); fixDataFormMailForm(); +fixTZGoof(); finish(); # this line required +#------------------------------------------------- +sub fixTZGoof { + print "\tFixing default timezone.\n" unless ($quiet); + WebGUI::SQL->write("update userProfileField set dataDefault='\\\'America/Chicago\\\'' where fieldName='timeZone'"); +} + #------------------------------------------------- sub fixPosts { print "\tFixing posts.\n" unless ($quiet); diff --git a/lib/WebGUI/Asset.pm b/lib/WebGUI/Asset.pm index 061c88170..41510ed85 100644 --- a/lib/WebGUI/Asset.pm +++ b/lib/WebGUI/Asset.pm @@ -409,10 +409,10 @@ sub getAssetAdderLinks { } else { $constraint = quoteAndJoin($session{config}{assets}); } - my $sth = WebGUI::SQL->read("select asset.className,asset.assetId,max(assetData.revisionDate) from asset left join assetData on asset.assetId=assetData.assetId where assetData.isPrototype=1 and asset.state='published' and asset.className in ($constraint) group by assetData.assetId"); + my $sth = WebGUI::SQL->read("select asset.className,asset.assetId,assetData.revisionDate from asset left join assetData on asset.assetId=assetData.assetId where assetData.isPrototype=1 and asset.state='published' and asset.className in ($constraint) and assetData.revisionDate=(SELECT max(revisionDate) from assetData where assetData.assetId=asset.assetId) group by assetData.assetId"); while (my ($class,$id,$date) = $sth->array) { - my $asset = WebGUI::Asset->new($id,$class); - next unless ($asset->get("isPrototype") eq '1' && $asset->canView && $asset->canAdd && $asset->getUiLevel <= $session{user}{uiLevel}); + my $asset = WebGUI::Asset->new($id,$class,$date); + next unless ($asset->canView && $asset->canAdd && $asset->getUiLevel <= $session{user}{uiLevel}); my $url = $self->getUrl("func=add;class=".$class.";prototype=".$id); $url = WebGUI::URL::append($url,$addToUrl) if ($addToUrl); $links{$asset->getTitle}{url} = $url; diff --git a/lib/WebGUI/Asset/Post/Thread.pm b/lib/WebGUI/Asset/Post/Thread.pm index 8f2090def..86e8fb2d3 100644 --- a/lib/WebGUI/Asset/Post/Thread.pm +++ b/lib/WebGUI/Asset/Post/Thread.pm @@ -648,17 +648,18 @@ sub view { $var->{'unlock.url'} = $self->getUnlockUrl; my $p = WebGUI::Paginator->new($self->getUrl,$self->getParent->get("postsPerPage")); - my $sql = "select asset.assetId, asset.className, max(assetData.revisionDate) as revisionDate from asset + my $sql = "select asset.assetId, asset.className, assetData.revisionDate as revisionDate from asset left join assetData on assetData.assetId=asset.assetId left join Post on Post.assetId=assetData.assetId and assetData.revisionDate=Post.revisionDate where asset.lineage like ".quote($self->get("lineage").'%') ." and asset.state='published' + and assetData.revisionDate=(SELECT max(revisionDate) from assetData where assetData.assetId=asset.assetId and ( assetData.status in ('approved','archived') or assetData.tagId=".quote($session{scratch}{versionTag}); $sql .= " or assetData.status='pending'" if ($self->getParent->canModerate); $sql .= " or (assetData.ownerUserId=".quote($session{user}{userId})." and assetData.ownerUserId<>'1') - ) + )) group by assetData.assetId order by "; if ($layout eq "flat") { diff --git a/lib/WebGUI/Asset/Template.pm b/lib/WebGUI/Asset/Template.pm index d3f7a96c6..ec76a2c45 100644 --- a/lib/WebGUI/Asset/Template.pm +++ b/lib/WebGUI/Asset/Template.pm @@ -199,7 +199,8 @@ Specify the namespace to build the list for. sub getList { my $class = shift; my $namespace = shift; - my $sth = WebGUI::SQL->read("select asset.assetId, max(assetData.revisionDate) from template left join asset on asset.assetId=template.assetId left join assetData on assetData.revisionDate=template.revisionDate and assetData.assetId=template.assetId where template.namespace=".quote($namespace)." and template.showInForms=1 and asset.state='published' and (assetData.status='approved' or assetData.tagId=".quote($session{scratch}{versionTag}).") group by assetData.assetId order by assetData.title",WebGUI::SQL->getSlave); +my $sql = "select asset.assetId, assetData.revisionDate from template left join asset on asset.assetId=template.assetId left join assetData on assetData.revisionDate=template.revisionDate and assetData.assetId=template.assetId where template.namespace=".quote($namespace)." and template.showInForms=1 and asset.state='published' and assetData.revisionDate=(SELECT max(revisionDate) from assetData where assetData.assetId=asset.assetId and (assetData.status='approved' or assetData.tagId=".quote($session{scratch}{versionTag}).")) order by assetData.title"; + my $sth = WebGUI::SQL->read($sql,WebGUI::SQL->getSlave); my %templates; tie %templates, 'Tie::IxHash'; while (my ($id, $version) = $sth->array) { diff --git a/lib/WebGUI/Asset/Wobject/Collaboration.pm b/lib/WebGUI/Asset/Wobject/Collaboration.pm index ab8652a86..df64fcf74 100644 --- a/lib/WebGUI/Asset/Wobject/Collaboration.pm +++ b/lib/WebGUI/Asset/Wobject/Collaboration.pm @@ -41,7 +41,7 @@ sub appendPostListTemplateVars { my $page = $p->getPageData; my $i = 0; foreach my $row (@$page) { - my $post = WebGUI::Asset::Wobject::Collaboration->new($row->{assetId}, $row->{className}, $row->{revisionDate}); + my $post = WebGUI::Asset->new($row->{assetId}, $row->{className}, $row->{revisionDate}); $post->{_parent} = $self; # caching parent for efficiency my $controls = deleteIcon('func=delete',$post->get("url"),"Delete").editIcon('func=edit',$post->get("url")); if ($self->get("sortBy") eq "lineage") { @@ -952,12 +952,12 @@ sub view { $constraints .= " or assetData.status='pending'"; } $constraints .= ")"; - my $sql = "select asset.assetId,asset.className,max(assetData.revisionDate) as revisionDate + my $sql = "select asset.assetId,asset.className,assetData.revisionDate as revisionDate from Thread left join asset on Thread.assetId=asset.assetId left join Post on Post.assetId=Thread.assetId and Thread.revisionDate = Post.revisionDate left join assetData on assetData.assetId=Thread.assetId and Thread.revisionDate = assetData.revisionDate - where asset.parentId=".quote($self->getId)." and asset.state='published' and asset.className='WebGUI::Asset::Post::Thread' and $constraints + where asset.parentId=".quote($self->getId)." and asset.state='published' and asset.className='WebGUI::Asset::Post::Thread' and assetData.revisionDate=(SELECT max(revisionDate) from assetData where assetData.assetId=asset.assetId) and $constraints group by assetData.assetId order by Thread.isSticky desc, ".$sortBy." ".$sortOrder; my $p = WebGUI::Paginator->new($self->getUrl,$self->get("threadsPerPage")); $self->appendPostListTemplateVars(\%var, $sql, $p); @@ -965,14 +965,6 @@ sub view { return $self->processTemplate(\%var,$self->get("collaborationTemplateId")); } -#------------------------------------------------------------------- -#sub www_edit { -# my $self = shift; -# return WebGUI::Privilege::insufficient() unless $self->canEdit; -# $self->getAdminConsole->setHelp("collaboration add/edit", "Asset_Collaboration"); -# return $self->getAdminConsole->render($self->getEditForm->print,"Edit Collaboration System"); -#} - #------------------------------------------------------------------- =head2 www_search ( ) diff --git a/lib/WebGUI/AssetClipboard.pm b/lib/WebGUI/AssetClipboard.pm index b8784ba5a..ffe9083bf 100644 --- a/lib/WebGUI/AssetClipboard.pm +++ b/lib/WebGUI/AssetClipboard.pm @@ -114,7 +114,7 @@ sub getAssetsInClipboard { my $sth = WebGUI::SQL->read(" select asset.assetId, - max(assetData.revisionDate), + assetData.revisionDate, asset.className from asset @@ -122,6 +122,7 @@ sub getAssetsInClipboard { assetData on asset.assetId=assetData.assetId where asset.state='clipboard' + and assetData.revisionDate=(SELECT max(revisionDate) from assetData where assetData.assetId=asset.assetId) $limit group by assetData.assetId diff --git a/lib/WebGUI/AssetLineage.pm b/lib/WebGUI/AssetLineage.pm index f86cf2490..f3af9b1b0 100644 --- a/lib/WebGUI/AssetLineage.pm +++ b/lib/WebGUI/AssetLineage.pm @@ -338,7 +338,8 @@ sub getLineage { $where .= ' and ('.$rules->{whereClause}.')'; } # based upon all available criteria, let's get some assets - my $columns = "asset.assetId, asset.className, asset.parentId, max(assetData.revisionDate)"; + my $columns = "asset.assetId, asset.className, asset.parentId, assetData.revisionDate"; + $where .= " and assetData.revisionDate=(SELECT max(revisionDate) from assetData where assetData.assetId=asset.assetId and (assetData.status='approved' or assetData.tagId=".quote($session{scratch}{versionTag}).")) "; my $sortOrder = ($rules->{invertTree}) ? "asset.lineage desc" : "asset.lineage asc"; if (exists $rules->{orderByClause}) { $sortOrder = $rules->{orderByClause}; diff --git a/lib/WebGUI/AssetPackage.pm b/lib/WebGUI/AssetPackage.pm index edd0157bb..c7fa570a8 100644 --- a/lib/WebGUI/AssetPackage.pm +++ b/lib/WebGUI/AssetPackage.pm @@ -47,27 +47,22 @@ Returns an array of hashes containing title, assetId, and className for all asse sub getPackageList { my $self = shift; my @assets; - my $sth = WebGUI::SQL->read(" + my $sql = " select asset.assetId, - max(assetData.revisionDate), + assetData.revisionDate, asset.className from asset left join assetData on asset.assetId=assetData.assetId where - assetData.isPackage=1 and - ( - assetData.status='approved' or - assetData.tagId=".quote($session{scratch}{versionTag})." - ) and - asset.state='published' - group by - assetData.assetId - order by - assetData.title desc - "); + assetData.isPackage=1 + and assetData.revisionDate=(SELECT max(revisionDate) from assetData where assetData.assetId=asset.assetId and + (assetData.status='approved'"; + $sql .= " or assetData.tagId=".quote($session{scratch}{versionTag}) if ($session{scratch}{versionTag}); + $sql .= ")) and asset.state='published' group by assetData.assetId order by assetData.title desc"; + my $sth = WebGUI::SQL->read($sql); while (my ($id, $date, $class) = $sth->array) { my $asset = WebGUI::Asset->new($id,$class); push(@assets, $asset) if ($asset->get("isPackage")); diff --git a/lib/WebGUI/AssetTrash.pm b/lib/WebGUI/AssetTrash.pm index 55a751bba..a26fdf51d 100644 --- a/lib/WebGUI/AssetTrash.pm +++ b/lib/WebGUI/AssetTrash.pm @@ -64,7 +64,7 @@ sub getAssetsInTrash { my $sth = WebGUI::SQL->read(" select asset.assetId, - max(assetData.revisionDate), + assetData.revisionDate, asset.className from asset @@ -72,6 +72,7 @@ sub getAssetsInTrash { assetData on asset.assetId=assetData.assetId where asset.state='trash' + and assetData.revisionDate=(SELECT max(revisionDate) from assetData where assetData.assetId=asset.assetId) $limit group by assetData.assetId diff --git a/lib/WebGUI/Auth/WebGUI.pm b/lib/WebGUI/Auth/WebGUI.pm index cc6cad93a..34cec8362 100644 --- a/lib/WebGUI/Auth/WebGUI.pm +++ b/lib/WebGUI/Auth/WebGUI.pm @@ -18,6 +18,7 @@ use WebGUI::Auth; use WebGUI::DateTime; use WebGUI::FormProcessor; use WebGUI::HTMLForm; +use WebGUI::HTTP; use WebGUI::Macro; use WebGUI::Mail; use WebGUI::Session; @@ -472,6 +473,7 @@ sub getPasswordRecoveryTemplateId { sub login { my $self = shift; if(!$self->authenticate($session{form}{username},$session{form}{identifier})){ + WebGUI::HTTP::setStatus("401","Incorrect Credentials"); WebGUI::ErrorHandler::security("login to account ".$session{form}{username}." with invalid information."); return $self->displayLogin("

".WebGUI::International::get(70)."

".$self->error); } diff --git a/lib/WebGUI/ErrorHandler.pm b/lib/WebGUI/ErrorHandler.pm index 8da3e5988..62fc8b774 100644 --- a/lib/WebGUI/ErrorHandler.pm +++ b/lib/WebGUI/ErrorHandler.pm @@ -179,6 +179,7 @@ sub fatal { Apache2::RequestUtil->request->content_type('text/html') if ($WebGUI::Session::session{req}); $logger->fatal($message); $logger->debug("Stack trace for FATAL ".$message."\n".getStackTrace()); + print WebGUI::HTTP::getHeader if ($WebGUI::Session::session{req}); unless (canShowDebug()) { #NOTE: You can't internationalize this because with some types of errors that would cause an infinite loop. print "

Problem With Request

@@ -224,7 +225,7 @@ Returns a text message containing all of the session variables. sub getSessionVars { my $data; while (my ($section, $hash) = each %WebGUI::Session::session) { - if ($section eq "debug") { + if ($section eq "debug" || $section eq 'replacements') { next; } elsif (ref $hash eq 'HASH') { while (my ($key, $value) = each %$hash) { diff --git a/lib/WebGUI/Operation/Profile.pm b/lib/WebGUI/Operation/Profile.pm index 500b069e1..2237ad83b 100644 --- a/lib/WebGUI/Operation/Profile.pm +++ b/lib/WebGUI/Operation/Profile.pm @@ -76,7 +76,13 @@ sub validateProfileData { my $error = ""; my $warning = ""; foreach my $field (@{WebGUI::ProfileField->getEditableFields}) { - $data{$field->getId} = $field->formProcess; + my $fieldValue = $field->formProcess; + use Data::Dumper;print $field->getLabel.' : '.Dumper($fieldValue); + if (ref $fieldValue eq "ARRAY") { + $data{$field->getId} = $$fieldValue[0]; + } else { + $data{$field->getId} = $fieldValue; + } if ($field->isRequired && !$data{$field->getId}) { $error .= '
  • '.$field->getLabel.' '.WebGUI::International::get(451).'
  • '; } elsif ($field->getId eq "email" && isDuplicateEmail($data{$field->getId})) { diff --git a/lib/WebGUI/ProfileField.pm b/lib/WebGUI/ProfileField.pm index ccc41987e..e95d4af84 100644 --- a/lib/WebGUI/ProfileField.pm +++ b/lib/WebGUI/ProfileField.pm @@ -163,7 +163,17 @@ Returns the value retrieved from a form post. sub formProcess { my $self = shift; - return WebGUI::HTML::filter(WebGUI::FormProcessor::process($self->getId,$self->get("fieldType"),WebGUI::Operation::Shared::secureEval($self->get("possibleValues"))), "javascript"); + my $result = WebGUI::FormProcessor::process($self->getId,$self->get("fieldType"),WebGUI::Operation::Shared::secureEval($self->get("dataDefault"))); + if (ref $result eq "ARRAY") { + my @results = @$result; + for (my $count=0;$countprepare($sql) or WebGUI::ErrorHandler::fatal("Couldn't prepare statement: ".$sql." : ". DBI->errstr); + push(@{$WebGUI::Session::session{SQLquery}},$sql); + my $sth = $dbh->prepare($sql) or WebGUI::ErrorHandler::fatal("Couldn't prepare statement: ".$sql." : ". DBI->errstr); bless ({_sth => $sth, _sql => $sql}, $class); } @@ -638,7 +636,6 @@ The database handler. Defaults to the WebGUI database handler. sub quote { my $value = shift; - return "''" unless defined $value; my $dbh = shift || _getDefaultDb(); return $dbh->quote($value); } diff --git a/lib/WebGUI/User.pm b/lib/WebGUI/User.pm index 9279f08bd..3b7f34339 100644 --- a/lib/WebGUI/User.pm +++ b/lib/WebGUI/User.pm @@ -269,7 +269,7 @@ sub new { if ($profile{$key} eq "" && $default{$key}) { $value = eval($default{$key}); if (ref $value eq "ARRAY") { - $profile{$key} = $$value[0]; + $profile{$key} = $$value[0]; } else { $profile{$key} = $value; }