Validation in autoload PHP 4 (Fix suggested) |
[eluser]Seppo[/eluser]
This is an old bug... It has been reported many times, and currently it´s in the tracker with the ID 3175 The original problem is that in the view you get an empty error_string even if the validation fails. Tracking it down, I found out that the problem was that PHP was generating a copy of the autoloaded class, so they were different in the controller class and in the loader class (where the $this variable point, inside the views). A quick example, to show this Code: // system/application/config/autoload.php In PHP 4 (I´ve tested this in 4.3.9 and 4.4.7) throws a notice for the undefined variable. In PHP 5 (5.0.0, 5.1.6, 5.2.5) it prints "abcde", as expected. After tracking this bug inside all core I´ve finally reached to system/libraries/Controller.php, on line 87. After $this->_ci_autoloader(); I´ve added Code: foreach (array_keys(get_object_vars($this)) as $attribute) PLEASE EVERYONE, test this on all PHP versions you can and submit the result, so we can finally fix this bug...
[eluser]Derek Jones[/eluser]
Thanks for looking into this Seppo. It appears this affects all libraries that call the CI object. I think the only thing I would change in your proposed fix is to eliminate array_keys(): Code: foreach (get_object_vars($this) as $attribute => $val)
[eluser]Derek Jones[/eluser]
Actually, since it's going to make a copy in PHP4 for the foreach, the use of array_keys() seems to be appropriate. ::grumbles at PHP4::
[eluser]karloff[/eluser]
hate to be a pain, but i'm running php 4.4.8 and the bugs still appears. if one of the admin's want to contact me and test on my site they are welcome to. i need to upgrade to php5 asap!!
[eluser]karloff[/eluser]
that's really changed. never took notice of the version i was using until now, however I only recently started using CI therefore I presumed I had a up-to-date version. must have accidentally pulled that out of the archives. sorry for the silly question, and cheers for the heads up Derek
[eluser]karloff[/eluser]
sorry to be a pain Derek, I noticed that i originally had version 1.6.1 not 1.0 as mentioned before. I have updated the necessary folders and still can pas the error data to the view. i replaced the ; * system/codeigniter * system/database * system/helpers * system/language * system/libraries just did it a s quick fix live on the site, did i do anything wrong or miss anything?
[eluser]Derek Jones[/eluser]
Ok if you are already running 1.6.1, it should have the fix. Open system/libraries/Controller.php and double check that the code is there. If it is, then please back up to your reproducible sample of code that is leading to this error. |
Welcome Guest, Not a member yet? Register Sign In |