updated webgui to run with Config::JSON 2.04

This commit is contained in:
JT Smith 2008-01-25 05:10:33 +00:00
parent fb434a8b3a
commit 34fd8c9245
20 changed files with 56 additions and 51 deletions

View file

@ -9,6 +9,7 @@
- fix: Gallery is now part of the default set of assets
- fix: replaced return; with return undef; and changed WGBP.
- Default maximum attachment size is now 100kB
- Updated to work with the new JSON 2.04 module. See gotcha.txt for details.
- removed old CS based photo gallery prototype in favor of the new gallery
asset

View file

@ -14,6 +14,13 @@ save you many hours of grief.
located at:
WebGUI/docs/upgrades/packages-7.5.0/root_import_timetracking_user.wgpkg
* WebGUI requires newer versions of some existing modules. Be sure to
install them BEFORE upgrading. They are:
JSON 2.04
Config::JSON 1.1.2
7.5.0
--------------------------------------------------------------------
* Event related links are now displayed using a template loop
@ -25,12 +32,14 @@ save you many hours of grief.
upgrade to the beta. If you upgrade past 7.4.21 then you cannot
use the beta.
7.4.12
--------------------------------------------------------------------
* Any customizations made to the Matrix default Search, Compare or
Detailed listing templates will be lost. Please back up your
custom templates before running the upgrade.
7.4.11
--------------------------------------------------------------------
* The 7.4.8 upgrade script had an error for sites using Dashboards.

View file

@ -152,7 +152,7 @@ sub loadSiteData {
}
else {
my $siteData = {};
eval { $siteData = JSON::jsonToObj($response->content); };
eval { $siteData = JSON::from_json($response->content); };
if ($@) {
$self->error("Couldn't fetch Spectre configuration data for $key");
}

View file

@ -19,7 +19,7 @@ use DateTime;
use HTTP::Request::Common;
use HTTP::Cookies;
use POE qw(Component::Client::HTTP);
use JSON 'objToJson';
use JSON qw/ to_json /;
#-------------------------------------------------------------------
@ -337,7 +337,7 @@ sub getJsonStatus {
next unless $self->{_jobs}->{$key}->{sitename} eq $sitename;
$data{$key} = $self->{_jobs}->{$key};
}
$kernel->call(IKC => post => $rsvp, objToJson(\%data));
$kernel->call(IKC => post => $rsvp, to_json(\%data));
}

View file

@ -20,7 +20,7 @@ use HTTP::Cookies;
use POE qw(Component::Client::HTTP);
use POE::Queue::Array;
use Tie::IxHash;
use JSON 'objToJson';
use JSON qw/ to_json /;
#-------------------------------------------------------------------
@ -223,7 +223,7 @@ sub editWorkflowPriority {
if ($ackPriority != $newPriority) {
# return an error
my $error = 'edit priority setting error';
$kernel->call(IKC=>post=>$rsvp, objToJson({message => $error}));
$kernel->call(IKC=>post=>$rsvp, to_json({message => $error}));
}
$found = 1;
last;
@ -232,11 +232,11 @@ sub editWorkflowPriority {
if (! $found) {
# return an error message
my $error = 'edit priority instance not found error';
$kernel->call(IKC=>post=>$rsvp, objToJson({message => $error}));
$kernel->call(IKC=>post=>$rsvp, to_json({message => $error}));
}
else {
# return success message
$kernel->call(IKC=>post=>$rsvp, objToJson({message => 'edit priority success'}));
$kernel->call(IKC=>post=>$rsvp, to_json({message => 'edit priority success'}));
}
}
@ -338,7 +338,7 @@ sub getJsonStatus {
}
}
$kernel->call(IKC=>post=>$rsvp, objToJson(\%output));
$kernel->call(IKC=>post=>$rsvp, to_json(\%output));
}
#-------------------------------------------------------------------

View file

@ -19,7 +19,7 @@ use base 'WebGUI::Asset::File::Image';
use Carp qw( carp croak );
use Image::ExifTool qw( :Public );
use JSON;
use JSON qw/ to_json from_json /;
use Tie::IxHash;
use WebGUI::DateTime;
@ -439,7 +439,7 @@ sub getTemplateVars {
}
### Format exif vars
my $exif = jsonToObj( delete $var->{exifData} );
my $exif = from_json( delete $var->{exifData} );
$exif = ImageInfo( $self->getStorageLocation->getPath( $self->get("filename") ) );
for my $tag ( keys %$exif ) {
# Hash of exif_tag => value
@ -679,9 +679,8 @@ sub updateExifDataFromFile {
return undef;
my $info = ImageInfo( $storage->getPath( $self->get('filename') ) );
use Data::Dumper; $self->session->errorHandler->info( Dumper $info );
$self->update({
exifData => objToJson( $info ),
exifData => to_json( $info ),
});
}

View file

@ -2,8 +2,6 @@ package WebGUI::Asset::Wobject::Calendar;
use strict;
our $VERSION = "0.0.0";
####################################################################
# WebGUI is Copyright 2001-2007 Plain Black Corporation.
####################################################################
@ -26,7 +24,7 @@ use WebGUI::DateTime;
use base 'WebGUI::Asset::Wobject';
use DateTime;
use JSON;
use JSON qw/to_json/;
=head1 Name
@ -553,7 +551,7 @@ ENDHTML
my $feeds = $self->getFeeds();
$tab->raw('<script type="text/javascript">'."\n");
for my $feedId (keys %$feeds) {
$tab->raw("FeedsManager.addFeed('feeds','".$feedId."',".objToJson($feeds->{$feedId}).");\n");
$tab->raw("FeedsManager.addFeed('feeds','".$feedId."',".to_json($feeds->{$feedId}).");\n");
}
$tab->raw('</script>');

View file

@ -18,7 +18,7 @@ use strict;
use base 'WebGUI::Asset::Wobject';
use Tie::IxHash;
use WebGUI::HTMLForm;
use JSON;
use JSON qw/ to_json /;
use Digest::MD5;
use WebGUI::Workflow::Instance;
use WebGUI::Cache;
@ -952,7 +952,7 @@ sub getBadgeSelector {
};
}
$js = '<script type="text/javascript">
var badges = '.objToJson(\%badgeJS,{autoconv=>0, skipinvalid=>1}).';
var badges = '.to_json(\%badgeJS).';
</script>';
%options = (%options,%{$badges});
$output .= WebGUI::Form::selectBox($self->session,{

View file

@ -192,7 +192,7 @@ sub freezeGraphConfig {
my $self = shift;
my $obj = shift;
return JSON::objToJson($obj);
return JSON::to_json($obj);
}
@ -403,7 +403,7 @@ sub thawGraphConfig {
my $self = shift;
my $string = shift;
return JSON::jsonToObj($string);
return JSON::from_json($string);
}
#-------------------------------------------------------------------

View file

@ -65,7 +65,7 @@ sub exportPackage {
my $storage = WebGUI::Storage->createTemp($self->session);
foreach my $asset (@{$self->getLineage(["self","descendants"],{returnObjects=>1})}) {
my $data = $asset->exportAssetData;
$storage->addFileFromScalar($data->{properties}{lineage}.".json", JSON::objToJson($data,{pretty => 1, indent => 4, autoconv=>0, skipinvalid=>1}));
$storage->addFileFromScalar($data->{properties}{lineage}.".json", JSON->new->pretty->encode($data));
foreach my $storageId (@{$data->{storage}}) {
my $assetStorage = WebGUI::Storage->get($self->session, $storageId);
$assetStorage->tar($storageId.".storage", $storage);
@ -209,8 +209,7 @@ sub importPackage {
next unless ($decompressed->getFileExtension($file) eq "json");
$error->info("Found data file $file");
my $data = eval{
local $JSON::UnMapping = 1;
JSON::jsonToObj($decompressed->getFileContentsAsScalar($file))
JSON->new->relaxed(1)->decode($decompressed->getFileContentsAsScalar($file))
};
if ($@ || $data->{properties}{assetId} eq "" || $data->{properties}{className} eq "" || $data->{properties}{revisionDate} eq "") {
$error->error("package corruption: ".$@) if ($@);

View file

@ -18,7 +18,7 @@ package WebGUI::Commerce::Transaction;
use strict;
use WebGUI::SQL;
use WebGUI::Commerce::Payment;
use JSON;
use JSON qw/ from_json to_json /;
#-------------------------------------------------------------------
@ -567,11 +567,11 @@ sub shippingOptions {
$shippingOptions = shift;
if (scalar (keys %{$shippingOptions})) {
$self->{_properties}{shippingOptions} = objToJson($shippingOptions);
$self->{_properties}{shippingOptions} = to_json($shippingOptions);
$self->session->db->write("update transaction set shippingOptions=? where transactionId=?",[$self->{_properties}{shippingOptions},$self->{_transactionId}]);
}
return jsonToObj($self->{_properties}{shippingOptions});
return from_json($self->{_properties}{shippingOptions});
}
#-------------------------------------------------------------------

View file

@ -97,7 +97,7 @@ sub www_spectreGetSiteData {
}
$siteData{cron} = \@schedules;
}
return JSON::objToJson(\%siteData,{autoconv=>0, skipinvalid=>1});
return JSON::to_json(\%siteData);
}
#-------------------------------------------------------------------
@ -144,8 +144,8 @@ sub www_spectreStatus {
}
my %data = (
workflow => jsonToObj($workflowResult),
cron => jsonToObj($cronResult),
workflow => from_json($workflowResult),
cron => from_json($cronResult),
);
my $workflowCount = @{ $data{workflow}{Suspended} } + @{ $data{workflow}{Waiting} } + @{ $data{workflow}{Running} };

View file

@ -21,7 +21,7 @@ use WebGUI::Workflow::Activity;
use WebGUI::Workflow::Instance;
use WebGUI::Utility;
use POE::Component::IKC::ClientLite;
use JSON 'jsonToObj';
use JSON qw/ from_json /;
=head1 NAME
@ -337,7 +337,7 @@ sub www_editWorkflowPriority {
return $ac->render($output, $i18n->get('show running workflows'));
}
my $responseHref = jsonToObj($resultJson);
my $responseHref = from_json($resultJson);
my $message = $i18n->get($responseHref->{message}) || $i18n->get('edit priority unknown error');
return $ac->render($message, $i18n->get('show running workflows'));
@ -577,7 +577,7 @@ ENDCODE
}
if (defined $workflowResult) {
my $workflowsHref = jsonToObj($workflowResult);
my $workflowsHref = from_json($workflowResult);
my $workflowTitleFor = $session->db->buildHashRef(<<"");
SELECT wi.instanceId, w.title

View file

@ -398,7 +398,7 @@ sub showDebug {
$form->{$key} = "********";
}
}
$text = JSON::objToJson($form, {pretty => 1, indent => 4, autoconv=>0, skipinvalid=>1});
$text = JSON->new->pretty->encode($form);
$text =~ s/&/&amp;/sg;
$text =~ s/>/&gt;/sg;
$text =~ s/</&lt;/sg;

View file

@ -25,7 +25,7 @@ use WebGUI::DateTime;
use DateTime::TimeZone;
use LWP::UserAgent;
use JSON qw(objToJson jsonToObj);
use JSON qw(to_json from_json);
=head1 NAME
@ -92,8 +92,8 @@ sub execute {
my $eventList = [];
my $feedList;
if ($instance->getScratch('events')) {
$eventList = jsonToObj($instance->getScratch('events'));
$feedList = jsonToObj($instance->getScratch('feeds'));
$eventList = from_json($instance->getScratch('events'));
$feedList = from_json($instance->getScratch('feeds'));
}
else {
my $ua = LWP::UserAgent->new(agent => "WebGUI");
@ -356,8 +356,8 @@ sub execute {
}
while (@$eventList) {
if ($startTime + 55 < time()) {
$instance->setScratch('events', objToJson($eventList));
$instance->setScratch('feeds', objToJson($feedList));
$instance->setScratch('events', to_json($eventList));
$instance->setScratch('feeds', to_json($feedList));
return $self->WAITING;
}
my $eventData = shift @$eventList;

View file

@ -105,7 +105,7 @@ sub execute {
# See if we're done
if (scalar(@arrayCopy) > 0) {
$instance->setScratch("syndicatedUrls", objToJson(@arrayCopy));
$instance->setScratch("syndicatedUrls", JSON::to_json(@arrayCopy));
return $self->WAITING;
}
@ -139,11 +139,11 @@ sub getSyndicatedUrls {
asset.state='published'"
);
$instance->setScratch("syndicatedUrls", objToJson($urls));
$instance->setScratch("syndicatedUrls", JSON::to_json($urls));
return $urls;
}
return jsonToObj($syndicatedUrls);
return JSON::from_json($syndicatedUrls);
}

View file

@ -116,7 +116,7 @@ sub get {
my $self = shift;
my $name = shift;
if ($name eq "parameters") {
my $parameters = JSON::jsonToObj($self->{_data}{$name});
my $parameters = JSON::from_json($self->{_data}{$name});
return $parameters->{parameters};
}
return $self->{_data}{$name};
@ -298,7 +298,7 @@ sub set {
$self->{_data}{className} = (exists $properties->{className}) ? $properties->{className} : $self->{_data}{className};
$self->{_data}{methodName} = (exists $properties->{methodName}) ? $properties->{methodName} : $self->{_data}{methodName};
if (exists $properties->{parameters}) {
$self->{_data}{parameters} = JSON::objToJson({parameters => $properties->{parameters}},{pretty => 1, indent => 4, autoconv=>0, skipinvalid=>1});
$self->{_data}{parameters} = JSON->new->pretty->encode({parameters => $properties->{parameters}});
}
$self->{_data}{enabled} = 0 unless ($self->{_data}{workflowId});
my $spectre = WebGUI::Workflow::Spectre->new($self->session);

View file

@ -66,7 +66,7 @@ sub create {
my ($isSingleton) = $session->db->quickArray("select count(*) from Workflow where workflowId=? and
mode='singleton'",[$properties->{workflowId}]);
my $params = (exists $properties->{parameters})
? JSON::objToJson({parameters => $properties->{parameters}}, {pretty => 1, indent => 4, autoconv=>0, skipinvalid=>1})
? JSON->new->pretty->encode({parameters => $properties->{parameters}})
: undef;
my ($count) = $session->db->quickArray("select count(*) from WorkflowInstance where workflowId=? and parameters=?",[$properties->{workflowId},$params]);
return undef if ($isSingleton && $count);
@ -147,7 +147,7 @@ sub get {
my $self = shift;
my $name = shift;
if ($name eq "parameters") {
my $parameters = JSON::jsonToObj($self->{_data}{$name});
my $parameters = JSON::from_json($self->{_data}{$name});
return $parameters->{parameters};
}
return $self->{_data}{$name};
@ -416,7 +416,7 @@ sub set {
$self->{_data}{className} = (exists $properties->{className}) ? $properties->{className} : $self->{_data}{className};
$self->{_data}{methodName} = (exists $properties->{methodName}) ? $properties->{methodName} : $self->{_data}{methodName};
if (exists $properties->{parameters}) {
$self->{_data}{parameters} = JSON::objToJson({parameters => $properties->{parameters}}, {pretty => 1, indent => 4, autoconv=>0, skipinvalid=>1});
$self->{_data}{parameters} = JSON->new->pretty->encode({parameters => $properties->{parameters}});
}
$self->{_data}{currentActivityId} = (exists $properties->{currentActivityId}) ? $properties->{currentActivityId} : $self->{_data}{currentActivityId};
$self->{_data}{lastUpdate} = time();

View file

@ -103,8 +103,8 @@ checkModule("HTML::TagFilter",0.07);
checkModule("HTML::Template",2.9);
checkModule("HTML::Template::Expr",0.05,2);
checkModule("XML::RSSLite",0.11);
checkModule("JSON",0.991);
checkModule("Config::JSON","1.1.0");
checkModule("JSON",2.04);
checkModule("Config::JSON","1.1.2");
checkModule("Text::CSV_XS","0.26");
checkModule("Net::Subnets",0.21);
checkModule("Finance::Quote",1.08);

View file

@ -19,7 +19,6 @@ use strict;
use DBI;
use File::Path;
use Getopt::Long;
use JSON;
use WebGUI::Config;
use WebGUI::Session;
use WebGUI::Utility;
@ -331,8 +330,8 @@ STOP
sub checkVersion {
$_[0] =~ /(\d+)\.(\d+)\.(\d+)/;
my $goal = 7;
my $feature = 3;
my $fix = 22;
my $feature = 4;
my $fix = 21;
if ($1 > $goal) {
return 1;
}