Problem with class definition

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mbrampton
Forum Newbie
Posts: 9
Joined: Fri Mar 04, 2005 5:39 pm
Location: North Yorkshire

Problem with class definition

Post by mbrampton »

I have picked up the support for a PHP application that runs as a component within the Mambo CMS system. One module is causing a few users a bizarre problem, while working everywhere else.

When it runs, it has been preceded by all sorts of Mambo stuff, including the declaration of various standard classes.

The unit that causes the problem has a number of lines of general code, then a whole series of function declarations. Within them is one class declaration that extends a standard Mambo class. As I say, mostly this works fine. A few users get a fatal error when the code attempts to call the class constructor, saying no such class. One user has moved the code around to get a solution. Another says this does not work, but notices that removing the "extends X" allows the code to run for longer, until methods of the abstract class get called.

That is about all I know of the problem. I'm not even sure where to start looking. Any offers?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

you can start by posting code.
User avatar
smpdawg
Forum Contributor
Posts: 292
Joined: Thu Jan 27, 2005 3:10 pm
Location: Houston, TX
Contact:

Post by smpdawg »

I do Mambo component development and use Mambo almost exclusively for CMS work. Perhaps I can lend a hand. Which component is it?
mbrampton
Forum Newbie
Posts: 9
Joined: Fri Mar 04, 2005 5:39 pm
Location: North Yorkshire

Post by mbrampton »

Thanks! Remository - the problem is arising in admin.remository.php and the project is at http://mamboforge.net/projects/remository or my site of http://www.black-sheep-research.com.

Some people get:

Fatal error: Class 'remosConfig' not found in F:\apachefriends\xampp\htdocs\administrator\components\com_remository\admin.remository.php on line 1261

when they select "Configuration" from "Remository" from the "Components" item on the admin menu bar.

I've seen convincing evidence that it happens, but it doesn't happen in my testing, on either 4.5 or 4.5.2.1. The problem site that I know most (not much) about is running 4.5.2.
User avatar
smpdawg
Forum Contributor
Posts: 292
Joined: Thu Jan 27, 2005 3:10 pm
Location: Houston, TX
Contact:

Post by smpdawg »

I have 4.5.2 on one of my sites and I just downloaded 2.21.

What can you tell me about the problem sites? Is it limited to Windows? What PHP version are they running?

I am going to work with it a bit and also look at the code to see if I can spot anything. What version of remository had the error on line 1261?
User avatar
smpdawg
Forum Contributor
Posts: 292
Joined: Thu Jan 27, 2005 3:10 pm
Location: Houston, TX
Contact:

Post by smpdawg »

What is really odd is that remosConfig simply extends mosDBTable. It really doesn't offer much functionality which makes it even more peculiar that it misbehaves. I am going to poke around and see if I can get it to throw the error.

Do these same users have problems with the contacts module or polls?
mbrampton
Forum Newbie
Posts: 9
Joined: Fri Mar 04, 2005 5:39 pm
Location: North Yorkshire

Post by mbrampton »

They report that everything else (including all the rest of Remository) works fine!

I agree it is pretty odd - hard to see what there is to go wrong. That is why I'm casting around for ideas! If inspiration doesn't come, then I think one of the people with the problem will probably give me admin/FTP access to their site and I can figure it out step by step.

Right now, I'm about to go off on a trip for a few weeks, so a quick answer would be handy if it strikes one of us!
mbrampton
Forum Newbie
Posts: 9
Joined: Fri Mar 04, 2005 5:39 pm
Location: North Yorkshire

Post by mbrampton »

The code for the whole component is available from either http://mamboforge.net/projects/remository or http://www.black-sheep-research.com. The element that causes the problem is admin.remository.php. It is nearly 2,000 lines so not really worth posting here.

The trouble with just looking at this code is the problem is most likely at least partly an interaction with Mambo. That code is also accessible at Mamboforge http://mamboforge.net.
mbrampton
Forum Newbie
Posts: 9
Joined: Fri Mar 04, 2005 5:39 pm
Location: North Yorkshire

Post by mbrampton »

Aha! I've sorted it! This is a PHP5 issue. When I got full access to one of the sites experiencing the problem, and worked through solutions, the answer was to declare the class before much else happened.

It seems that PHP5 requires classes to be declared head of use - presumably PHP4 must look ahead for class definitions, and both must look ahead for function definitions. Does anyone know why the change?

I've another curious issue - but thought it better posted as a separate thread. About file download and spurious CR character.
User avatar
smpdawg
Forum Contributor
Posts: 292
Joined: Thu Jan 27, 2005 3:10 pm
Location: Houston, TX
Contact:

Post by smpdawg »

I'm glad to hear that it was something as easy at that.

BTW - There are some warning messages that occur during install and general use. I run with E_ALL and error messages displayed so they jump out at me.
mbrampton
Forum Newbie
Posts: 9
Joined: Fri Mar 04, 2005 5:39 pm
Location: North Yorkshire

Post by mbrampton »

Good point. It's on my list of feature requests to try to get rid of all the notices.
Post Reply