Part of the EllisLab Network
   
 
Call to undefined function get_instance()
Posted: 30 September 2007 10:48 AM   [ Ignore ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  709
Joined  06-07-2007

Hey, when I have xss filtering turned on in the config.php file, i get the following error:


Fatal error: Call to undefined function get_instance() in /Users/majd/Sites/cap1_wc/trunk/system/libraries/Input.php on line 855

As soon as i turn it off, the whole thing works perfect

 Signature 

jtaby.com

Profile
 
 
Posted: 20 October 2007 05:12 PM   [ Ignore ]   [ # 1 ]  
Summer Student
Total Posts:  12
Joined  10-20-2007

I ran into the same issue. The method in question is:

function _html_entity_decode_callback($match)
    
{
        $CI 
=& get_instance(); // This is the line it errors on.
        
$charset $CI->config->item('charset');

        return 
$this->_html_entity_decode($match[0]strtoupper($charset));
    

PHP Fatal error:  Call to undefined function get_instance() in .../system/libraries/Input.php on line 855

I get this error when the user inputs ‘<stuff>’. But ‘<>’ or the ‘<’ and ‘>’ char’s alone will not mess it up.

Any thoughs guys ?

Profile
 
 
Posted: 20 October 2007 05:19 PM   [ Ignore ]   [ # 2 ]  
Summer Student
Total Posts:  12
Joined  10-20-2007

After some more searching i found a post on this issue:

http://codeigniter.com/forums/viewthread/60481/

Antivanity

Profile
 
 
Posted: 20 October 2007 06:02 PM   [ Ignore ]   [ # 3 ]  
Lab Assistant
RankRank
Total Posts:  228
Joined  10-17-2006

The solution is indeed as mentioned in the other thread:

function _html_entity_decode_callback($match)
    
{
        $charset 
config_item('charset');

        return 
$this->_html_entity_decode($match[0]strtoupper($charset));
    

The error is however caused because in codeigniter.php the Base4/5.php file is only loaded after the Input-class. In the Base4/5.php file the get_instance() function is written and it is conditionally loaded so it won’t be present until after it is loaded. Therefore the function is not present, yet. Another fix would probably be moving the IN=& load_class(‘Input’); after the loading of the base4/5.php file. I haven’t checked though. Neither would I really know the benefits of either solution.

Profile
 
 
Posted: 20 October 2007 06:31 PM   [ Ignore ]   [ # 4 ]  
Summer Student
Total Posts:  12
Joined  10-20-2007

Thank you for explaining the reason behind this error.

Profile