Bug Report #4401

Config cache should be reset after new Config source attached

Added by Ivan Brotkin 4 months ago.

Status:New Start date:01/14/2012
Priority:Normal Due date:
Assignee:- % Done:

0%

Category:Core
Target version:v3.3.0
Resolution: Points:1

Description

The problem

For example, I have a Config_File attached by default:

    Kohana::$config->attach(new Config_File);

    // enable modules
    Kohana::modules(...);

    //After that I want to add a Config_Database driver:
    Kohana::$config->attach(new Config_Database);
    //And then I try to get a 'database' config 
    Kohana::$config->load('database');

Even if I have a 'database' group in my DB config table, it will be ignored. Config_File already cached 'database' group before creating Config_Database object (because we need a Database instance for it).

Possible solution

I think, we need a flush($group = NULL) method to clear config cache. For example:

    public function attach(Kohana_Config_Source $source, $first = TRUE)
    {
        if ($first === TRUE)
        {
            // Place the log reader at the top of the stack
            array_unshift($this->_sources, $source);
        }
        else
        {
            // Place the reader at the bottom of the stack
            $this->_sources[] = $source;
        }

        // !!! delete config cache
        $this->flush();

        return $this;
    }

Also this method may be useful for manual cache reset.

Also available in: Atom PDF