You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
function &_get_validation_object()
{
$CI =& get_instance();
// We set this as a variable since we're returning by reference$return = FALSE;
if ( ! isset($CI->load->_ci_classes) OR ! isset($CI->load->_ci_classes['form_validation']))
{
return$return;
}
$object = $CI->load->_ci_classes['form_validation'];
if ( ! isset($CI->$object) OR ! is_object($CI->$object))
{
return$return;
}
return$CI->$object;
}
the _get_validation_object() function always returns FALSE as the first if condition fails (because _ci_classes is a protected field of the Loader class). Also,
throws an error as, again, _ci_classes is a protected field.
Here is a suggested fix
function &_get_validation_object()
{
$CI =& get_instance();
// We set this as a variable since we're returning by reference$return = FALSE;
if ( !$CI->load->is_loaded('form_validation'))
{
return$return;
}
// this may need to be changed to a more suitable name$object = 'form_validation';
if ( ! isset($CI->$object) OR ! is_object($CI->$object))
{
return$return;
}
return$CI->$object;
}
The fix uses the is_loaded method the Loader class already provides - The Law of Demeter prohibits access such as $CI->load->_ci_classes and although CI uses it extensively here is an example why it shouldn't!
The text was updated successfully, but these errors were encountered:
Version: CodeIgniter 2.0.3
System: PHP Version 5.3.2-1ubuntu4.9
File: ./system/helpers/form_helper.php
Affected Code:
the _get_validation_object() function always returns FALSE as the first if condition fails (because _ci_classes is a protected field of the Loader class). Also,
throws an error as, again, _ci_classes is a protected field.
Here is a suggested fix
The fix uses the is_loaded method the Loader class already provides - The Law of Demeter prohibits access such as $CI->load->_ci_classes and although CI uses it extensively here is an example why it shouldn't!
The text was updated successfully, but these errors were encountered: