zend.ze1_compatibility_mode Implicit cloning object??

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
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

zend.ze1_compatibility_mode Implicit cloning object??

Post by Chris Corbyn »

Strict Standards: Implicit cloning object of class 'Swift_DependencyContainer' because of 'zend.ze1_compatibility_mode' in /path/to/web/webroot/swift/lib/classes/Swift/DependencyContainer.php on line 66
Somebody has posted me a bug. The error they're getting is this.

Should I be concerned? The PHP install is the "hardened" PHP project with the Suhosin patch.

What on earth is zend.ze1_compatibility_mode and why is it choosing to make copies for all of the object references? It sounds like it's some "mode" to make PHP5 behave more like PHP4 but I don't know.

Here's the line it's fatal dying on in this case. It emits the same error for any other line that instantiates an object.

Code: Select all

 /**
   * Returns a singleton of the DependencyContainer.
   * @return Swift_DependencyContainer
   */
  public static function getInstance()
  {
    if (!isset(self::$_instance))
    {
      self::$_instance = new self(); // <--- THIS LINE
    }
    return self::$_instance;
  }
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: zend.ze1_compatibility_mode Implicit cloning object??

Post by Chris Corbyn »

From Zend Developer Zone:
zend.ze1_compatibility_mode boolean

Enable compatibility mode with Zend Engine 1 (PHP 4). It affects the cloning, casting (objects with no properties cast to FALSE or 0), and comparing of objects. In this mode, objects are passed by value instead of reference by default.
Ugh. PHP, you suck.

I can't possibly run a PHP5 project and offer support to anybody who decides to run with this mode on. So I won't ;)
wodka
Forum Newbie
Posts: 4
Joined: Wed Feb 25, 2009 7:36 pm

Re: zend.ze1_compatibility_mode Implicit cloning object??

Post by wodka »

Yeah, I just told the hosting provider, that this setting is illogical.
They have separate PHP4, PHP4-suhosin, PHP5, PHP5-suhosin packages, so...

Yeah, this is when saying PHP, you suck is absolutely right!
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: zend.ze1_compatibility_mode Implicit cloning object??

Post by Chris Corbyn »

I can't believe Zend keep choosing to add these crazy php.ini settings. They cause all kinds of problems. They need to make sure every PHP installation exhibits the same behaviour.

I'm still not clear if this is specific to the Hardened PHP Project or to all of PHP.
Post Reply