ZF-3100: Zend_Filter_Input with inputNamespace having filters and validators getting the wrong type...

Issue Type: Bug Created: 2008-04-11T12:04:28.000+0000 Last Updated: 2008-11-15T11:36:02.000+0000 Status: Resolved Fix version(s): - 1.8.0 (30/Apr/09)

Reporter: Jordan Raub (ludicruz) Assignee: Benjamin Eberlei (beberlei) Tags: - Zend_Filter_Input

Related issues: Attachments: - patchfile


I have a date filter called My_Filter_Date and I need to use this before the standard Zend_Validate_Date validation, in ZF 1.5.1 this happens {quote} $filters = array( 'dob' => array('Date') ); $validators = array( 'dob' => array('Date') ); $data = array( 'dob' => '1990-01-01' ), $options = array( 'inputNamespace' => array('My_Filter', 'My_Validate'), ); $filter = new Zend_Filter_Input($filters, $validators, $data, $options); $filter->process(); //throws "Zend_Filter_Exception: Class based on basename 'Date' must implement the 'Zend_Validate_Interface' interface" from line 914 Zend/Filter/Input.php {quote}

line 908 of Zend/Filter/Input.php pulls out the wrong Class name from the method getPluginLoader since adding inputNamespace doesn't specify which type, either filter or validator or maybe both, the specified directory holds.

maybe it would be useful to add a key to the inputNamespace options array like so: {quote} $options = array( 'inputNamespace' => array( 'filter' => 'My_Filter', 'validate' => 'My_Validate' ), ); {quote}


Posted by Jordan Raub (ludicruz) on 2008-04-11T12:35:34.000+0000

This also breaks when I have a filter and a validator for the same thing... i.e. My_Filter_SSN and My_Validate_SSN

exception thrown as "Zend_Filter_Exception: Class based on basename 'SSN' must implement the 'Zend_Filter_Interface' interface"

Posted by Carlton Gibson (carlton) on 2008-06-16T11:03:15.000+0000

I noticed a related problem that setOptions() calls addNamespace() for the INPUT_NAMESPACE case (ZFI lines 512-514): addNamespace has been depreciated though...

Applying Jordan's suggestion above for a nested array as the inputNamespace value, the following would work:

<pre class="highlight">
      $this->addFilterPrefixPath($value['filter'], str_replace('_', DIRECTORY_SEPARATOR, $value['filter']) );
      $this->addValidatorPrefixPath($value['validate'], str_replace('_', DIRECTORY_SEPARATOR, $value['validate']) );

All this does though is replicate what's going on in the depreciated method...

Posted by Carlton Gibson (carlton) on 2008-06-16T11:45:23.000+0000

This is a patchfile which retains BC.

It adds validatorNamespace and filterNamespace to the available options so you can use those instead of inputNamespace.

It calls the appropriate add --- PrefixPath method converting the prefix to a path in the process.

Posted by Benjamin Eberlei (beberlei) on 2008-11-15T11:36:01.000+0000

Fixed in trunk as of 12670.

Have you found an issue?

See the Overview section for more details.


© 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.