open-classifieds / OpenClassifieds

OLD REPO! DO not clone/Download. Only here for historical reasons. Version 1.X
https://yclas.com
12 stars 7 forks source link

[CACHE] Post-Install issue in admin/settings #28

Open emanwebdev opened 11 years ago

emanwebdev commented 11 years ago

On some hosts, with {some} cache installed,

installation goes through OK as cache is set as 'filecache' install/install.php::113

define('CACHE_TYPE','filecache');

but on 1st login to admin panel,

Scenario:

as cache has just been set to 'auto'

and depending on the host, a non-file cache as been selected but now that cache needs params to be used... (ex: Memcache needs to connect to a server, etc...)

Critical sections

includes/bootstrap.php::30-31

//start cache
Cache::get_instance(CACHE_TYPE,CACHE_EXPIRE,CACHE_DATA_FILE);

includes/classes/cache.php::292

public function set_cache_type($type)
(...)
        case 'auto'://try to auto select a cache system
            if     (function_exists('eaccelerator_get'))$this->cache_type = 'eaccelerator';                                       
            elseif (function_exists('apc_fetch'))       $this->cache_type = 'apc' ;                                     
            elseif (function_exists('xcache_get'))      $this->cache_type = 'xcache' ;                                        
            elseif (class_exists('Memcache'))           $this->init_memcache();
            elseif (class_exists('fileCache'))          $this->init_filecache();
            else $this->cache_error('not any compatible cache was found');
        break;

Workarounds

public function set_cache_type($type)

// change order of the auto select

// put if (class_exists('fileCache')) $this->init_filecache() FIRST

++++++++++++++++++++++++++++++++++++ Possible ENHANCEMENT:

//start cache
if (CACHE_ACTIVE===TRUE)  Cache::get_instance(CACHE_TYPE,CACHE_EXPIRE,CACHE_DATA_FILE);

++++++++++++++++++++++++++++++++++++ IMPORTANT:

neo22s commented 11 years ago

Great you found this!

It's true absolutely wrong, in 2.0. you wont be able to change the cache or DB configs from the settings, will need to be done via file.

So only people that knows what is doing can change stuff.

You dont need to send email to us thanks :P