Re: cvs: pear /Validate/Validate IS.php /Validate/tests validate_IS.phpt
| From: | Hannes Magnusson | Date: | Mon, 21 Nov 2005 21:58:58 +0000 |
| Subject: | Re: cvs: pear /Validate/Validate IS.php /Validate/tests validate_IS.phpt | ||
| References: | 1 2 | Groups: | php.pear.cvs |
| Request: | Send a blank email to pear-cvs+get-36439@lists.php.net to get a copy of this message | ||
[snip]
>
> > + /* Same configuration as last time? No need to go further then */
> > + if (count($postCodes) && $dataFile == $lastFile &&
> > + (($strong && $lastUrl == $url) || !$strong)) {
> *** (!$strong || $lastUrl == $url)) {
> is more efficient
Noted.
> + return in_array($postCode, $postCodes);
> > + }
> ******************
> > + /* Sanity check the data file */
> > + if (!is_readable($dataFile)) {
> > + return false;
> > }
> ******************
> I would simply not do that, you could imagine to run only on $url, no
> $file.
> Check it better as last mean after trying url, see below
It doesn't make any sens to me to run without datafile as backup.. ..but, I
guess if you tought about it someone else will to :)
[snip]
>
> > - if (!count($postCodes) && file_exists($file)) {
> > - $postCodes = file($file);
> > + if (!count($postCodes) && file_exists($dataFile)) {
> *** if (!count($postCodes) && $dataFile && is_readable($dataFile)) {
> You take the file as last mean, if url was not used or did not work
is_readable() makes more sense then file_exists, true, but the extra &&
$dataFile I can't see any use for since is_readable will reutrn false no
matter what $dataFile contains (well, unless its readable file :))
> + $postCodes = file($dataFile);
> > + $lastFile = $dataFile;
> > }
> > - if (is_array($postCodes) && in_array($postcode, $postCodes)) {
> > + if (count($postCodes) && in_array($postCode, $postCodes)) {
> > return true;
> > }
>
> Haha, interesting discussion ... but I like the autosave feature based
> on the writable or not file:
> I mean in normal case, the web server will not have it , so no risk.
> But then, if the admin runs it in a cli as root, then he *will* update
> the file.
> a+
> --
> toggg
>
Thanks
-Hannes