Welcome Guest, Not a member yet? Register   Sign In
I think I found an error in the Validation library...
#1

[eluser]ccw39[/eluser]
So, I was looking through my log files to figure out why I'm having a problem with my site. I randomly noticed that, on form validation when I have form errors, the last log message involving that form is incorrect. Basically, it's attaching the wrong error to the very last field that was validated.


Line 386 in Validation.php is about where the problems are happening (this is in the run() function)

Notice how that line is outputing the $field variable. However, from the looks of it, the $field variable was created way back near the top of the run() function during a foreach loop on line 210: "foreach ($this->_rules as $field => $rules)". However, the right curly bracket on line 358 closes that particular foreach function. Thus, by time line 386 sees the $field variable, I think it's getting the last value of $field from the foreach loop (which, oddly enough, isn't out of scope here for some reason, although it seems like it should).

Anyway, by time line 386 comes around, the log is incorrectly displaying ALL the validation errors and saying they are attributed to the very last value of $field from that foreach loop.

So, if you see what I mean, please let me know. I just wanted to bring it to your attention.



I'm running PHP 5.2.3 with Code Igniter 1.5.3 on Windows with Apache 2.2.4.
#2

[eluser]coolfactor[/eluser]
CodeIgniter 1.5.4 was released a couple of weeks ago. You might want to grab that.

Furthermore, in my Validation.php file, the run() function is between Lines 180 and 369. Same as in CI 1.5.3.

Line 386 in my copy is part of the required() function.

Do you have a modified copy?
#3

[eluser]ccw39[/eluser]
Ahh okay. Thanks for pointing that out.

Looks like one of my team members modified Validation.php (he didn't do a good job it seems) without commenting to say that he did so or that he had made changes to the file.

Sorry about that.




Theme © iAndrew 2016 - Forum software by © MyBB