all loop iterators have to be declared lexical. PBP/108

This commit is contained in:
Colin Kuskie 2007-12-05 16:46:38 +00:00
parent 52132e61f4
commit 08fbd46d28
8 changed files with 31 additions and 34 deletions

View file

@ -772,13 +772,13 @@ resides.
=cut =cut
sub _getDatabaseInfo { sub _getDatabaseInfo {
my (@tables, $tableName, $sth, $columnDefinition, $currentColumn, $databaseDefinition); my (@tables, $sth, $columnDefinition, $currentColumn, $databaseDefinition);
my $self = shift; my $self = shift;
my $dbLink = $self->_getDbLink; my $dbLink = $self->_getDbLink;
@tables = $dbLink->db->buildArray("show tables"); @tables = $dbLink->db->buildArray("show tables");
foreach $tableName (@tables) { foreach my $tableName (@tables) {
$sth = $dbLink->db->read("describe ".$tableName); $sth = $dbLink->db->read("describe ".$tableName);
while ($columnDefinition = $sth->hashRef) { while ($columnDefinition = $sth->hashRef) {
@ -1940,7 +1940,7 @@ Processes and stores the field properties, and will alter the table according to
=cut =cut
sub www_editFieldSave { sub www_editFieldSave {
my ($databaseDef, $key, $joinNumber, @tables, $processed, $tableName, my ($databaseDef, $joinNumber, @tables, $processed, $tableName,
$joinAColumnName, $joinATableName, $joinBColumnName, $joinBTableName, $joinAColumnName, $joinATableName, $joinBColumnName, $joinBTableName,
@joinConstraints, @differenceConstraints, $maxAllowedLength, $fieldId, @joinConstraints, @differenceConstraints, $maxAllowedLength, $fieldId,
@error, $properties, $i18n); @error, $properties, $i18n);
@ -2028,7 +2028,7 @@ my @columnConstraints;
my %fingerprint; my %fingerprint;
my $dbLink = $self->_getDbLink; my $dbLink = $self->_getDbLink;
foreach $key (sort(keys(%{$self->session->form->paramsHashRef}))) { foreach my $key (sort(keys(%{$self->session->form->paramsHashRef}))) {
if ($key =~ m/^database(\d+)/ && $self->session->form->process($key)) { if ($key =~ m/^database(\d+)/ && $self->session->form->process($key)) {
$joinNumber = $1; $joinNumber = $1;
my $databaseName = $self->session->form->process("database$joinNumber"); my $databaseName = $self->session->form->process("database$joinNumber");
@ -3332,7 +3332,6 @@ revision number in form param 'rev'; otherwise the latest revision is used.
=cut =cut
sub www_viewFile { sub www_viewFile {
my ($field, $revision);
my $self = shift; my $self = shift;
return $self->session->privilege->insufficient() unless ($self->canView); return $self->session->privilege->insufficient() unless ($self->canView);
@ -3341,7 +3340,7 @@ sub www_viewFile {
my $recordId = $self->session->form->process('rid'); my $recordId = $self->session->form->process('rid');
my $revision = $self->session->form->process('rev'); my $revision = $self->session->form->process('rev');
$field = $self->_getFieldProperties($fieldId); my $field = $self->_getFieldProperties($fieldId);
if ($field->{formFieldType} eq 'file') { if ($field->{formFieldType} eq 'file') {
my ($mimeType, $data) = $self->_getFileFromDatabase($recordId, $field->{fieldName}, $revision); my ($mimeType, $data) = $self->_getFileFromDatabase($recordId, $field->{fieldName}, $revision);
@ -3364,7 +3363,6 @@ This particular caching scheme is used in stead of storage, since privileges sho
=cut =cut
sub www_viewThumbnail { sub www_viewThumbnail {
my ($field, $revision, $thumbnailData);
my $self = shift; my $self = shift;
return $self->session->privilege->insufficient() unless ($self->canView); return $self->session->privilege->insufficient() unless ($self->canView);
@ -3372,12 +3370,12 @@ sub www_viewThumbnail {
my $fieldId = $self->session->form->process('fid'); my $fieldId = $self->session->form->process('fid');
my $recordId = $self->session->form->process('rid'); my $recordId = $self->session->form->process('rid');
my $revision = $self->session->form->process('rev'); my $revision = $self->session->form->process('rev');
$field = $self->_getFieldProperties($self->session->form->process("fid")); my $field = $self->_getFieldProperties($self->session->form->process("fid"));
if ($field->{formFieldType} eq 'file') { if ($field->{formFieldType} eq 'file') {
my $cache = WebGUI::Cache->new($self->session, ["sqlform",$recordId,$fieldId,$revision], 24*60*60); my $cache = WebGUI::Cache->new($self->session, ["sqlform",$recordId,$fieldId,$revision], 24*60*60);
$thumbnailData = $cache->get; my $thumbnailData = $cache->get;
unless ($thumbnailData) { unless ($thumbnailData) {
my ($mimeType, $data) = $self->_getFileFromDatabase($recordId, $field->{fieldName}, $revision); my ($mimeType, $data) = $self->_getFileFromDatabase($recordId, $field->{fieldName}, $revision);
@ -3923,7 +3921,7 @@ my %sortWeights = (
); );
sub _constructSearchQuery { sub _constructSearchQuery {
my (@tables, @joinConstraints, $tableCounter, @constraints, $currentField, $conditional, @joinSequence); my (@tables, @joinConstraints, $tableCounter, @constraints, $conditional, @joinSequence);
my $self = shift; my $self = shift;
my $searchInFields = shift; my $searchInFields = shift;
my $showFields = shift; my $showFields = shift;
@ -3946,7 +3944,7 @@ sub _constructSearchQuery {
$tableCounter = 2; $tableCounter = 2;
# Process search fields. # Process search fields.
foreach $currentField (@$searchInFields) { foreach my $currentField (@$searchInFields) {
# Set conditional given for this field or to like or regexp mode if in normal search # Set conditional given for this field or to like or regexp mode if in normal search
my $searchMode = $self->session->form->process("searchMode") || $self->session->scratch->get('SQLForm_'.$self->getId.'searchMode'); my $searchMode = $self->session->form->process("searchMode") || $self->session->scratch->get('SQLForm_'.$self->getId.'searchMode');
if ($searchMode) { if ($searchMode) {

View file

@ -398,7 +398,7 @@ Draws the pie chart.
=cut =cut
sub draw { sub draw {
my ($currentSlice, $coordinates, $sliceData, $leftPlaneVisible, $rightPlaneVisible); my ($currentSlice, $coordinates, $leftPlaneVisible, $rightPlaneVisible);
my $self = shift; my $self = shift;
$self->processDataset; $self->processDataset;
@ -407,7 +407,7 @@ sub draw {
my @slices = sort sortSlices @{$self->{_slices}}; my @slices = sort sortSlices @{$self->{_slices}};
# First draw the bottom planes and the labels behind the chart. # First draw the bottom planes and the labels behind the chart.
foreach $sliceData (@slices) { foreach my $sliceData (@slices) {
# Draw bottom # Draw bottom
$self->drawBottom($sliceData); $self->drawBottom($sliceData);
@ -419,7 +419,7 @@ sub draw {
# Second draw the sides # Second draw the sides
# If angle == 0 do a 2d pie # If angle == 0 do a 2d pie
if ($self->getTiltAngle != 0) { if ($self->getTiltAngle != 0) {
foreach $sliceData (@slices) { #(sort sortSlices @{$self->{_slices}}) { foreach my $sliceData (@slices) { #(sort sortSlices @{$self->{_slices}}) {
$leftPlaneVisible = (_mod2pi($sliceData->{startAngle}) <= 0.5*pi || _mod2pi($sliceData->{startAngle} >= 1.5*pi)); $leftPlaneVisible = (_mod2pi($sliceData->{startAngle}) <= 0.5*pi || _mod2pi($sliceData->{startAngle} >= 1.5*pi));
$rightPlaneVisible = (_mod2pi($sliceData->{stopAngle}) >= 0.5*pi && _mod2pi($sliceData->{stopAngle} <= 1.5*pi)); $rightPlaneVisible = (_mod2pi($sliceData->{stopAngle}) >= 0.5*pi && _mod2pi($sliceData->{stopAngle} <= 1.5*pi));
@ -446,7 +446,7 @@ sub draw {
} }
# Finally draw the top planes of each slice and the labels that are in front of the chart. # Finally draw the top planes of each slice and the labels that are in front of the chart.
foreach $sliceData (@slices) { foreach my $sliceData (@slices) {
$self->drawTop($sliceData) if ($self->getTiltAngle != 0); $self->drawTop($sliceData) if ($self->getTiltAngle != 0);
if (_mod2pi($sliceData->{avgAngle}) > pi) { if (_mod2pi($sliceData->{avgAngle}) > pi) {

View file

@ -123,7 +123,7 @@ Draws all the bars.
=cut =cut
sub drawGraph { sub drawGraph {
my ($currentBar, %location); my %location;
my $self = shift; my $self = shift;
$self->processDataSet; $self->processDataSet;
@ -137,7 +137,7 @@ sub drawGraph {
$location{x} = $self->getChartOffset->{x} ; $location{x} = $self->getChartOffset->{x} ;
$location{y} = $self->getChartOffset->{y} + $self->getChartHeight; $location{y} = $self->getChartOffset->{y} + $self->getChartHeight;
foreach $currentBar (@{$self->{_bars}}) { foreach my $currentBar (@{$self->{_bars}}) {
if ($self->getDrawMode eq 'stacked') { if ($self->getDrawMode eq 'stacked') {
$self->drawStackedBar($currentBar, \%location, $barWidth); $self->drawStackedBar($currentBar, \%location, $barWidth);
} else { } else {

View file

@ -404,7 +404,7 @@ C<viewPurchaseHistory> operation.
sub www_checkoutSubmit { sub www_checkoutSubmit {
my $session = shift; my $session = shift;
my ($plugin, $shoppingCart, $transaction, $var, $amount, @cartItems, $i18n, @transactions, my ($plugin, $shoppingCart, $transaction, $var, $amount, @cartItems, $i18n, @transactions,
@normal, $currentPurchase, $checkoutError, @resultLoop, %param, $normal, $recurring, @normal, $checkoutError, @resultLoop, %param, $normal, $recurring,
$formError, $shipping, $shippingCost, $shippingDescription); $formError, $shipping, $shippingCost, $shippingDescription);
$i18n = WebGUI::International->new($session, 'Commerce'); $i18n = WebGUI::International->new($session, 'Commerce');
@ -449,7 +449,7 @@ sub www_checkoutSubmit {
map {push(@transactions, {recurring => 1, items => [$_]})} @$recurring; map {push(@transactions, {recurring => 1, items => [$_]})} @$recurring;
push(@transactions, {recurring => 0, items => [@$normal]}) if (@$normal); push(@transactions, {recurring => 0, items => [@$normal]}) if (@$normal);
foreach $currentPurchase (@transactions) { foreach my $currentPurchase (@transactions) {
$amount = 0; $amount = 0;
$var = {}; $var = {};
@ -634,7 +634,7 @@ Calls C<www_editCommerceSettingsSave> on form submission.
sub www_editCommerceSettings { sub www_editCommerceSettings {
my $session = shift; my $session = shift;
my (%tabs, $tabform, $currentPlugin, $ac, $jscript, $i18n, my (%tabs, $tabform, $ac, $jscript, $i18n,
$paymentPlugin, @paymentPlugins, %paymentPlugins, @failedPaymentPlugins, $plugin, $paymentPlugin, @paymentPlugins, %paymentPlugins, @failedPaymentPlugins, $plugin,
$shippingPlugin, @shippingPlugins, %shippingPlugins, @failedShippingPlugins); $shippingPlugin, @shippingPlugins, %shippingPlugins, @failedShippingPlugins);
return $session->privilege->adminOnly unless canView($session); return $session->privilege->adminOnly unless canView($session);
@ -741,7 +741,7 @@ sub www_editCommerceSettings {
-extras => 'onchange="activePayment=operateHidden(this.options[this.selectedIndex].value,activePayment)"' -extras => 'onchange="activePayment=operateHidden(this.options[this.selectedIndex].value,activePayment)"'
); );
foreach $currentPlugin (@paymentPlugins) { foreach my $currentPlugin (@paymentPlugins) {
my $style = '" style="display: none;' unless ($currentPlugin->namespace eq $paymentPlugin); my $style = '" style="display: none;' unless ($currentPlugin->namespace eq $paymentPlugin);
$tabform->getTab('payment')->raw('<tr id="'.$currentPlugin->namespace.$style.'"><td colspan="2" width="100%">'. $tabform->getTab('payment')->raw('<tr id="'.$currentPlugin->namespace.$style.'"><td colspan="2" width="100%">'.
'<table border="0" cellspacing="0" cellpadding="0" width="100%">'. '<table border="0" cellspacing="0" cellpadding="0" width="100%">'.
@ -780,7 +780,7 @@ sub www_editCommerceSettings {
-extras => 'onchange="activeShipping=operateHidden(this.options[this.selectedIndex].value,activeShipping)"' -extras => 'onchange="activeShipping=operateHidden(this.options[this.selectedIndex].value,activeShipping)"'
); );
foreach $currentPlugin (@shippingPlugins) { foreach my $currentPlugin (@shippingPlugins) {
my $style = '" style="display: none;' unless ($currentPlugin->namespace eq $shippingPlugin); my $style = '" style="display: none;' unless ($currentPlugin->namespace eq $shippingPlugin);
$tabform->getTab('shipping')->raw('<tr id="'.$currentPlugin->namespace.$style.'"><td colspan="2" width="100%">'. $tabform->getTab('shipping')->raw('<tr id="'.$currentPlugin->namespace.$style.'"><td colspan="2" width="100%">'.
'<table border="0" cellspacing="0" cellpadding="0" width="100%">'. '<table border="0" cellspacing="0" cellpadding="0" width="100%">'.
@ -897,7 +897,7 @@ The screen is not templated.
sub www_listTransactions { sub www_listTransactions {
my $session = shift; my $session = shift;
my ($output, %criteria, $transaction, @transactions); my ($output, %criteria, @transactions);
return $session->privilege->insufficient unless canView($session); return $session->privilege->insufficient unless canView($session);
@ -968,7 +968,7 @@ sub www_listTransactions {
'<th>'. $i18n->get('shipping cost'). '</th>'. '<th>'. $i18n->get('shipping cost'). '</th>'.
'<th>'. $i18n->get('status'). '</th>'. '<th>'. $i18n->get('status'). '</th>'.
'<th>'. $i18n->get('shipping status'). '</th></tr>'; '<th>'. $i18n->get('shipping status'). '</th></tr>';
foreach $transaction (@transactions) { foreach my $transaction (@transactions) {
$output .= '<tr bgcolor="#ddd">'; $output .= '<tr bgcolor="#ddd">';
$output .= '<td>'.$session->icon->delete('op=deleteTransaction;tid='.$transaction->get('transactionId')).'</td>'; $output .= '<td>'.$session->icon->delete('op=deleteTransaction;tid='.$transaction->get('transactionId')).'</td>';
my $userId = $transaction->get('userId'); my $userId = $transaction->get('userId');

View file

@ -289,7 +289,7 @@ sub www_editFontSave {
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub www_editPalette { sub www_editPalette {
my ($name, $palette, $output, $color); my ($name, $palette, $output);
my $session = shift; my $session = shift;
my $paletteId = shift || $session->form->process('pid'); my $paletteId = shift || $session->form->process('pid');
@ -324,7 +324,7 @@ sub www_editPalette {
$output .= '<table>'; $output .= '<table>';
$output .= '<tr><th></th><th>'.$i18n->get('fill color').'</th><th>'.$i18n->get('stroke color').'</th></tr>'; $output .= '<tr><th></th><th>'.$i18n->get('fill color').'</th><th>'.$i18n->get('stroke color').'</th></tr>';
foreach $color (@{$palette->getColorsInPalette}) { foreach my $color (@{$palette->getColorsInPalette}) {
$output .= '<tr>'; $output .= '<tr>';
$output .= '<td>'; $output .= '<td>';
$output .= $session->icon->delete('op=removeColorFromPalette;pid='.$palette->getId.';index='.$palette->getColorIndex($color)); $output .= $session->icon->delete('op=removeColorFromPalette;pid='.$palette->getId.';index='.$palette->getColorIndex($color));

View file

@ -852,7 +852,7 @@ The current WebGUI session object.
sub www_manageProduct { sub www_manageProduct {
my $session = shift; my $session = shift;
my ($product, $output, $parameter, $option, $optionId, $i18n); my ($product, $output, $option, $i18n);
return $session->privilege->insufficient unless canView($session); return $session->privilege->insufficient unless canView($session);
@ -882,14 +882,14 @@ sub www_manageProduct {
$output .= "<h2>Parameters</h2>"; $output .= "<h2>Parameters</h2>";
$output .= '<a href="'.$session->url->page('op=editProductParameter;parameterId=new;productId='.$product->get('productId')).'">'. $output .= '<a href="'.$session->url->page('op=editProductParameter;parameterId=new;productId='.$product->get('productId')).'">'.
$i18n->get('add parameter').'</a><br />'; $i18n->get('add parameter').'</a><br />';
foreach $parameter (@{$product->getParameter}) { foreach my $parameter (@{$product->getParameter}) {
$output .= $session->icon->delete('op=deleteProductParameter;parameterId='.$parameter->{parameterId}). $output .= $session->icon->delete('op=deleteProductParameter;parameterId='.$parameter->{parameterId}).
$session->icon->edit('op=editProductParameter;parameterId='.$parameter->{parameterId}); $session->icon->edit('op=editProductParameter;parameterId='.$parameter->{parameterId});
$output .= '<span style="margin-left: 10px"><b>'.$parameter->{name}.'</b></span><br />'; $output .= '<span style="margin-left: 10px"><b>'.$parameter->{name}.'</b></span><br />';
$output .= '<a style="margin-left: 20px" href="'. $output .= '<a style="margin-left: 20px" href="'.
$session->url->page('op=editProductParameterOption;optionId=new;parameterId='.$parameter->{parameterId}).'">'. $session->url->page('op=editProductParameterOption;optionId=new;parameterId='.$parameter->{parameterId}).'">'.
$i18n->get('add option').'</a><br />'; $i18n->get('add option').'</a><br />';
foreach $optionId (@{$parameter->{options}}) { foreach my $optionId (@{$parameter->{options}}) {
$option = $product->getOption($optionId); $option = $product->getOption($optionId);
$output .= '<span style="margin-left: 20px">'. $output .= '<span style="margin-left: 20px">'.
$session->icon->delete('op=deleteProductParameterOption;optionId='.$option->{optionId}). $session->icon->delete('op=deleteProductParameterOption;optionId='.$option->{optionId}).

View file

@ -254,12 +254,12 @@ A reference to the current session.
sub www_editProfileSave { sub www_editProfileSave {
my $session = shift; my $session = shift;
my ($profile, $fieldName, $error, $u, $warning); my ($profile, $error, $warning);
return WebGUI::Operation::Auth::www_auth($session, "init") if ($session->user->userId eq '1'); return WebGUI::Operation::Auth::www_auth($session, "init") if ($session->user->userId eq '1');
($profile, $error, $warning) = validateProfileData($session); ($profile, $error, $warning) = validateProfileData($session);
$error .= $warning; $error .= $warning;
return www_editProfile($session, '<ul>'.$error.'</ul>') if($error ne ""); return www_editProfile($session, '<ul>'.$error.'</ul>') if($error ne "");
foreach $fieldName (keys %{$profile}) { foreach my $fieldName (keys %{$profile}) {
$session->user->profileField($fieldName,$profile->{$fieldName}); $session->user->profileField($fieldName,$profile->{$fieldName});
} }
return WebGUI::Operation::Auth::www_auth($session); return WebGUI::Operation::Auth::www_auth($session);

View file

@ -501,10 +501,9 @@ sub is_constant {
} }
sub sum { sub sum {
my ($sum, $elem); my $sum = 0;
$sum = 0;
my $arrRef = shift; my $arrRef = shift;
foreach $elem (@{$arrRef}) { $sum += $elem; } foreach my $elem (@{$arrRef}) { $sum += $elem; }
return($sum); return($sum);
} }