Part of the EllisLab Network
   
 
Call to undefined function get_instance()
Posted: 30 September 2007 09:48 AM   [ Ignore ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  716
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 

CodeExtinguisher
Download: codex2_rc14.2.zip - 219 KiloBytes of Gloriousness!
Demo: Public preview - login with preview:preview
Temporary Docs: PBWiki

Profile
 
 
Posted: 20 October 2007 04: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 04: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 05:02 PM   [ Ignore ]   [ # 3 ]  
Research Assistant
RankRankRank
Total Posts:  303
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 05:31 PM   [ Ignore ]   [ # 4 ]  
Summer Student
Total Posts:  12
Joined  10-20-2007

Thank you for explaining the reason behind this error.

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 819, on March 11, 2010 11:15 AM
Total Registered Members: 120025 Total Logged-in Users: 38
Total Topics: 126159 Total Anonymous Users: 4
Total Replies: 663605 Total Guests: 360
Total Posts: 789764    
Members ( View Memberlist )