1
bungoman85
really odd error in wfsection 2.07 beta 3 code
  • 2005/6/13 18:24

  • bungoman85

  • Just popping in

  • Posts: 27

  • Since: 2005/5/23


So I finally figured out how to turn PHP debug on. I decided to roll back XOOPS to a point before I had installed the wfsection module (using a nice little perl script I made that copies XOOPS and the mySQL database for backup and allows me to revert to any previous version I want). Rather than go with version 1.01 of the module, which was generating lots of blank pages and is relatively old I decided to go with 2.07 beta 3, the newest version. I had tried it before but I had not been able to install it before for some odd reason it was making XOOPS freak out whenever I tried to go to the modules admin page. It seems there was some sort of fatal error inside the PHP code that was causing XOOPS to stop rendering HTML so I couldn't even see the module in the install list, nor could I see any module whose directories inode number was greater than the wfsection directory's. Now that I have PHP debug on I was able to shed some light on the problem. At first I was getting some redeclared variable errors inside of the wfsarticle.php file inside the declaration of the WfsArticle class. I commented out the redeclared variables (why they were left in there is beyond me) but then I came to this error:

Fatal error: Cannot re-assign $this in /engtools/local_advtech_develop/apache2/htdocs.xoops.v006/modules/wfsection/class/wfsarticle.php on line 591
Notice [PHP]: Undefined index: logopath in file modules/wfsection/class/common.php line 92
Notice [PHP]: Undefined index: logopath in file modules/wfsection/class/common.php line 93

Here is the code in surrounding the error:

585 function getArticle($articleid)
586 {
587 $sql = "SELECT * FROM " . $this->table . " WHERE articleid=" . $articleid . " ";
588 $array = $this->db->fetchArray($this->db->query($sql));
589 if (!is_array($array))
590 {
591 $this = false;
592 return false;
593 }
594 $this->makeArticle($array);
595 }

This error is a bit much for me to handle without serious understanding of what is going on. I don't feel comfortable trying to change any of this code as I don't want to break it more than it already is broken. Does anyone know what this error means exactly? Has anyone else even encountered this before?

2
maumed
Re: really odd error in wfsection 2.07 beta 3 code
  • 2005/6/13 18:30

  • maumed

  • Just popping in

  • Posts: 50

  • Since: 2004/10/18


youre running php5? im not sure, but i think in php5 you cannot redeclare a variable representing a object *inside* this object.... like "$this", in this case. Im running the last wfsections without any problem in php4

[]
Mauricio

3
wcrwcr
Re: really odd error in wfsection 2.07 beta 3 code
  • 2005/6/13 18:32

  • wcrwcr

  • Home away from home

  • Posts: 1114

  • Since: 2003/12/12


Hi bungoman

Quote:
(using a nice little perl script I made that copies XOOPS and the mySQL database for backup and allows me to revert to any previous version I want).


Any chance to share that very interesting script?

4
maumed
Re: really odd error in wfsection 2.07 beta 3 code
  • 2005/6/13 18:36

  • maumed

  • Just popping in

  • Posts: 50

  • Since: 2004/10/18


Quote:

wcrwcr wrote:
Hi bungoman

Quote:
(using a nice little perl script I made that copies XOOPS and the mySQL database for backup and allows me to revert to any previous version I want).


Any chance to share that very interesting script?


better than that... (at least for me - i cant run perl on my server lol) can you tell us how you implement that? specially the part os "revert to any previous version".... maybe i can reproduce this script in php. but if you could share the script, it would help a lot!

[]s
Mauricio

5
bungoman85
Re: really odd error in wfsection 2.07 beta 3 code
  • 2005/6/13 19:11

  • bungoman85

  • Just popping in

  • Posts: 27

  • Since: 2005/5/23


Quote:

wcrwcr wrote:
Hi bungoman

Quote:
(using a nice little perl script I made that copies XOOPS and the mySQL database for backup and allows me to revert to any previous version I want).


Any chance to share that very interesting script?


#!/usr/local/bin/perl -w
# ******************************************************************************
# File: xoopsbackup.pl
#
# Author: Sean Eshbaugh
#
# Created: 06-01-2005
#
# Description:
#  Creates a backup of the current XOOPS mySQL database and puts it in the
#  current XOOPS directory. Then a copy of the XOOPS directory is made and the
#  version number associated with it is incrimented by one. All necessary
#  changes to file permissions and associations are then made. The symbolic
#  link from the Apache htdocs directory is changed to the new XOOPS directory.
#  Finally the old XOOPS database is removed from the new XOOPS folder to
#  prevent unecessary clutter.
#
# Arguments:
#  <arg1> - <password>
#
# Returns: 
#  0 on success, 1 on failure
#
# ******************************************************************************
# $Id$

# ******************** Globals *************************************************
use strict;
use 
Cwd;
use 
File::Basename;

my $usage "nUsage: xoopsbackup.pl <mysql_password>nn";

my $password "";

my $basepath "/usr/local/apache2";

# ******************** Main ****************************************************

# Parse the command line arguments and get the mySQL database password
&parse_cmd_line;

# Set umask
umask 002;

# cd to the Apache directory
chdir($basepath) || die "Could not cd to $basepathn";

# Get the name of the current XOOPS directory from the htdocs link
print STDERR "Getting current XOOPS path...n";

my $current_xoops_dir = &get_current_xoops_dir;

# Get the version number from the XOOPS directory name
print STDERR "Getting current XOOPS backup version...n";

my $current_version = &get_current_version;

# Incriment the current version by one to get the next version
print STDERR "Getting new XOOPS backup version...n";

my $next_version $current_version 1;

# Create the new XOOPS directory name
print STDERR "Getting new XOOPS path...n";

my $new_xoops_dir sprintf("htdocs.xoops.v%03d"$next_version);

# Backup the mySQL database to a file
print STDERR "Backing up mySQL dbase...n";

&
backup_dbase;

# Copy existing XOOPS installation to a new directory
&seed_new_dir;

print 
STDERR "Done backing up Xoops.n";

# ******************** Subs ****************************************************

# Parse cmd line args
sub parse_cmd_line
{
        
unless (@ARGV == 1)
        {
                die 
$usage;
        }

        
$password $ARGV[0];
}

# Get the current XOOPS directory
sub get_current_xoops_dir
{
         
unless (-'htdocs')
        {
                die 
"Could not find htdocs link in current dir: $basepathn";
        }

        return 
readlink('htdocs');
}

sub get_current_version
{
        if (
$current_xoops_dir =~ /.v(ddd)$/)
        {
                return $
1;
        }
        else
        {
                die 
"Could not extract version from current XOOPS path: $current_xoops_dirn";
        }
}

sub backup_dbase
{
        
my $outfile "$basepath/htdocs/xoopsdb.v" sprintf("%03d"$current_version) . ".sql";

        if (-
f $outfile)
        {
                
unlink($outfile) || die "Failed to delete $outfilen";
        }

        
my $mysql_cmd "/usr/local/mysql-4.1.7/bin/mysqldump -u root -p$password XOOPS ";

        
unless (system("$mysql_cmd > $outfile") == 0)
        {
                die 
"System call failed: $mysql_cmdn";
        }
}

sub seed_new_dir
{
        
# Copy the current XOOPS directory to a new one
        
print STDERR "Copying old XOOPS directory to new XOOPS directory...n";

        
my $cmd "/bin/cp -pr $current_xoops_dir $new_xoops_dir";

        
unless (system($cmd) == 0)
        {
                die 
"System call failed: $cmdn";
        }

        
# Change group ownership of the new XOOPS directory to techweb
        
print STDERR "Changing group ownership of new XOOPS directory to techweb...n";

        
$cmd "/bin/chgrp -R techweb $new_xoops_dir";

        
unless (system($cmd) == 0)
        {
                die 
"System call failed: $cmdn";
        }

        
# Add group write privleges to the new directory
        
print STDERR "Adding group write privleges to new XOOPS directory...n";

        
$cmd "/bin/chmod -R g+w $new_xoops_dir";

        
unless (system($cmd) == 0)
        {
                die 
"System call failed: $cmdn";
        }

        
# Update XOOPS root path in mainfile.php
        
print STDERR "Updating XOOPS root path...n";

        
$cmd "/bin/chmod u+w $new_xoops_dir/mainfile.php";

        
unless (system($cmd) == 0)
        {
                die 
"System call failed: $cmdn";
        }

        &
update_xoops_root_path;

        
# Set privleges to read only for the new mainfile.php
        
print STDERR "Setting privleges to read only for the new mainfile.php...n";

        
$cmd "/bin/chmod 444 $new_xoops_dir/mainfile.php";

        
unless (system($cmd) == 0)
        {
                die 
"System call failed: $cmdn";
        }

        
# Change symbolic link to point to the newly created XOOPS directory
        
print STDERR "Changing htdocs symbolic link to point to new XOOPS directory...n";

        
$cmd "/bin/rm -f htdocs; /bin/ln -s $new_xoops_dir htdocs";

        
unless (system($cmd) == 0)
        {
                die 
"System call failed: $cmdn";
        }

        
# Remove mySQL database backup from new directory
        
print STDERR "Removing old mySQL database backup from new XOOPS directory...n";

        
chdir ('htdocs') || die "Could not cd into newly created 'htdocs' directoryn";

        
my $oldfile  "$basepath/htdocs/xoopsdb.v" sprintf("%03d"$current_version) . ".sql";

        
$cmd "/bin/rm -f $oldfile";

        
unless (system($cmd) == 0)
        {
                die 
"System call failed: $cmdn";
        }
}

sub update_xoops_root_path
{
        
my $file "$new_xoops_dir/mainfile.php";
        
my @array = &load_file_to_array($file);

        
open(OUT">$file") || die "Could not open $file for writtingn";

        foreach 
my $line (@array)
        {
                
$line =~ s/$current_xoops_dir/$new_xoops_dir/;

                print 
OUT "$linen";
        }

        
close(OUT);
}

# Read the contents of a file into an array
sub load_file_to_array
{
        
my $file shift;
        
my @array = ();

        
open(LFTA$file) || die "Could not open $file for readingn";

        while (<
LFTA>)
        {
                
$_ =~ s/r//;

                
chomp $_;

                
push(@array, $_);
        }

        
close(LFTA);

        return @array;
}


and...

#!/usr/local/bin/perl -w
# ******************************************************************************
# File: xoopsrevert.pl
#
# Author: Sean Eshbaugh
#
# Created: 06-03-2005
#
# Description:
#
# Arguments:
#  <arg1> - <password>, <arg2> - <version to revert to>
#
# Returns: 
#  0 on success, 1 on failure
#
# ******************************************************************************
# $Id$

# ******************** Globals *************************************************

use strict;
use 
Cwd;
use 
File::Basename;

my $usage "nUsage: xoopsrevert.pl <password> <requested_version>nn";

my $basepath "/usr/local/apache2/";

my $password "";

my $requested_version 0;

# ******************** Main ****************************************************

# Parse the command line arguments and get the mySQL database password
&parse_cmd_line;

# Set umask

umask 002;

# cd to the Apache directory
chdir($basepath) || die "Could not cd to $basepathn";

# Get the name of the current XOOPS directory from the htdocs link
print STDERR "Getting current XOOPS path...n";

my $current_xoops_dir = &get_current_xoops_dir;

# Check to see if the requested version exists
my $requested_version_dir "htdocs.xoops.v" sprintf("%03d"$requested_version);

unless (-d $requested_version_dir)
{
        die 
"Could not find requested backup versionn";
}       

if (
$current_xoops_dir eq $requested_version_dir)
{
        die 
"Current XOOPS backup requestedn";
}

print 
STDERR "$current_xoops_dirn";
print 
STDERR "$requested_version_dirn";

# Change symbolic link to point to the old XOOPS directory
print STDERR "Changing htdocs symbolic link to point to old XOOPS directory...n";

my $cmd "/bin/rm -f htdocs; /bin/ln -s $requested_version_dir htdocs";

unless (system($cmd) == 0)
{
        die 
"System call failed: $cmdn";
}

# Edit the mySQL backup file so that mySQL can use it
print STDERR "Editing the mySQL database file...n";

&
edit_mysql_file;

# ******************** Subs ****************************************************

# Parse cmd line args
sub parse_cmd_line
{
        
unless (@ARGV == 2)
        {
                die 
$usage;
        }

        
$password $ARGV[0];

        
$requested_version $ARGV[1];
}

# Get the current XOOPS directory
sub get_current_xoops_dir
{
        
unless (-'htdocs')
        {
                die 
"Could not find htdocs link in current dir: $basepathn";
        }

        return 
readlink('htdocs');
}

sub edit_mysql_file
{
        
my $file "$requested_version_dir/xoopsdb.v" sprintf("%03d"$requested_version) . ".sql";
        
my @array = &load_file_to_array($file);

        
open(OUT">$file") || die "Could not open $file for writtingn";

        print 
OUT "use xoopsn";

        foreach 
my $line (@array)
        {
                print 
OUT "$linen";
        }

        
close(OUT);

        
my $mysql_cmd "/usr/local/mysql-4.1.7/bin/mysql -u root -p$password < $file";

        
unless (system($mysql_cmd) == 0)
        {
                die 
"Could not load the mySQL database filen";
        }
}

# Read the contents of a file into an array
sub load_file_to_array
{
        
my $file shift;
        
my @array = ();

        
open(LFTA$file) || die "Could not open $file for readingn";

        while (<
LFTA>)
        {
                
$_ =~ s/r//;

                
chomp $_;

                
push(@array, $_);
        }

        
close(LFTA);

        return @array;
}

6
bungoman85
Re: really odd error in wfsection 2.07 beta 3 code
  • 2005/6/13 19:13

  • bungoman85

  • Just popping in

  • Posts: 27

  • Since: 2005/5/23


Forgot to mention, you'll need to change some things in the script to fit your own system, like the group name and the MySQL user and whatnot, nothing too hard to figure out.

7
maumed
Re: really odd error in wfsection 2.07 beta 3 code
  • 2005/6/13 19:17

  • maumed

  • Just popping in

  • Posts: 50

  • Since: 2004/10/18


many many thanx for sharing this script!

[]s
mauricio

8
Catzwolf
Re: really odd error in wfsection 2.07 beta 3 code
  • 2005/6/13 19:19

  • Catzwolf

  • Home away from home

  • Posts: 1392

  • Since: 2007/9/30


The problem is that this version of WF-Sections is not PHP5 ready, with PHP5 $this is basically only used within classes etc (It's reserved so to speak).

I am close to releasing a version that should work on PHP5 without any problems and without those little clitches you mentioned already.

John

9
wcrwcr
Re: really odd error in wfsection 2.07 beta 3 code
  • 2005/6/13 19:30

  • wcrwcr

  • Home away from home

  • Posts: 1114

  • Since: 2003/12/12


Than k u bungoman
That script must be on the core I guess.

10
scott_68
Re: really odd error in wfsection 2.07 beta 3 code
  • 2005/6/14 17:49

  • scott_68

  • Just popping in

  • Posts: 28

  • Since: 2005/2/6 1


I just installed this version 2 days ago, it worked fine till I found out that I suddenly had white pages members modul, after clicking on a member and in the wffaq modul.

xoops2-mod_wfsection_v2_01.zip .

Has anyone got a version (link) here to a version that is running stable on xoops2.0.10 without errors ??

Thank you.

Or post me a solution how to get rid of the blank pages as the module wfsection itself is running ok so far.

Login

Who's Online

175 user(s) are online (104 user(s) are browsing Support Forums)


Members: 0


Guests: 175


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Mar 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits