Fork me on GitHub

pe_pplog demo page

Main menu

finally fixed the bug #10

when editing a newly submitted post or note the pplog used to write "notes" or "posts" instead of the entry number.

I was dumbfounded by the bug, see if you can spot it:

my $fileName = r('viewDetailed');
$fileName = "posts/".$fileName if $fileName =~ /^(\d\d\d)/; #if there is no folder indication it is assumed to be a post
my @split= split (/\//, $fileName);
my $fileNum = $split[1];

if(r('process') eq 'doEntry')
# new or edit entry
my $title = r('title');
my $content=bbcode(r('content'));
my $category = r('category');
my $isHTML = r('isHTML'); #Efia HTML checkbox
my $isPage = r('isPage');

$content = basic_r('content') if($isHTML == 1);

if($title eq '' || $content eq '' || $category eq '') #check if everything is filled out
print $locale{$lang}->{necessary};
if (r('Submit') eq $locale{$lang}->{newnote} || r('Submit') eq $locale{$lang}->{subentry})
my $dir = '/posts'; #according to submit button
$dir = '/notes' if (r('Submit') eq $locale{$lang}->{newnote}); #for Notes
my @files = getFiles($config_DatabaseFolder.$dir);
my @lastOne = split(/,/, $files[0]);

if($lastOne[4] eq '') #new file with latest number
$fileNum = sprintf("%05d",0);
$fileNum = sprintf("%05d",$lastOne[4]+1);
$fileName = "$dir/$fileNum";

open(FILE, ">$config_DatabaseFolder.$fileName.$config_dbFilesExtension");
print FILE;
close FILE;

the problem was the additional "/" at $dir = "posts"

it is fixed now, but leaves me with the question what are the standard coding practices of path names, trailing "/" no trailing "/"?
Posted on - Categories: bugs

No comments posted yet

Add Comment