Commit 7faccfcb authored by Jesse Norell's avatar Jesse Norell
Browse files

call verify_php_ini from server_php_{insert,update} events

parent 0f7af6df
Pipeline #9262 passed with stage
in 10 minutes and 14 seconds
......@@ -54,6 +54,9 @@ class web_module {
'web_backup_insert',
'web_backup_update',
'web_backup_delete',
'server_php_insert',
'server_php_update',
'server_php_delete',
'aps_instance_insert',
'aps_instance_update',
'aps_instance_delete',
......@@ -112,6 +115,7 @@ class web_module {
$app->modules->registerTableHook('web_folder', 'web_module', 'process');
$app->modules->registerTableHook('web_folder_user', 'web_module', 'process');
$app->modules->registerTableHook('web_backup', 'web_module', 'process');
$app->modules->registerTableHook('server_php', 'web_module', 'process');
$app->modules->registerTableHook('aps_instances', 'web_module', 'process');
$app->modules->registerTableHook('aps_instances_settings', 'web_module', 'process');
$app->modules->registerTableHook('aps_packages', 'web_module', 'process');
......@@ -167,6 +171,11 @@ class web_module {
if($action == 'u') $app->plugins->raiseEvent('web_backup_update', $data);
if($action == 'd') $app->plugins->raiseEvent('web_backup_delete', $data);
break;
case 'server_php':
if($action == 'i') $app->plugins->raiseEvent('server_php_insert', $data);
if($action == 'u') $app->plugins->raiseEvent('server_php_update', $data);
if($action == 'd') $app->plugins->raiseEvent('server_php_delete', $data);
break;
case 'aps_instances':
if($action == 'i') $app->plugins->raiseEvent('aps_instance_insert', $data);
if($action == 'u') $app->plugins->raiseEvent('aps_instance_update', $data);
......
......@@ -54,7 +54,11 @@ class webserver_plugin {
global $app;
$app->plugins->registerAction('server_plugins_loaded', $this->plugin_name, 'check_phpini_changes');
$app->plugins->registerEvent('server_update', $this->plugin_name, 'server_update');
$app->plugins->registerEvent('server_php_insert', $this->plugin_name, 'server_php_update');
$app->plugins->registerEvent('server_php_update', $this->plugin_name, 'server_php_update');
}
/**
......@@ -184,6 +188,36 @@ class webserver_plugin {
unset($processed);
}
/**
* The method runs each php.ini file through verify_php_ini()
*/
function server_php_update($event_name, $data) {
global $app, $conf;
if(isset($data['new']['php_fastcgi_ini_dir'])) {
$php_ini = $data['new']['php_fastcgi_ini_dir'] . '/php.ini';
if(file_exists($php_ini)) {
$this->verify_php_ini(array('file' => $php_ini,
'mode' => 'fast-cgi',
'php_version' => $data['new']['server_php_id'])
);
} else {
$app->log("Cannot verify php.ini, file not found: $php_ini", LOGLEVEL_WARN);
}
}
if(isset($data['new']['php_fpm_ini_dir'])) {
$php_ini = $data['new']['php_fpm_ini_dir'] . '/php.ini';
if(file_exists($php_ini)) {
$this->verify_php_ini(array('file' => $php_ini,
'mode' => 'php-fpm',
'php_version' => $data['new']['server_php_id'])
);
} else {
$app->log("Cannot verify php.ini, file not found: $php_ini", LOGLEVEL_WARN);
}
}
}
/**
* The method checks/sets needed php.ini settings
*/
......@@ -281,7 +315,32 @@ class webserver_plugin {
}
}
}
$check_files = array();
if ($old['php_ini_path_apache'] != $new['php_ini_path_apache']) {
$check_files[] = array('file' => $new['php_ini_path_apache'],
'mode' => 'mod',
'php_version' => 0);
}
if ($old['fastcgi_phpini_path'] != $new['fastcgi_phpini_path']) {
$check_files[] = array('file' => $new['fastcgi_phpini_path'],
'mode' => 'fast-cgi',
'php_version' => 0);
}
if ($old['php_ini_path_cgi'] != $new['php_ini_path_cgi']) {
$check_files[] = array('file' => $new['php_ini_path_cgi'],
'mode' => 'fast-cgi',
'php_version' => 0);
}
if ($old['php_fpm_ini_path'] != $new['php_fpm_ini_path']) {
$check_files[] = array('file' => $web_config['php_fpm_ini_path'],
'mode' => 'php-fpm',
'php_version' => 0);
}
foreach ($check_files as $file) {
$this->verify_php_ini($file);
}
}
}
?>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment