function create_compiled_config($cache_filename) { /** * defines $keys with descriptors * @var array $keys config keys */ include W3TC_LIB_W3_DIR . '/ConfigKeys.php'; $compiled_config = new W3_ConfigData($keys); $compiled_config->set_defaults(); // collect config data from master config if (!$compiled_config->read($this->_get_config_filename(true))) { // try to read production master config $success = false; if ($this->_preview) { $success = $compiled_config->read($this->_get_config_filename(true, false)); } // try to read legacy master config if (!$success) { $data = $this->get_imported_legacy_config_keys(true); if (!is_null($data)) { foreach ($data as $key => $value) { $compiled_config->set($key, $value); } } } } $this->_put_instance_value_in_config($compiled_config); // append data from blog config $config_admin = w3_instance('W3_ConfigAdmin'); $data = W3_ConfigData::get_array_from_file($this->_get_config_filename()); if (is_null($data)) { $data = $this->get_imported_legacy_config_keys(); } if (!is_null($data)) { foreach ($data as $key => $value) { if (!$this->_key_sealed($key, $compiled_config->data, $config_admin, $value)) { $compiled_config->set($key, $value); } } } // save the value for 'home' in the config $this->_put_home_value_in_config($compiled_config->data); // save the bad_behavior path in config if plugin exists $this->_put_bad_behavior_in_config($compiled_config->data); $this->_post_process_values($compiled_config); // write cache try { $compiled_config->write($cache_filename); } catch (Exception $ex) { // dont care here about file permissions } $this->flush_apc($cache_filename, true); return $compiled_config->data; }
/** * Overloads the current ConfigWriter with found legacy values and saves to config file. */ public function import_legacy_config_and_save() { if ($this->own_config_exists()) { return; } /** * defines $keys with descriptors * @var array $keys config keys */ include W3TC_LIB_W3_DIR . '/ConfigKeys.php'; $compiled_config = new W3_ConfigData($keys); $compiled_config->set_defaults(); $config_admin = w3_instance('W3_ConfigAdmin'); $data = $this->_import_legacy_config($compiled_config); if (!is_null($data)) { $master_data = array(); if ($this->_blog_id != 0 && w3_is_network()) { $master_config = new W3_ConfigData($keys); $master_config->read($this->_get_config_filename(true)); $master_data = $master_config->data; } foreach ($data as $key => $value) { if ($master_data && isset($master_data[$key]) && $master_data[$key] === $value) { continue; } if (!$this->_key_sealed($key, $this->_data->data, $config_admin, $value)) { $this->_data->set($key, $value); } } // Since configs don't exist create them. $this->save(); $config_admin->save(); } }