5 * Run the PHP+MySQL system requirements checks from Civi\Install\Requirements.
7 * Aesthetically, I'd sorta prefer to remove this and (instead) migrate the
8 * `Requirements.php` so that each check was its own plugin. But for now this works.
11 if (!defined('CIVI_SETUP')) {
12 exit("Installation plugins must only be loaded by the installer.\n");
15 \Civi\Setup
::dispatcher()
16 ->addListener('civi.setup.checkRequirements', function (\Civi\Setup\Event\CheckRequirementsEvent
$e) {
17 $model = $e->getModel();
18 $r = new \Civi\Install\
Requirements();
20 \Civi\Setup
::log()->info(sprintf('[%s] Run Requirements::checkSystem()', basename(__FILE__
)));
21 $systemMsgs = $r->checkSystem(array(/* no $file_paths to pass - we check those elsewhere */));
22 _corereqadapter_addMessages($e, 'system', $systemMsgs);
24 \Civi\Setup
::log()->info(sprintf('[%s] Run Requirements::checkDatabase()', basename(__FILE__
)));
25 list ($host, $port) = \Civi\Setup\DbUtil
::decodeHostPort($model->db
['server']);
26 $dbMsgs = $r->checkDatabase(array(
29 'username' => $model->db
['username'],
30 'password' => $model->db
['password'],
31 'database' => $model->db
['database'],
32 'ssl_params' => $model->db
['ssl_params'] ??
NULL,
34 _corereqadapter_addMessages($e, 'database', $dbMsgs);
38 * @param \Civi\Setup\Event\CheckRequirementsEvent $e
39 * Symbolic machine name for this group of messages.
40 * Ex: 'database' or 'system'.
42 * A list of messages in the format used by \Civi\Install\Requirements
44 function _corereqadapter_addMessages($e, $section, $msgs) {
46 \Civi\Install\Requirements
::REQUIREMENT_OK
=> 'info',
47 \Civi\Install\Requirements
::REQUIREMENT_WARNING
=> 'warning',
48 \Civi\Install\Requirements
::REQUIREMENT_ERROR
=> 'error',
51 foreach ($msgs as $msg) {
52 $e->addMessage($severityMap[$msg['severity']], $section, $msg['title'], $msg['details']);