Part of the EllisLab Network
   
 
Autoload Bug
Posted: 12 November 2006 07:50 PM   [ Ignore ]  
Grad Student
Rank
Total Posts:  66
Joined  07-12-2006

Hello this bug is in reference to my last topic http://codeigniter.com/forums/viewthread/46687/, but i have had 26 views and no responses. I am surprised because i think this is a pretty serious bug, but perhaps i may have confusing the way i worded things, so i will try again.

I have setup validation just as the user guide says. I have been working with CI for awhile now, so I am sure my code is right for both the controller and view for my validation example. When I load the validation library manually using $this->load->library() in my controller, everything works fine, just as the user guide says.

When i remove the $this->load->library() from my controller and instead autoload the validation class, all my of validation breaks. I get the following notice each time i try to echo out a validation field into an input value parameter:

Severity: Notice

Message: Undefined property: username

I would like to upgrade a fairly large application of mine to CI 1.5, but this is preventing me from doing so because there are a lot of sections using validation. If you could please fix it would be much appreciated. thanks.

Profile
 
 
Posted: 13 November 2006 02:11 AM   [ Ignore ]   [ # 1 ]  
Lab Assistant
RankRank
Total Posts:  240
Joined  11-10-2006

if i get that right, that’s only logical ...
the field “username” of your validation-object exists only AFTER validation did take place which - in the view - did not YET ...
you may have recognised that it’s only a notice though ...
my proposal: just set the error reporting to E_ALL ^ E_NOTICE in the config file ... it should work properly smile

 Signature 

blog

Profile
 
 
Posted: 13 November 2006 10:16 AM   [ Ignore ]   [ # 2 ]  
Grad Student
Rank
Total Posts:  66
Joined  07-12-2006

no that is not the problem. validation is running when i do “if ($this->validation->run() == FALSE)” in my controller. i also set_fields() so the field “username” of the validation object SHOULD exist at this point. I tried setting the error_reporting to E_ALL ^ E_NOTICE, which obviously gets rid of the notices, but there is no field re-population, nor error messages. download CI 1.5 and try it. thanks.

Profile
 
 
Posted: 17 November 2006 09:46 AM   [ Ignore ]   [ # 3 ]  
Grad Student
Rank
Total Posts:  66
Joined  07-12-2006

rick,

hey did you get a chance to look into this? i have confirmed this problem with a few people and there is definitely an issue when autoloading validation.

thanks

Profile
 
 
Posted: 10 December 2006 03:42 PM   [ Ignore ]   [ # 4 ]  
Summer Student
Total Posts:  1
Joined  12-10-2006

I just stumbled on this bug and I believe this can be fixed by changing the system/codeigniter/Codeigniter.php line 183 from

$CI = new $class();


to

$CI =& new $class();

Don’t know if this is a bug or what, but all object in the Codeigniter.php are created using =& except for the Contoller.

Profile
 
 
Posted: 21 December 2006 05:58 AM   [ Ignore ]   [ # 5 ]  
Summer Student
Total Posts:  3
Joined  12-21-2006

I can confirm that 1.4.1 and 1.5.1 has this ugly bug

Profile
 
 
Posted: 07 March 2007 05:59 AM   [ Ignore ]   [ # 6 ]  
Grad Student
Avatar
Rank
Total Posts:  36
Joined  03-02-2007

I confirm the bug too, i think it’s only a php4.x(?) bug.

The hack masi proposed works well, autoloading validation will now show errors well ...

Profile
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 719, on June 06, 2008 10:16 AM
Total Registered Members: 66415 Total Logged-in Users: 38
Total Topics: 84759 Total Anonymous Users: 0
Total Replies: 454880 Total Guests: 260
Total Posts: 539639    
Members ( View Memberlist )