public function load()
 {
     // apply data from master config
     $master_filename = Config::util_config_filename(0, $this->_preview);
     $data = Config::util_array_from_file($master_filename);
     if (is_null($data) && $this->_preview) {
         // try to read production data when preview not available
         $master_filename = Config::util_config_filename(0, false);
         $data = Config::util_array_from_file($master_filename);
     }
     // try to get legacy data
     if (is_null($data)) {
         $master_filename = Config::util_config_filename_legacy(0, $this->_preview);
         $data = self::util_array_from_file_legacy($master_filename);
     }
     if (is_array($data)) {
         $data = $this->upgrade($data);
         foreach ($data as $key => $value) {
             $this->_data[$key] = $value;
         }
     }
     if ($this->is_master()) {
         return;
     }
     // apply child config
     $child_filename = Config::util_config_filename($this->_blog_id, $this->_preview);
     $data = Config::util_array_from_file($child_filename);
     if (is_null($data) && $this->_preview) {
         // try to read production data when preview not available
         $child_filename = Config::util_config_filename($this->_blog_id, false);
         $data = Config::util_array_from_file($child_filename);
     }
     // try to get legacy data
     if (is_null($data)) {
         $child_filename = Config::util_config_filename_legacy($this->_blog_id, $this->_preview);
         $data = self::util_array_from_file_legacy($child_filename);
     }
     if (is_array($data)) {
         $data = $this->upgrade($data);
         foreach ($data as $key => $value) {
             if (!ConfigCompiler::child_key_sealed($key, $this->_data, $data)) {
                 $this->_data[$key] = $value;
             }
         }
     }
 }
Example #2
0
 /**
  * Loads config.
  * In a case it finds out config files are of older version - uses slower
  * loader which takes all possible bloglevel-overloads into account
  * correctly
  */
 public function load()
 {
     $master_filename = Config::util_config_filename(0, $this->_preview);
     $data = Config::util_array_from_file($master_filename);
     // config file assumed is not up to date, use slow version
     if (!isset($data['version']) || $data['version'] != W3TC_VERSION) {
         return $this->load_full();
     }
     if (!$this->is_master()) {
         $child_filename = Config::util_config_filename($this->_blog_id, $this->_preview);
         $child_data = Config::util_array_from_file($child_filename);
         if (!is_null($child_data)) {
             if (!isset($data['version']) || $data['version'] != W3TC_VERSION) {
                 return $this->load_full();
             }
             foreach ($child_data as $key => $value) {
                 $data[$key] = $value;
             }
         }
     }
     $this->_data = $data;
 }