1
widgetapps
PHP 5 fix...
  • 2004/6/18 18:06

  • widgetapps

  • Just popping in

  • Posts: 9

  • Since: 2004/5/25


Hey all,

I've finally had a chance to take a look at the XOOPS source to see what was causing an error in PHP 5. I have PHP 5 RC3 installed on my server. The XOOPS install works great, everything was setup smoothly. After setup, that's where the error showed up, right on the main page.

The problem is object cloning. There was no way to truely clone an object in PHP 4, but there is in PHP 5. The &clone() function in the XoopsObject class (file: /html/kernel/object.php, line 528) conflicts with a new reserved word in PHP 5: clone (see http://www.php.net/zend-engine-2.php).

As a quick fix, I simply renamed it to __clone(). This will mean finding all calls to &clone() in all the other files, and replacing them with __clone(). For my install of Xoops, I'll change them as the errors come up... I'm sure once I install some modules, I'll run into the errors, but the basic install hasn't had any problems yet.

As a note, objects can be cloned 2 ways in PHP 5:

Way 1
$obj = new MyClass();
$obj_clone = clone $obj;

Way 2
$obj = new MyClass();
$obj_clone = $obj->__clone();

Xoops should use Way 2, as it will work with PHP 4.

Hope this help those trying to get XOOPS to work in PHP 5. I'll be noting all source changes I make as I go along, and I'll post them here, and perhaps on the site I'm working on now which is going to use Xoops.

D

2
Mithrandir
Re: PHP 5 fix...

Thank you very much for your fix.

It would be best if you post them on the Patches tracker on SourceForge as it is easier to keep track of, then.

Again, thanks for your help and support.

3
widgetapps
Re: PHP 5 fix...
  • 2004/6/18 18:40

  • widgetapps

  • Just popping in

  • Posts: 9

  • Since: 2004/5/25


I'll be sure to do that as well then....

Nice name, I play Radagast on a MUSH called Elendor. :)

4
widgetapps
Re: PHP 5 fix...
  • 2004/6/18 21:16

  • widgetapps

  • Just popping in

  • Posts: 9

  • Since: 2004/5/25


Found another one. The PHP funstion get_class() in PHP 4 returns lowercase version of the class name. PHP 5 returns the actual class name, case in-tact.

http://ca2.php.net/manual/en/function.get-class.php

So, I'll be adding strtolower() around all get_class() calls. I'll post this to SourceForge as well.

5
Mithrandir
Re: PHP 5 fix...

add is_subclass_of() to that list, please.

6
Dave_L
Re: PHP 5 fix...
  • 2004/7/14 19:51

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


Just posting this link here for reference: Migrating from PHP 4 to PHP 5 - Backward Incompatible Changes.

7
azari
Re: PHP 5 fix...
  • 2004/7/27 4:13

  • azari

  • Just popping in

  • Posts: 2

  • Since: 2003/8/7 0


no idea what Im gonna do with this problem - think Im just gonna stick to php4 till the error is sorted :/

Login

Who's Online

402 user(s) are online (318 user(s) are browsing Support Forums)


Members: 0


Guests: 402


more...

Donat-O-Meter

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

Latest GitHub Commits