Re: validation extension
| From: | Nick Loeve | Date: | Fri, 20 Aug 2004 04:56:38 +0000 |
| Subject: | Re: validation extension | ||
| References: | 1 2 | Groups: | php.pecl.dev |
| Request: | Send a blank email to pecl-dev+get-1198@lists.php.net to get a copy of this message | ||
Rasmus,
I am redoing this to use the input_filter, but i have just one question.
Does the function defined as the input filter get called before the modules request initialization function?
I know have a switch to load the dom object at module startup (using a single xml file for now), and in the request i do a xpath query to match a rule node to the current request uri. Only this rule is stored in a module global variable and it is not set when inside the input_filter function.
Hope that made sense.
On 14/08/2004, at 7:22 PM, Rasmus Lerdorf wrote:
Seems like an interesting approach. Have you done any performance testing on this to see exactly what sort of performance impact it has compared to no validation and compared to more traditional PHP-based validation. I see a couple of problems with the implementation. First, using call_user_function to preg_match() to apply a regex is non-optimal. We have a PHPAPI function exposed by ext/pcre called pcre_get_compiled_regex() and then you can just call pcre_exec() directly. Second, this would make sense to implement as a PHP5 input filter. Have a look at README.input_filter in the php5 tree and specifically the example implementation there. And getting back to the performance worry. These XML files should be relatively simple and generating the DOM tree for them on every request seems like a waste of cycles. The SAX interface in libxml2 is faster than the DOM interface you are using and would be preferred if it needs to be done on every request. But perhaps a more creative solution exists for that? What about a DOM tree cache? This might be something beyond just this extension though. It might make sense to have a generic shared memory DOM tree cache of some sort, or perhaps even piggyback it on top of APC. APC already has all the mechanisms in place for handling shared memory cacheing of stuff. -Rasmus On Sat, 14 Aug 2004, nick loeve wrote:Hi, I have the start of an extension for validation based on rules defined as xml. Each rule can currently validate GET and POST variables: - validating their existence - validating regular expressions - integer ranges. The extension defines a single function for the moment, and this function enforces a rule in a certain file. The functionality is limited and the design not the greatest, but i have some different things i would like to be able to define in regards to automated validation from XML. If someone gets a chance could have a look at the code and see what may be required in order for this extension to be granted a listing at pecl. Thanks Nick -- PECL development discussion Mailing List (http://pecl.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php