Part of the EllisLab Network
   
 
_display_cache arguments
Posted: 10 November 2006 11:18 AM   [ Ignore ]  
Lab Assistant
Avatar
RankRank
Total Posts:  254
Joined  10-04-2006

Hi all !!

I was wondering about the _disqply_cache_ function in /system/libraries/Ouput.php

Before the function call, in codeigniter.php

$CFG =& load_class('Config');
$RTR =& load_class('Router');
$OUT =& load_class('Output');

/*
* ------------------------------------------------------
*    Is there a valid cache file?  If so, we're done...
* ------------------------------------------------------
*/

if ($EXT->_call_hook('cache_override') === FALSE)
{
    
if ($OUT->_display_cache($CFG, $RTR) == TRUE)
    
{
        
exit;
    
}
}

So config oud router are passed by ref.

But in the function there is :

/**
     * Update/serve a cached file
     *
     * @access    public
     * @return    void
     */    
    
function _display_cache(&$CFG, &$RTR)
    
{
        $CFG
=& load_class('Config');
        
$RTR =& load_class('Router');
    
        
$cache_path = ($CFG->item('cache_path') == '') ? BASEPATH.'cache/' : $CFG->item('cache_path');
            
        if ( !
is_dir($cache_path) OR ! is_writable($cache_path))
        
{
            
return FALSE;
...
...

I am not sur this is exact.
There is no need to load again those classes.

Perhaps is there a particular reason but ...

Bye

 Signature 

Sylvain Gourvil
PHP Developer
French scuba divingMotivation and team building

Profile
 
 
Posted: 11 November 2006 03:16 PM   [ Ignore ]   [ # 1 ]  
Administrator
Avatar
RankRankRankRankRank
Total Posts:  2505
Joined  12-21-2001

The load_class function returns the class object if it has been previously instantiated.  It doesn’t actually load the class again.  In the _display_cache function those objects are needed, so calling load_class give us a simple way to get the objects.

 Signature 
Profile
MSG
 
 
Posted: 13 November 2006 04:16 AM   [ Ignore ]   [ # 2 ]  
Lab Assistant
Avatar
RankRank
Total Posts:  254
Joined  10-04-2006

ok, thanks.

I thought it might be obvious but I prefered ask for it.

 Signature 

Sylvain Gourvil
PHP Developer
French scuba divingMotivation and team building

Profile
 
 
Posted: 23 March 2008 08:49 PM   [ Ignore ]   [ # 3 ]  
Lab Technician
Avatar
RankRankRankRank
Total Posts:  1739
Joined  06-23-2006

CI v1.6 introduced a small change into the _display_cache() function : the URI library is used instead of the Router library.

However, the Router instance is still being passed in as a function argument.

Also, why the inconsistency in how the class instances are provided to the function - $CFG as an argument, $URI using load_class()?

 Signature 

Mac OS X 10.4.10, Apache 1.3.3, PHP 5.2.3, CodeIgniter 1.5.x., baby!

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: 66412 Total Logged-in Users: 29
Total Topics: 84752 Total Anonymous Users: 1
Total Replies: 454812 Total Guests: 218
Total Posts: 539564    
Members ( View Memberlist )
Newest Members:  NirCalexmuellerkizerdrixcaptainredmuffquinodligtharttechsivamDjordjesammozzazodman23