Browse Source

Check the required PHP extensions before starting the daemon

pull/1456/head
Timothée Jaussoin 3 months ago
parent
commit
fa18717e56
  1. 1
      CHANGELOG.md
  2. 37
      app/Helpers/UtilsHelper.php
  3. 2
      src/Movim/Console/ClearTemplatesCache.php
  4. 2
      src/Movim/Console/CompileLanguages.php
  5. 2
      src/Movim/Console/CompileOpcache.php
  6. 2
      src/Movim/Console/CompileStickers.php
  7. 2
      src/Movim/Console/ConfigCommand.php
  8. 9
      src/Movim/Console/DaemonCommand.php
  9. 2
      src/Movim/Console/EmojisToJsonCommand.php
  10. 4
      src/Movim/Console/SetAdmin.php
  11. 33
      src/Movim/Daemon/Session.php

1
CHANGELOG.md

@ -18,6 +18,7 @@ v0.31 (master)
* Add a placeholder if a Post is not accessible without a contact subscription
* Add a little helper in the Publish widget when publishing publicly and the blog is configured on presence
* Add SDP to Jingle and Jingle to SDP debug tool
* Check the required PHP extensions before starting the daemon
v0.30.1
---------------------------

37
app/Helpers/UtilsHelper.php

@ -194,6 +194,43 @@ function resolveInfos($postCollection)
}
}
/**
* Get required PHP extensions
*/
function requiredExtensions(): array
{
$extensions = [
'curl',
'dom',
'imagick',
'mbstring',
'openssl',
'pdo',
'simplexml',
'xml',
];
// ext-json is included in PHP since 8.0
if (version_compare(PHP_VERSION, '8.0.0') < 0) {
array_push($extensions, 'json');
}
if (config('database.driver') == 'mysql') {
array_push($extensions, 'mysqlnd');
array_push($extensions, 'mysqli');
array_push($extensions, 'pdo_mysql');
} else {
array_push($extensions, 'pdo_pgsql');
}
// Optional extension
if (extension_loaded('bcmath')) {
array_push($extensions, 'bcmath');
}
return $extensions;
}
/**
* Form to array
*/

2
src/Movim/Console/ClearTemplatesCache.php

@ -31,6 +31,6 @@ class ClearTemplatesCache extends Command
$output->writeln('<info>Template cache cleared</info>');
return 0;
return Command::SUCCESS;
}
}

2
src/Movim/Console/CompileLanguages.php

@ -30,6 +30,6 @@ class CompileLanguages extends Command
$locale->compilePos();
$output->writeln('<info>Compiled po files</info>');
return 0;
return Command::SUCCESS;
}
}

2
src/Movim/Console/CompileOpcache.php

@ -44,6 +44,6 @@ class CompileOpcache extends Command
$output->writeln('Set opcache.enable=1 and opcache.enable_cli=1');
}
return 0;
return Command::SUCCESS;
}
}

2
src/Movim/Console/CompileStickers.php

@ -66,6 +66,6 @@ class CompileStickers extends Command
}
$output->writeln('<info>' . $count . ' stickers compiled</info>');
return 0;
return Command::SUCCESS;
}
}

2
src/Movim/Console/ConfigCommand.php

@ -115,6 +115,6 @@ class ConfigCommand extends Command
}
}
return 0;
return Command::SUCCESS;
}
}

9
src/Movim/Console/DaemonCommand.php

@ -56,6 +56,13 @@ class DaemonCommand extends Command
exit;
}
foreach (requiredExtensions() as $extension) {
if (!extension_loaded($extension)) {
$output->writeln('<comment>The following PHP extension is missing: ' . $extension . '</comment>');
return Command::FAILURE;
}
}
$loop = Loop::get();
if (config('daemon.url')) {
@ -134,6 +141,6 @@ class DaemonCommand extends Command
(new IoServer($app, $socket, $loop))->run();
return 0;
return Command::SUCCESS;
}
}

2
src/Movim/Console/EmojisToJsonCommand.php

@ -70,6 +70,6 @@ class EmojisToJsonCommand extends Command
$output->writeln('<info>'.\count($json).' emojis saved</info>');
return 0;
return Command::SUCCESS;
}
}

4
src/Movim/Console/SetAdmin.php

@ -45,11 +45,11 @@ class SetAdmin extends Command
$user->save();
return 0;
return Command::SUCCESS;
}
$output->writeln('<error>User '.$input->getArgument('jid').' not found</error>');
return 1;
return Command::FAILURE;
}
}

33
src/Movim/Daemon/Session.php

@ -28,6 +28,8 @@ class Session
public bool $registered = false;
public bool $started = false;
private $state;
private $verbose;
@ -35,17 +37,6 @@ class Session
private $language;
private $extensions = [
'curl',
'dom',
'imagick',
'mbstring',
'openssl',
'pdo',
'simplexml',
'xml',
];
public function __construct(
LoopInterface $loop,
string $sid,
@ -122,25 +113,7 @@ class Session
// Only load the required extensions
$configuration = '-n ';
// ext-json is included in PHP since 8.0
if (version_compare(PHP_VERSION, '8.0.0') < 0) {
array_push($this->extensions, 'json');
}
if (config('database.driver') == 'mysql') {
array_push($this->extensions, 'mysqlnd');
array_push($this->extensions, 'mysqli');
array_push($this->extensions, 'pdo_mysql');
} else {
array_push($this->extensions, 'pdo_pgsql');
}
// Optional extension
if (extension_loaded('bcmath')) {
array_push($this->extensions, 'bcmath');
}
foreach ($this->extensions as $extension) {
foreach (requiredExtensions() as $extension) {
$configuration .= '-dextension=' . $extension . '.so ';
}

Loading…
Cancel
Save