Issues

ZF-11745: In Zend_ValidateEmailAddress, make certain 'private' functions 'protected' so that they can be overridden when the class is extended, and store $mxHosts as a class protected variable

Issue Type: Improvement Created: 2011-09-15T17:38:07.000+0000 Last Updated: 2011-10-03T18:34:15.000+0000 Status: Resolved Fix version(s): - Next Major Release ()

Reporter: Rob McClean (romac) Assignee: Thomas Weidner (thomas) Tags: - Zend_Validate

  • emailaddresses
  • mxhosts
  • validating

Related issues: Attachments:

Description

Make the following functions 'protected' rather than 'private' so that they can be extended or overridden: o _isReserved(), _toIp(), _validateLocalPart(), _validateMXRecords(), _validateHostnamePart()

Modify _validateMXRecords() to: o get the mx weighting information as well o sort the list of $mxhosts by desc weight order o store the resultant array as a protected variable at class level

Separate out the logic that splits the email into a separate public function that stores the results in the class variables as now.

This will make the class more useful when being extended, and also allow other code to obtain the benefit of the sorted mxhosts array, and the email split functionality

Comments

Posted by Thomas Weidner (thomas) on 2011-09-15T20:54:14.000+0000

Why should the validate method being extended? There is no benefit in having this additional informations, and sorting them internally. The validator looks only if there is ONE matching record. For the match itself it is useless if there is a sorting or not.

Posted by Rob McClean (romac) on 2011-09-16T09:29:17.000+0000

  1. Why should the validate method being extended? Are you're asking why I'm extending it? Well, I have a very specific reason - it's because it nearly does what I want! What I want to do is, after calling isValid(), grab a copy of the MX Hosts array to use in the next stage of a process.
  2. There is no benefit in having this additional informations, and sorting them internally. OK, OK, not for you! But either make the function protected so I can override it and do what I wish, or expose that array, correctly sorted by weight. 3.The validator looks only if there is ONE matching record. For the match itself it is useless if there is a sorting or not. Agreed, for the match itself. (But the sort takes less time than the call to getmxrr() - I can post that code if you wish) And, hey, I'm suggesting promoting it to be protected function. You could add a parameter to the signature to choose between 'exists' and 'sorted list' without breaking anything. Regards Romac

Posted by Thomas Weidner (thomas) on 2011-09-16T12:22:29.000+0000

Nope, I did not disagree to make it protected nor did I ask why you want to extend it. But I asked why additional informations should be taken in account in the existing validation when they are not used internally. I see no reason to extend the implementation, get informations which are not used and store them internally so that others can extend the class based on not used informations.

Posted by Rob McClean (romac) on 2011-09-16T15:05:09.000+0000

OK, no problem, thanks. It was just an idea. (p.s. I'm a newbie to Zend and this Issue tracker. Sorry if I've commented inappropriately)

Posted by Thomas Weidner (thomas) on 2011-10-03T18:34:15.000+0000

Added within ZF2 with GH-452

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