ZF-3745: If Zend_Mail_Part is extended it should return an instance of the new class

Issue Type: Improvement Created: 2008-07-24T13:55:37.000+0000 Last Updated: 2012-05-05T02:59:15.000+0000 Status: Resolved Fix version(s): - 1.11.12 (22/Jun/12)

  • 1.12.0 (27/Aug/12)

Reporter: Nico Edtinger (nico) Assignee: Adam Lundrigan (adamlundrigan) Tags: - Zend_Mail_Storage

  • state:patch-ready-for-review
  • zf-caretaker-adamlundrigan
  • zf-crteam-padraic
  • zf-crteam-priority
  • zf-crteam-review

Related issues: Attachments: - ZF-3745.patch


Zend_Mail_Part currently creates instances wit 'new self(...)', which means even if it's extended it still uses Zend_Mail_Part, because of early binding. '$classname = get_class($this); new $classname(..)' can be used in PHP < 5.3 to avoid the problem.


Posted by Adam Lundrigan (adamlundrigan) on 2011-06-29T15:04:42.000+0000

One concern: The above suggestion will change the way Zend_Mail_Message works. It extends Zend_Mail_Part, and so with the above modification all parts accessed via a Zend_Mail_Message object will be returned as instances of Zend_Mail_Message and not Zend_Mail_Part. Probably not a big deal, but worth noting.

Might it be better to give Zend_Mail_Part something analogous to Zend_Db_Table's get/setRowClass methods? ie: Allow specifying the part class through the constructor and/or setter method, with the default value being equivalent to 'self'?

Posted by Dolf Schimmel (Freeaqingme) (freak) on 2011-07-03T13:08:15.000+0000

For consistency a method as Adam suggested would indeed be appreciated. This will be fixed in ZF2 however, so unless a patch is supplied this won't be given priority.


Posted by Pádraic Brady (padraic) on 2011-08-13T19:57:02.000+0000

Updated affected versions and switched to an improvement issue

Posted by Adam Lundrigan (adamlundrigan) on 2011-10-04T22:27:40.000+0000

Attached patch contains a prototype implementation of the agreed-upon solution. Comments?

Posted by Adam Lundrigan (adamlundrigan) on 2012-05-05T02:59:15.000+0000

Fixed in trunk (1.12.0): r24759 Fixed in release-1.11 (1.11.12): r24760

Have you found an issue?

See the Overview section for more details.


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

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