mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-39441 behat: Restrict config.php allowed settings
This commit is contained in:
parent
07bbbcf174
commit
f38e22ed91
3 changed files with 34 additions and 0 deletions
|
@ -141,3 +141,30 @@ function behat_error_handler($errno, $errstr, $errfile, $errline, $errcontext) {
|
|||
// Also use the internal error handler so we keep the usual behaviour.
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restrict the config.php settings allowed.
|
||||
*
|
||||
* When running the behat features the config.php
|
||||
* settings should not affect the results.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function behat_clean_init_config() {
|
||||
global $CFG;
|
||||
|
||||
$allowed = array_flip(array(
|
||||
'wwwroot', 'dataroot', 'dirroot', 'admin', 'directorypermissions', 'filepermissions',
|
||||
'dbtype', 'dblibrary', 'dbhost', 'dbname', 'dbuser', 'dbpass', 'prefix', 'dboptions',
|
||||
'proxyhost', 'proxyport', 'proxytype', 'proxyuser', 'proxypassword', 'proxybypass',
|
||||
'theme'
|
||||
));
|
||||
|
||||
// Also allowing behat_ prefixed attributes.
|
||||
foreach ($CFG as $key => $value) {
|
||||
if (!isset($allowed[$key]) && strpos($key, 'behat_') !== 0) {
|
||||
unset($CFG->{$key});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue