removing first parameter from WebGUI::Session->open and other cleanups

This commit is contained in:
Graham Knop 2010-02-23 16:16:09 -06:00
parent 29df110409
commit a141de0ebf
39 changed files with 150 additions and 291 deletions

View file

@ -10,15 +10,9 @@
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
our ($webguiRoot);
BEGIN {
$webguiRoot = "../..";
unshift (@INC, $webguiRoot."/lib");
}
use strict;
use Getopt::Long;
use WebGUI::Paths -inc;
use WebGUI::Session;
use WebGUI::Storage;
use WebGUI::Asset;
@ -86,7 +80,7 @@ sub start {
'configFile=s'=>\$configFile,
'quiet'=>\$quiet
);
my $session = WebGUI::Session->open($webguiRoot,$configFile);
my $session = WebGUI::Session->open($configFile);
$session->user({userId=>3});
my $versionTag = WebGUI::VersionTag->getWorking($session);
$versionTag->set({name=>"Upgrade to ".$toVersion});

View file

@ -10,16 +10,10 @@
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
our ($webguiRoot);
BEGIN {
$webguiRoot = "../..";
unshift (@INC, $webguiRoot."/lib");
}
use strict;
use File::Path qw/rmtree/;
use Getopt::Long;
use WebGUI::Paths -inc;
use WebGUI::Session;
use WebGUI::Storage;
use WebGUI::Asset;
@ -116,7 +110,7 @@ sub start {
'configFile=s'=>\$configFile,
'quiet'=>\$quiet
);
my $session = WebGUI::Session->open($webguiRoot,$configFile);
my $session = WebGUI::Session->open($configFile);
$session->user({userId=>3});
my $versionTag = WebGUI::VersionTag->getWorking($session);
$versionTag->set({name=>"Upgrade to ".$toVersion});

View file

@ -98,7 +98,7 @@ sub authen {
# determine session id
my $sessionId = $cookies->{$config->getCookieName};
my $session = WebGUI::Session->open($server->dir_config('WebguiRoot'),$config->getFilename, $request, $server, $sessionId);
my $session = WebGUI::Session->open($config, $request, $server, $sessionId);
my $log = $session->log;
$request->pnotes(wgSession => $session);

View file

@ -264,9 +264,7 @@ sub exportAsHtml {
# now, create a new session as the user doing the exports. this is so that
# the exported assets are taken from that user's perspective.
my $exportSession = WebGUI::Session->open(
$session->config->getFilename,
);
my $exportSession = WebGUI::Session->open($session->config);
my $esGuard = Scope::Guard->new(sub {
$exportSession->var->end;
$exportSession->close;
@ -497,9 +495,7 @@ sub exportGetDescendants {
# open a temporary session as the user doing the exporting so we don't get
# assets that they can't see
if ( ref $user && $user->isa('WebGUI::User') ) {
$session = WebGUI::Session->open(
$session->config->getFilename,
);
$session = WebGUI::Session->open($session->config);
$session->user( { userId => $user->userId } );
$sGuard = Scope::Guard->new(sub {
$session->var->end;

View file

@ -36,9 +36,9 @@ This package parses the WebGUI config file.
WebGUI::Config->loadAllConfigs($webguiRoot);
my $configs = WebGUI::Config->readAllConfigs($webguiRoot);
my $configs = WebGUI::Config->readAllConfigs;
my $config = WebGUI::Config->new($webguiRoot, $configFileName);
my $config = WebGUI::Config->new($configFileName);
my $value = $config->get($param);
$config->set($param,$value);
@ -123,8 +123,7 @@ The path to the WebGUI installation.
sub loadAllConfigs {
my $class = shift;
my $webguiPath = shift;
my $configs = $class->readAllConfigs($webguiPath);
my $configs = $class->readAllConfigs;
foreach my $filename (keys %{$configs}) {
unless ($filename =~ /^demo\d/) {
print "\tLoading ".$filename."\n";

View file

@ -15,6 +15,9 @@ package WebGUI::Paths;
=cut
our $VERSION = '0.0.1';
use 5.010;
use strict;
use warnings;
use Carp qw(croak);
use Cwd qw(realpath);
use File::Spec::Functions qw(catdir splitpath catpath splitpath updir catfile);
@ -59,6 +62,21 @@ BEGIN {
}
}
sub import {
my $class = shift;
given (\@_) {
when ('-inc') {
$class->includePreloads;
}
when ('-preload') {
$class->preloadAll;
}
default {
warn "Invalid option $_";
}
}
}
sub siteConfigs {
my $class = shift;
opendir my $dh, $class->configBase;
@ -83,7 +101,7 @@ sub preloadPaths {
try {
@paths = grep {
(-d) ? 1 : do {
warn "WARNING: Not adding lib directory '$path' from @{[$class->preloadCustom]}: Directory does not exist.\n";
warn "WARNING: Not adding lib directory '$_' from @{[$class->preloadCustom]}: Directory does not exist.\n";
0;
}
} _readTextLines($class->preloadCustom);
@ -104,6 +122,8 @@ sub preloadExclude {
sub preloadAll {
my $class = shift;
$class->includePreloads;
require WebGUI::Pluggable;
WebGUI::Pluggable::findAndLoad( 'WebGUI', {

View file

@ -50,7 +50,7 @@ B<NOTE:> It is important to distinguish the difference between a WebGUI session
use WebGUI::Session;
$session = WebGUI::Session->open($webguiRoot, $configFile);
$session = WebGUI::Session->open($configFile);
$sessionId = $session->getId;
($form, $db, $user) = $session->quick("form", "db", "user");
$session->close;
@ -455,11 +455,16 @@ Uses simple session vars. See WebGUI::Session::Var::new() for more details.
sub open {
my $class = shift;
my $webguiRoot = shift;
my $configFile = shift;
my $request = shift;
my $server = shift;
my $config = WebGUI::Config->new($configFile);
my $config;
if (try { $configFile->isa('WebGUI::Config' }) {
$config = $configFile;
}
else {
$config = WebGUI::Config->new($configFile);
}
my $self = {_config=>$config, _server=>$server};
bless $self , $class;
$self->{_request} = $request if (defined $request);

View file

@ -66,7 +66,7 @@ sub handler {
my $session = $request->pnotes('wgSession');
WEBGUI_FATAL: {
unless (defined $session) {
$session = WebGUI::Session->open($server->dir_config('WebguiRoot'), $config->getFilename, $request, $server);
$session = WebGUI::Session->open($config, $request, $server);
return Apache2::Const::OK if ! defined $session;
}
foreach my $handler (@{$config->get("contentHandlers")}) {

View file

@ -62,7 +62,7 @@ sub handler {
unless ($privs[1] eq "7" || $privs[1] eq "1") {
my $session = $request->pnotes('wgSession');
unless (defined $session) {
$session = WebGUI::Session->open($server->dir_config('WebguiRoot'), $config->getFilename, $request, $server);
$session = WebGUI::Session->open($config->getFilename, $request, $server);
}
my $hasPrivs = ($session->var->get("userId") eq $privs[0] || $session->user->isInGroup($privs[1]) || $session->user->isInGroup($privs[2]));
$session->close();

View file

@ -87,7 +87,7 @@ sub execute {
$self->session->errorHandler->warn("More than 1 old userLoginLog rows found, removing offending rows");
$self->session->db->write("delete from userLoginLog where lastPageViewed = timeStamp and sessionId = ? ", [$sessionId] );
}
my $session = WebGUI::Session->open($self->session->config->getFilename, undef, undef, $sessionId, 1);
my $session = WebGUI::Session->open($self->session->config, undef, undef, $sessionId, 1);
if (defined $session) {
$session->var->end;
$session->close;

View file

@ -10,31 +10,26 @@
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
$|++; # disable output buffering
our ($webguiRoot, $configFile, $help, $man);
BEGIN {
$webguiRoot = "..";
unshift (@INC, $webguiRoot."/lib");
}
use strict;
use Pod::Usage;
use Getopt::Long;
use WebGUI::Paths -inc;
use WebGUI::Session;
$|++; # disable output buffering
# Get parameters here, including $help
GetOptions(
'configFile=s' => \$configFile,
'help' => \$help,
'man' => \$man,
'configFile=s' => \(my $configFile),
'help' => \(my $help),
'man' => \(my $man),
);
pod2usage( verbose => 1 ) if $help;
pod2usage( verbose => 2 ) if $man;
pod2usage( msg => "Must specify a config file!" ) unless $configFile;
pod2usage( msg => "Must specify a config file!" ) unless $configFile;
my $session = start( $webguiRoot, $configFile );
my $session = start( $configFile );
# Do your work here
finish($session);
@ -43,9 +38,8 @@ finish($session);
#----------------------------------------------------------------------------
sub start {
my $webguiRoot = shift;
my $configFile = shift;
my $session = WebGUI::Session->open($webguiRoot,$configFile);
my $session = WebGUI::Session->open($configFile);
$session->user({userId=>3});
## If your script is adding or changing content you need these lines, otherwise leave them commented

View file

@ -10,16 +10,10 @@
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
our ($webguiRoot);
BEGIN {
$webguiRoot = "..";
unshift (@INC, $webguiRoot."/lib");
}
use strict;
use Getopt::Long;
use Pod::Usage;
use strict;
use WebGUI::Paths -inc;
use WebGUI::Session;
use WebGUI::User;
use WebGUI::Inbox;
@ -51,7 +45,7 @@ pod2usage( verbose => 2 ) if $help;
pod2usage() unless $configFile;
print "Starting up...\n" unless ($quiet);
my $session = WebGUI::Session->open($webguiRoot,$configFile);
my $session = WebGUI::Session->open($configFile);
if ($userMessageFile) {
print "Opening message file.." unless ($quiet);

View file

@ -10,16 +10,10 @@
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
our ($webguiRoot);
BEGIN {
$webguiRoot = "..";
unshift (@INC, $webguiRoot."/lib");
}
use strict;
use Getopt::Long;
use Pod::Usage;
use strict;
use WebGUI::Paths -inc;
use WebGUI::Session;
use WebGUI::Asset;
@ -54,7 +48,7 @@ finish($session);
#-------------------------------------------------
sub start {
my $session = WebGUI::Session->open($webguiRoot,$configFile);
my $session = WebGUI::Session->open($configFile);
$session->user({userId=>3});
return $session;
}

View file

@ -10,16 +10,8 @@
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
our ($webguiRoot, @nailable);
use strict;
BEGIN {
$webguiRoot = "..";
@nailable = qw(jpg jpeg png gif);
unshift (@INC, $webguiRoot."/lib");
}
$| = 1;
use File::Path;
use File::stat;
@ -27,13 +19,17 @@ use FileHandle;
use Getopt::Long;
use POSIX;
use Pod::Usage;
use strict;
use WebGUI::Paths -inc;
use WebGUI::Asset::File;
use WebGUI::Asset::File::Image;
use WebGUI::Session;
use WebGUI::Storage;
use WebGUI::Utility;
$| = 1;
my @nailable = qw(jpg jpeg png gif);
# TB : Get the time as soon as possible. Use $now as global variable.
# $now is used for skipOlderThan feature.
my $now = time;
@ -89,7 +85,7 @@ my %ListAssetExists;
my %filelisthash;
print "Starting..." unless ($quiet);
my $session = WebGUI::Session->open($webguiRoot,$configFile);
my $session = WebGUI::Session->open($configFile);
$session->user({userId=>3});
print "OK\n" unless ($quiet);

View file

@ -10,14 +10,13 @@
# http://www.plainblack.com info@plainblack.com
# -------------------------------------------------------------------
$|=1;
use lib '../lib';
use strict;
use Carp qw( carp croak );
use File::Find;
use Getopt::Long;
use Pod::Usage;
use Scalar::Util qw( blessed );
use WebGUI::Paths -inc;
use WebGUI::Asset::Wobject::Collaboration;
use WebGUI::Asset::Wobject::GalleryAlbum;
use WebGUI::Asset::Wobject::Gallery;
@ -25,6 +24,7 @@ use WebGUI::Asset::Wobject::Folder;
use WebGUI::Asset::Post::Thread;
use WebGUI::Storage;
$|=1;
# custom flags
my ($fromAssetId, $fromPath, $fromAssetUrl, $toId, $toUrl) = undef;
@ -378,7 +378,7 @@ sub start {
pod2usage("$0: Must specify a --configFile");
}
my $session = WebGUI::Session->open("..",$configFile);
my $session = WebGUI::Session->open($configFile);
$session->user({userId=>3});
my $versionTag = WebGUI::VersionTag->getWorking($session);

View file

@ -10,19 +10,10 @@
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
our $webguiRoot;
BEGIN {
$webguiRoot = "..";
unshift (@INC, $webguiRoot."/lib");
}
use DBI;
use FileHandle;
use strict;
use Getopt::Long;
use Pod::Usage;
use strict qw(subs vars);
use WebGUI::Paths -inc;
use WebGUI::Session;
use WebGUI::Asset;
@ -46,7 +37,7 @@ pod2usage( verbose => 2 ) if $help;
pod2usage() if ($configFile eq '' || !($assetId||$url) );
# Open WebGUI session
my $session = WebGUI::Session->open($webguiRoot,$configFile);
my $session = WebGUI::Session->open($configFile);
$session->user({userId=>$userId}) if (defined $userId);
$session->scratch->set("personalStyleId", $styleId) if (defined $styleId);
@ -54,23 +45,26 @@ my $asset = undef;
if ($url) {
$asset = WebGUI::Asset->newByUrl($session,$url);
} else {
}
else {
$asset = WebGUI::Asset->newByDynamicClass($session,$assetId);
}
if (defined $asset) {
my $file = undef;
my $file;
if ($toFile) {
$file = FileHandle->new(">$toFile") or die "Can't open file $toFile for writing. $!";
open $file '>', $toFile or die "Can't open file $toFile for writing. $!";
$session->output->setHandle($file);
}
my $content = $asset->www_view;
unless ($content eq "chunked") {
$session->output->print($content);
$session->output->print($content);
$session->output->setHandle(undef);
}
$file->close if (defined $file);
} else {
close $file
if defined $file;
}
else {
print "Asset not defined!!\n";
}

View file

@ -11,10 +11,10 @@
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use lib "../lib";
use strict;
use Getopt::Long;
use Pod::Usage;
use WebGUI::Paths -inc;
use WebGUI::Pluggable;
use WebGUI::Session;
use WebGUI::Paths;
@ -48,7 +48,7 @@ die "Config file '$configFile' does not exist!\n"
if !-f WebGUI::Paths->configBase . '/' . $configFile;
# Open the session
my $session = WebGUI::Session->open( "..", $configFile );
my $session = WebGUI::Session->open( $configFile );
$session->user( { userId => 3 } );
# Install or uninstall the asset

View file

@ -11,16 +11,10 @@
#-------------------------------------------------------------------
our ($webguiRoot);
BEGIN {
$webguiRoot = "..";
unshift (@INC, $webguiRoot."/lib");
}
use strict;
use Getopt::Long;
use Pod::Usage;
use strict;
use WebGUI::Paths -inc;
use WebGUI::Session;
my $help;
@ -39,7 +33,7 @@ pod2usage( verbose => 2 ) if $help;
pod2usage() if $configFile eq "";
my $session = WebGUI::Session->open($webguiRoot,$configFile);
my $session = WebGUI::Session->open($configFile);
$session->setting->remove('specialState');
$session->setting->add('specialState','upgrading') unless $stop;
$session->var->end;

View file

@ -1,62 +1,24 @@
use strict;
my $webguiRoot = '/data/WebGUI';
use WebGUI::Paths -preload;
@INC = grep { $_ ne q{.} } @INC;
use Log::Log4perl;
Log::Log4perl->init( WebGUI::Paths->logConfig );
unshift @INC, "$webguiRoot/lib";
use DBI;
DBI->install_driver("mysql");
# add custom lib directories to library search path
unshift @INC, grep {
if (!-d $_) {
warn "WARNING: Not adding lib directory '$_' from $webguiRoot/sbin/preload.custom: Directory does not exist.\n";
0;
}
else {
1;
}
} readLines($webguiRoot."/sbin/preload.custom");
#----------------------------------------
# Logger
#----------------------------------------
require Log::Log4perl;
Log::Log4perl->init( $webguiRoot."/etc/log.conf" );
#----------------------------------------
# Database connectivity.
#----------------------------------------
#require Apache::DBI; # Uncomment if you want to enable connection pooling. Not recommended on servers with many sites, or those using db slaves.
require DBI;
DBI->install_driver("mysql"); # Change to match your database driver.
#----------------------------------------
# WebGUI modules.
#----------------------------------------
require WebGUI;
require WebGUI::Config;
require WebGUI::Pluggable;
# these modules should always be skipped
my @excludes;
push @excludes, readLines($webguiRoot."/sbin/preload.exclude");
WebGUI::Pluggable::findAndLoad( "WebGUI",
{
exclude => \@excludes,
onLoadFail => sub { warn sprintf 'Error loading %s: %s', @_ },
}
);
require APR::Request::Apache2;
require Apache2::Cookie;
require Apache2::ServerUtil;
use WebGUI;
use WebGUI::Config;
use APR::Request::Apache2;
use Apache2::Cookie;
use Apache2::ServerUtil;
if ( $ENV{MOD_PERL} ) {
# Add WebGUI to Apache version tokens
my $server = Apache2::ServerUtil->server;
$server->push_handlers(PerlPostConfigHandler => sub {
$server->add_version_component("WebGUI/".$WebGUI::VERSION);
$server->add_version_component('WebGUI/' . $WebGUI::VERSION);
});
}
@ -64,28 +26,7 @@ $| = 1;
print "\nStarting WebGUI ".$WebGUI::VERSION."\n";
#----------------------------------------
# Preload all site configs.
#----------------------------------------
WebGUI::Config->loadAllConfigs($webguiRoot);
# reads lines from a file into an array, trimming white space and ignoring commented lines
sub readLines {
my $file = shift;
my @lines;
if (open(my $fh, '<', $file)) {
while (my $line = <$fh>) {
$line =~ s/#.*//;
$line =~ s/^\s+//;
$line =~ s/\s+$//;
next if !$line;
push @lines, $line;
}
close $fh;
}
return @lines;
}
WebGUI::Config->loadAllConfigs;
1;

View file

@ -10,16 +10,11 @@
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
our ($webguiRoot);
BEGIN {
$webguiRoot = "..";
unshift (@INC, $webguiRoot."/lib");
}
use strict;
use Getopt::Long;
use Pod::Usage;
use File::Find ();
use WebGUI::Paths -inc;
use WebGUI::Config;
local $| = 1; #disable output buffering
@ -31,8 +26,7 @@ GetOptions(
pod2usage( verbose => 2 ) if $help;
pod2usage() if $configFile eq '';
my $config = WebGUI::Config->new($webguiRoot,$configFile);
use File::Find;
my $config = WebGUI::Config->new($configFile);
print "\tRemoving unnecessary .wgaccess files.\n";
my $uploadsPath = $config->get('uploadsPath');

View file

@ -10,22 +10,14 @@
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
our ($webguiRoot);
BEGIN {
$webguiRoot = "..";
unshift (@INC, $webguiRoot."/lib");
}
$| = 1;
use strict;
use Getopt::Long;
use Pod::Usage;
use strict;
use WebGUI::Paths -inc;
use WebGUI::Session;
use WebGUI::Utility;
$| = 1;
my $configFile;
my $help;
my $quiet;
@ -40,7 +32,7 @@ pod2usage( verbose => 2 ) if $help;
pod2usage() unless (defined($configFile) && $configFile ne '');
print "Starting..." unless ($quiet);
my $session = WebGUI::Session->open($webguiRoot,$configFile);
my $session = WebGUI::Session->open($configFile);
print "OK\n" unless ($quiet);
print "Looking for descendant replationships...\n" unless ($quiet);

View file

@ -10,15 +10,9 @@
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
our ($webguiRoot);
BEGIN {
$webguiRoot = "..";
unshift (@INC, $webguiRoot."/lib");
}
use strict;
use Getopt::Long;
use WebGUI::Paths -inc;
use WebGUI::Asset;
use WebGUI::Config;
use WebGUI::Session;
@ -47,7 +41,7 @@ GetOptions(
pod2usage( verbose => 2 ) if $help;
if ($configFile) {
my $session = WebGUI::Session->open($webguiRoot, $configFile);
my $session = WebGUI::Session->open($configFile);
if ($indexsite) {
reindexSite($session);
} elsif ($updatesite) {
@ -67,10 +61,10 @@ if ($configFile) {
#-------------------------------------------------------------------
sub reindexAllSites {
my $configs = WebGUI::Config->readAllConfigs($webguiRoot);
my $configs = WebGUI::Config->readAllConfigs;
foreach my $site (keys %{$configs}) {
print "Indexing ".$site."...\n";
my $session = WebGUI::Session->open($webguiRoot,$site);
my $session = WebGUI::Session->open($site);
reindexSite($session);
$session->var->end;
$session->close;

View file

@ -10,19 +10,14 @@
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
our ($webguiRoot);
BEGIN {
$webguiRoot = "..";
unshift (@INC, $webguiRoot."/lib");
}
use Pod::Usage;
use strict;
use warnings;
use Pod::Usage;
use Getopt::Long;
use File::Spec;
use POE::Component::IKC::ClientLite;
use Spectre::Admin;
use WebGUI::Paths -inc;
use WebGUI::Config;
use JSON;
@ -52,9 +47,7 @@ GetOptions(
pod2usage( verbose => 2 ) if $help;
pod2usage() unless ($ping||$shutdown||$daemon||$run||$test||$status);
require File::Spec;
# Convert to absolute since we'll be changing directory
my $config = WebGUI::Config->new(File::Spec->rel2abs($webguiRoot),"spectre.conf",1);
my $config = WebGUI::Config->new( WebGUI::Paths->spectreConfig, 1);
unless (defined $config) {
print <<STOP;

12
sbin/syncToCdn.pl Normal file → Executable file
View file

@ -1,3 +1,5 @@
#!/usr/bin/env perl
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2009 Plain Black Corporation.
#-------------------------------------------------------------------
@ -8,16 +10,10 @@
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
our $webguiRoot;
BEGIN {
$webguiRoot = "..";
unshift( @INC, $webguiRoot . "/lib" );
}
use strict;
use Fcntl ':flock';
use Getopt::Long;
use WebGUI::Paths -inc;
use WebGUI::Session;
use WebGUI::Storage;
use Pod::Usage;
@ -51,7 +47,7 @@ if ( !( $^O =~ /^Win/i ) && $> != 0 && !$override ) {
}
print "Starting..." unless ($quiet);
my $session = WebGUI::Session->open( $webguiRoot, $configFile );
my $session = WebGUI::Session->open( $configFile );
$session->user( { userId => 3 } );
print "OK\n" unless ($quiet);

View file

@ -10,13 +10,6 @@
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
our ($webguiRoot);
BEGIN {
$webguiRoot = "..";
unshift (@INC, $webguiRoot."/lib");
}
#-----------------------------------------
# A little utility to generate WebGUI
# thumbnails.
@ -29,6 +22,7 @@ use Pod::Usage;
use Image::Magick;
use WebGUI::Paths -inc;
use WebGUI::Utility;
my $thumbnailSize;

View file

@ -10,29 +10,16 @@
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
our ($webguiRoot);
BEGIN {
$webguiRoot = "..";
unshift (@INC, $webguiRoot."/lib");
}
use strict;
use Cwd ();
use File::Path ();
use File::Spec;
use Getopt::Long ();
use Pod::Usage ();
use WebGUI::Paths -inc;
foreach my $libDir ( readLines( "$webguiRoot/sbin/preload.custom" ) ) {
if ( !-d $libDir ) {
warn "WARNING: Not adding lib directory '$libDir' from $webguiRoot/sbin/preload.custom: Directory does not exist.\n";
next;
}
unshift @INC, $libDir;
}
require WebGUI::Config;
require WebGUI::Session;
use WebGUI::Config;
use WebGUI::Session;
my $help;
my $history;
@ -108,14 +95,14 @@ if ($^O =~ /^Win/i) {
} else {
$slash = "/";
}
our $upgradesPath = $webguiRoot.$slash."docs".$slash."upgrades".$slash;
our $upgradesPath = WebGUI::Paths->upgrades;
our (%upgrade, %config);
## Find site configs.
print "\nGetting site configs...\n" unless ($quiet);
my $configs = WebGUI::Config->readAllConfigs($webguiRoot);
my $configs = WebGUI::Config->readAllConfigs;
foreach my $filename (keys %{$configs}) {
print "\tProcessing $filename.\n" unless ($quiet);
$config{$filename}{configFile} = $filename;
@ -130,7 +117,7 @@ foreach my $filename (keys %{$configs}) {
$config{$filename}{mysqlCLI} = $configs->{$filename}->get("mysqlCLI");
$config{$filename}{mysqlDump} = $configs->{$filename}->get("mysqlDump");
$config{$filename}{backupPath} = $configs->{$filename}->get("backupPath");
my $session = WebGUI::Session->open($webguiRoot,$filename);
my $session = WebGUI::Session->open($filename);
($config{$filename}{version}) = $session->db->quickArray("select webguiVersion from webguiVersion order by
dateApplied desc, length(webguiVersion) desc, webguiVersion desc limit 1");
unless ($history) {
@ -141,10 +128,10 @@ foreach my $filename (keys %{$configs}) {
}
unless ($skipDelete) {
print "\tDeleting temp files.\n" unless ($quiet);
my $path = $configs->{$filename}->get("uploadsPath").$slash."temp";
my $path = File::Spec->catdir($configs->{$filename}->get("uploadsPath"), 'temp');
File::Path::rmtree($path) unless ($path eq "" || $path eq "/" || $path eq "/data");
print "\tDeleting file cache.\n" unless ($quiet);
$path = $configs->{$filename}->get("fileCacheRoot")||"/tmp/WebGUICache";
$path = $configs->{$filename}->get("fileCacheRoot") || "/tmp/WebGUICache";
File::Path::rmtree($path) unless ($path eq "" || $path eq "/" || $path eq "/data");
}
}
@ -159,7 +146,7 @@ if ($history) {
print "\nDisplaying upgrade history for each site.\n";
foreach my $file (keys %config) {
print "\n".$file."\n";
my $session = WebGUI::Session->open($webguiRoot,$file);
my $session = WebGUI::Session->open($file);
my $sth = $session->db->read("select * from webguiVersion order by dateApplied asc, webguiVersion asc");
while (my $data = $sth->hashRef) {
print "\t".sprintf("%-8s %-15s %-15s",
@ -220,7 +207,7 @@ foreach my $filename (keys %config) {
$cmd .= " --host=".$config{$filename}{host} if ($config{$filename}{host});
$cmd .= " --port=".$config{$filename}{port} if ($config{$filename}{port});
$cmd .= " --add-drop-table ".$config{$filename}{db}." --result-file="
.$backupTo.$slash.$config{$filename}{db}."_".$upgrade{$upgrade}{from}."_".time.".sql";
.File::Spec->catfile($backupTo, $config{$filename}{db}."_".$upgrade{$upgrade}{from}."_".time.".sql");
unless (system($cmd)) {
print "OK\n" unless ($quiet);
} else {
@ -267,7 +254,7 @@ foreach my $filename (keys %config) {
sleep 1; # Sleep a second to avoid adding asset revisions too quickly
}
chdir($currentPath);
my $session = WebGUI::Session->open($webguiRoot,$filename);
my $session = WebGUI::Session->open($filename);
print "\tSetting site upgrade completed..." unless ($quiet);
$session->setting->remove('specialState');
$session->close();

View file

@ -10,17 +10,11 @@
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
our ($webguiRoot);
BEGIN {
$webguiRoot = "..";
unshift (@INC, $webguiRoot."/lib");
}
use strict;
use Digest::MD5;
use Getopt::Long;
use Pod::Usage;
use WebGUI::Paths -inc;
use WebGUI::DateTime;
use WebGUI::Group;
use WebGUI::Session;
@ -78,7 +72,7 @@ if (!($^O =~ /^Win/i) && $> != 0 && !$override) {
print "Starting up..." unless ($quiet);
my $session = WebGUI::Session->open($webguiRoot,$configFile);
my $session = WebGUI::Session->open($configFile);
$session->user({userId=>3});
open(FILE,"<".$usersFile);
print "OK\n" unless ($quiet);

View file

@ -27,7 +27,7 @@ is( ref $config->get("macros"), "HASH", "get() macros hash" );
is( ref $config->get("assets"), "HASH", "get() assets hash" );
is( ref $config->get("shippingDrivers"), "ARRAY", "get() shippingDrivers array" );
is( $config->getFilename, basename($configFile), "getFilename()" );
ok( defined WebGUI::Config->readAllConfigs($webguiRoot), "readAllConfigs" );
ok( defined WebGUI::Config->readAllConfigs, "readAllConfigs" );
$config->addToArray("shippingDrivers","TEST");
my $found = 0;
foreach my $driver ( @{$config->get("shippingDrivers")}) {

View file

@ -540,7 +540,7 @@ my @sessionBank = ();
foreach my $idx (0..$#scratchTests) {
##Create a new session
$sessionBank[$idx] = WebGUI::Session->open(WebGUI::Test->root, WebGUI::Test->file);
$sessionBank[$idx] = WebGUI::Session->open(WebGUI::Test->file);
##Create a new user and make this session's default user that user
$itchies[$idx] = WebGUI::User->new($sessionBank[$idx], "new");
@ -587,7 +587,7 @@ foreach my $idx (0..$#ipTests) {
$ENV{REMOTE_ADDR} = $ip;
##Create a new session
$sessionBank[$idx] = WebGUI::Session->open(WebGUI::Test->root, WebGUI::Test->file);
$sessionBank[$idx] = WebGUI::Session->open(WebGUI::Test->file);
##Create a new user and make this session's default user that user
$tcps[$idx] = WebGUI::User->new($sessionBank[$idx], "new");

View file

@ -178,7 +178,7 @@ sub setupUsers {
# Create sessions such that users are added to the userSession table
foreach (@users) {
my $newSession = WebGUI::Session->open(WebGUI::Test::root, WebGUI::Test::file);
my $newSession = WebGUI::Session->open(WebGUI::Test::file);
$newSession->user({user => $_});
}
addToCleanup(@users);

View file

@ -225,8 +225,8 @@ my $showDebug = $eh->showDebug;
#
####################################################
my $newSession = WebGUI::Session->open(WebGUI::Test::root, WebGUI::Test::file);
WebGUI::Test->sessionsToDelete($newSession);
my $newSession = WebGUI::Session->open(WebGUI::Test::file);
addToCleanup($newSession);
my $outputBuffer;
open my $outputHandle, '>', \$outputBuffer or die "Unable to create scalar filehandle: $!\n";
$newSession->output->setHandle($outputHandle);

View file

@ -54,7 +54,7 @@ for (my $count = 1; $count <= $maxCount; $count++){
}
##Creating a new session with the previous session's Id should clone the scratch data
my $newSession = WebGUI::Session->open(WebGUI::Test->root, WebGUI::Test->file, undef, undef, $session->getId);
my $newSession = WebGUI::Session->open(WebGUI::Test->file, undef, undef, $session->getId);
is($newSession->getId, $session->getId, "Successful session duplication");
@ -81,7 +81,7 @@ is($scratch->set('','value'), undef, 'set returns undef unless it gets a name ev
#
############################################
my @sessionBank = map { WebGUI::Session->open(WebGUI::Test->root, WebGUI::Test->file) } 0..3;
my @sessionBank = map { WebGUI::Session->open(WebGUI::Test->file) } 0..3;
##Set variables to be deleted by name
foreach my $i (0..3) {

View file

@ -133,8 +133,8 @@ is( $cart->readyForCheckout, 0, 'Cannot checkout an empty cart' );
is($session->db->quickScalar("select count(*) from cartItem where cartId=?",[ $cart->getId ]), 0, "Items are removed from cart.");
my $session2 = WebGUI::Session->open(WebGUI::Test->root, WebGUI::Test->file);
WebGUI::Test->sessionsToDelete($session2);
my $session2 = WebGUI::Session->open(WebGUI::Test->file);
addToCleanup($session2);
$session2->user({userId => 3});
my $cart2 = WebGUI::Shop::Cart->newBySession($session2);
isnt(

View file

@ -80,7 +80,7 @@ is($user->status, "Selfdestructed", 'status("Selfdestructed")');
# Deactivation user deletes all sessions and scratches
my $newSession = WebGUI::Session->open( WebGUI::Test->root, WebGUI::Test->file );
my $newSession = WebGUI::Session->open( WebGUI::Test->file );
$newSession->user({ user => $user });
$newSession->scratch->set("hasStapler" => "no");

View file

@ -214,7 +214,7 @@ is($siteWideTag->getId(), $siteWideTagId, 'versionTagMode siteWide: reclaim site
## Through in a new session as different user
my $admin_session = WebGUI::Session->open($WebGUI::Test::WEBGUI_ROOT, $WebGUI::Test::CONFIG_FILE);
my $admin_session = WebGUI::Session->open($WebGUI::Test->file);
$admin_session->user({'userId' => 3});
WebGUI::Test->sessionsToDelete($admin_session);
@ -279,8 +279,8 @@ $adminUserTag->rollback();
is($tag->getAssetCount, 1, qq{$test_prefix [singlePerUser] tag with 1 asset});
# create admin session
my $admin_session = WebGUI::Session->open($WebGUI::Test::WEBGUI_ROOT, $WebGUI::Test::CONFIG_FILE);
WebGUI::Test->sessionsToDelete($admin_session);
my $admin_session = WebGUI::Session->open($WebGUI::Test->file);
addToCleanup($session);
$admin_session->user({'userId' => 3});
setUserVersionTagMode($admin_session->user(), q{autoCommit});
@ -331,8 +331,8 @@ $adminUserTag->rollback();
is($tag->getAssetCount, 1, qq{$test_prefix [siteWide] tag with 1 asset});
# create admin session
$admin_session = WebGUI::Session->open($WebGUI::Test::WEBGUI_ROOT, $WebGUI::Test::CONFIG_FILE);
WebGUI::Test->sessionsToDelete($admin_session);
$admin_session = WebGUI::Session->open(WebGUI::Test->file);
addToCleanup($admin_session);
$admin_session->user({'userId' => 3});
setUserVersionTagMode($admin_session->user(), q{autoCommit});

View file

@ -58,14 +58,14 @@ note $scratchCount;
my @sessions;
foreach (1..2) {
push @sessions, WebGUI::Session->open(WebGUI::Test->root, WebGUI::Test->file);
push @sessions, WebGUI::Session->open(WebGUI::Test->file);
}
##Force automatic expiration of the sessions
$session->setting->set('sessionTimeout', -500);
foreach (1..2) {
push @sessions, WebGUI::Session->open(WebGUI::Test->root, WebGUI::Test->file);
push @sessions, WebGUI::Session->open(WebGUI::Test->file);
}
$session->setting->set('sessionTimeout', $origSessionTimeout );

View file

@ -37,8 +37,8 @@ WebGUI::Test->tagsToRollback($tag);
my $cart1 = WebGUI::Shop::Cart->create($session);
my $session2 = WebGUI::Session->open(WebGUI::Test->root, WebGUI::Test->file);
WebGUI::Test->sessionsToDelete($session2);
my $session2 = WebGUI::Session->open(WebGUI::Test->file);
addToCleanup($session2);
my $cart2 = WebGUI::Shop::Cart->create($session2);
$cart2->update({creationDate => time()-10000});