further updates to config_cascade patch

- add mediameta and license config files into the cascade
- update the cache validity code in cache.php, css.php & js.php to use config_cascade
- redo inclusion of main config files to avoid suppression of errors in config files
- add getConfigFiles($type) function
- minor updates elsewhere to use config_cascade rather than hardcoded config file names

darcs-hash:20090122114457-f07c6-98ad5627fd5df93edf8dd03289b9cf6d81962afe.gz
This commit is contained in:
Chris Smith 2009-01-22 12:44:57 +01:00
parent f0a201c570
commit f8121585ae
9 changed files with 60 additions and 22 deletions

View File

@ -181,18 +181,17 @@ class cache_parser extends cache {
}
function _addDependencies() {
global $conf;
global $conf, $config_cascade;
$this->depends['age'] = isset($this->depends['age']) ?
min($this->depends['age'],$conf['cachetime']) : $conf['cachetime'];
// parser cache file dependencies ...
$files = array($this->file, // ... source
DOKU_CONF.'dokuwiki.php', // ... config
DOKU_CONF.'local.php', // ... local config
DOKU_INC.'inc/parser/parser.php', // ... parser
DOKU_INC.'inc/parser/handler.php', // ... handler
);
$files = array_merge($files, getConfigFiles('main')); // ... wiki settings
$this->depends['files'] = !empty($this->depends['files']) ? array_merge($files, $this->depends['files']) : $files;
parent::_addDependencies();

View File

@ -181,6 +181,27 @@ function retrieveConfig($type,$fn) {
return $combined;
}
/**
* Include the requested configuration information
*
* @author Chris Smith <chris@jalakai.co.uk>
*
* @param string $type the configuration settings to be read, must correspond to a key/array in $config_cascade
* @return array list of files, default before local before protected
*/
function getConfigFiles($type) {
global $config_cascade;
$files = array();
if (!is_array($config_cascade[$type])) trigger_error('Missing config cascade for "'.$type.'"',E_USER_WARNING);
foreach (array('default','local','protected') as $config_group) {
if (empty($config_cascade[$type][$config_group])) continue;
$files = array_merge($files, $config_cascade[$type][$config_group]);
}
return $files;
}
/**
* check if the given action was disabled in config
*

View File

@ -62,6 +62,14 @@
'default' => array(DOKU_CONF.'interwiki.conf'),
'local' => array(DOKU_CONF.'interwiki.local.conf'),
),
'license' => array(
'default' => array(DOKU_CONF.'license.php'),
'local' => array(DOKU_CONF.'license.local.php'),
),
'mediameta' => array(
'default' => array(DOKU_CONF.'mediameta.php'),
'local' => array(DOKU_CONF.'mediameta.local.php'),
),
'mime' => array(
'default' => array(DOKU_CONF.'mime.conf'),
'local' => array(DOKU_CONF.'mime.local.conf'),
@ -87,8 +95,11 @@
// load the global config file(s)
foreach (array('default','local','protected') as $config_group) {
if (empty($config_cascade['main'][$config_group])) continue;
foreach ($config_cascade['main'][$config_group] as $config_file) {
@include($config_file);
if (@file_exists($config_file)) {
include($config_file);
}
}
}
@ -107,9 +118,13 @@
$license = array();
// load the license file(s)
require_once(DOKU_CONF.'license.php');
if(@file_exists(DOKU_CONF.'license.php')){
require_once(DOKU_CONF.'license.php');
foreach (array('default','local') as $config_group) {
if (empty($config_cascade['license'][$config_group])) continue;
foreach ($config_cascade['license'][$config_group] as $config_file) {
if(@file_exists($config_file)){
include($config_file);
}
}
}
// define baseURL

View File

@ -80,15 +80,19 @@ function media_metasave($id,$auth,$data){
*/
function media_metaform($id,$auth){
if($auth < AUTH_UPLOAD) return false;
global $lang;
global $lang, $config_cascade;
// load the field descriptions
static $fields = null;
if(is_null($fields)){
include(DOKU_CONF.'mediameta.php');
if(@file_exists(DOKU_CONF.'mediameta.local.php')){
include(DOKU_CONF.'mediameta.local.php');
foreach (array('default','local') as $config_group) {
if (empty($config_cascade['mediameta'][$config_group])) continue;
foreach ($config_cascade['mediameta'][$config_group] as $config_file) {
if(@file_exists($config_file)){
include($config_file);
}
}
}
$src = mediaFN($id);

View File

@ -631,7 +631,7 @@ function p_get_first_heading($id, $render=true){
* @author Andreas Gohr <andi@splitbrain.org>
*/
function p_xhtml_cached_geshi($code, $language, $wrapper='pre') {
global $conf;
global $conf, $config_cascade;
$language = strtolower($language);
// remove any leading or trailing blank lines
@ -640,9 +640,9 @@ function p_xhtml_cached_geshi($code, $language, $wrapper='pre') {
$cache = getCacheName($language.$code,".code");
$ctime = @filemtime($cache);
if($ctime && !$_REQUEST['purge'] &&
$ctime > filemtime(DOKU_INC.'inc/geshi.php') &&
$ctime > @filemtime(DOKU_INC.'inc/geshi/'.$language.'.php') &&
$ctime > filemtime(DOKU_CONF.'dokuwiki.php')){
$ctime > filemtime(DOKU_INC.'inc/geshi.php') && // geshi changed
$ctime > @filemtime(DOKU_INC.'inc/geshi/'.$language.'.php') && // language syntax definition changed
$ctime > filemtime(reset($config_cascade['main']['default']))){ // dokuwiki changed
$highlighted_code = io_readFile($cache, false);
} else {

View File

@ -7,7 +7,6 @@
*/
if(!defined('DOKU_INC')) die('meh.');
require_once(DOKU_CONF.'dokuwiki.php');
/**
* Returns the path to the given template, uses

View File

@ -159,14 +159,15 @@ function css_out(){
* @author Andreas Gohr <andi@splitbrain.org>
*/
function css_cacheok($cache,$files,$tplinc){
global $config_cascade;
if($_REQUEST['purge']) return false; //support purge request
$ctime = @filemtime($cache);
if(!$ctime) return false; //There is no cache
// some additional files to check
$files[] = DOKU_CONF.'dokuwiki.php';
$files[] = DOKU_CONF.'local.php';
$files = array_merge($files, getConfigFiles('main'));
$files[] = $tplinc.'style.ini';
$files[] = __FILE__;

View File

@ -220,8 +220,7 @@ function js_cacheok($cache,$files){
if(!$ctime) return false; //There is no cache
// some additional files to check
$files[] = DOKU_CONF.'dokuwiki.php';
$files[] = DOKU_CONF.'local.php';
$files = array_merge($files, getConfigFiles('main'));
$files[] = DOKU_CONF.'userscript.js';
$files[] = __FILE__;

View File

@ -273,7 +273,7 @@ class ap_manage {
* Refresh plugin list
*/
function refresh() {
global $MSG;
global $MSG,$config_cascade;
//are there any undisplayed messages? keep them in session for display
if (isset($MSG) && count($MSG)){
@ -285,7 +285,7 @@ class ap_manage {
// expire dokuwiki caches
// touching local.php expires wiki page, JS and CSS caches
@touch(DOKU_CONF.'local.php');
@touch(reset($config_cascade['main']['local']));
// update latest plugin date - FIXME
header('Location: '.wl($ID).'?do=admin&page=plugin');