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

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

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.

  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

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.

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)

Added within ZF2 with GH-452