diff --git a/sanity_check.php b/sanity_check.php index 35d5c2a7f..d70445e02 100644 --- a/sanity_check.php +++ b/sanity_check.php @@ -11,6 +11,7 @@ } require_once "config.php"; + require_once "sanity_config.php"; if (CONFIG_VERSION != EXPECTED_CONFIG_VERSION) { $err_msg = "config: your config file version is incorrect. See config.php-dist.\n"; @@ -22,6 +23,16 @@ $err_msg = "config: HTMLPurifier cache directory should be writable by anyone (chmod -R 777 $purifier_cache_dir)"; } + if (GENERATED_CONFIG_CHECK != EXPECTED_CONFIG_VERSION) { + $err_msg = "config: your sanity_config.php is outdated, please recreate it using ./utils/regen_config_checks.sh"; + } + + foreach ($requred_defines as $d) { + if (!defined($d)) { + $err_msg = "config: required constant $d is not defined. Please check config.php"; + } + } + if (defined('RSS_BACKEND_TYPE')) { print "Fatal error: RSS_BACKEND_TYPE is deprecated. Please remove this option from config.php\n"; diff --git a/sanity_config.php b/sanity_config.php new file mode 100644 index 000000000..6410c5407 --- /dev/null +++ b/sanity_config.php @@ -0,0 +1,3 @@ + diff --git a/utils/regen_config_checks.sh b/utils/regen_config_checks.sh new file mode 100755 index 000000000..78f2dbfba --- /dev/null +++ b/utils/regen_config_checks.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +DESTINATION="sanity_config.php" + +echo " $DESTINATION + +echo -n "define('GENERATED_CONFIG_CHECK', " >> $DESTINATION +grep CONFIG_VERSION config.php-dist | awk -F ' |)' '{ print $2 }' | xargs echo -n >> $DESTINATION +echo ");" >> $DESTINATION + +echo -n "\$requred_defines = array( " >> $DESTINATION + +grep define\( config.php-dist | awk -F\' '{ print "*" $2 "*," }' | xargs echo -n | sed -e s/,$// -e s/*/\'/g >> $DESTINATION + +echo "); ?>" >> $DESTINATION + +