Issues

ZF-10263: Unable to use startMvc() in a subclass of Zend_Layout due to use of 'self' keyword

Issue Type: Bug Created: 2010-08-04T11:03:08.000+0000 Last Updated: 2012-03-14T00:24:01.000+0000 Status: Closed Fix version(s): - Next Major Release ()

Reporter: David (hndavid) Assignee: Adam Lundrigan (adamlundrigan) Tags: - Zend_Layout

Related issues: Attachments:

Description

Test case:

<pre class="highlight">
<?php

class MyLayout extends Zend_Layout
{
}

$layout = MyLayout::startMvc();

echo get_class($layout);

Expected output: MyLayout

Actual output: Zend_Layout

This is due to the use of the 'self' keyword in startMvc() which statically binds to the Zend_Layout class, irrespective of any subclasses. More info: http://bugs.php.net/30934

Here's a patch, but it only works on PHP 5.3+ due to the use of get_called_class(). http://pastie.org/1075598

Comments

Posted by David (hndavid) on 2010-08-04T11:06:41.000+0000

couldn't find how to attach a file

Posted by Matthew Weier O'Phinney (matthew) on 2010-08-04T11:39:02.000+0000

You can actually override the behavior within versions of PHP prior to 5.3; you just need to copy and paste the methods "getMvcInstance()" and "startMvc()" into your subclass. Once you have, however, all calls to either My_Layout::getMvcInstance() or Zend_Layout::getMvcInstance() will return a My_Layout object as long as you started the session using My_Layout.

I've blogged about this type of extension previously: http://weierophinney.net/matthew/archives/…

In the meantime, we cannot make changes such as you suggest until 2.0, so I'm marking that as the fix version.

Posted by Matthew Weier O'Phinney (matthew) on 2010-08-04T11:39:23.000+0000

Scheduling for 2.0.

Posted by Adam Lundrigan (adamlundrigan) on 2012-03-14T00:24:01.000+0000

Will no be fixed in ZF1. No longer an issue with ZF2

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts