mirror of
https://github.com/humhub/humhub.git
synced 2025-03-14 20:19:47 +01:00
Prerequisites - check for mixed php version/user (#7127)
* Prerequisites: add a warning in case of cron commands executed with a wrong user of PHP version * Prerequisites: add a warning in case of cron commands executed with a wrong user of PHP version --------- Co-authored-by: Lucas Bartholemy <luke-@users.noreply.github.com>
This commit is contained in:
parent
d30aa1c2e5
commit
c6b7cf17d1
@ -7,12 +7,13 @@ HumHub Changelog
|
||||
- Enh #7070: Add GitHub action for PHP CS Fixer
|
||||
- Enh #7073: Add a link to notification settings on top dropdown list
|
||||
- Fix #7100: Enable all file handlers on RichText editor toolbar
|
||||
- Enh #7127: Prerequisites - Check that Web and Cli php version and user is the same
|
||||
- Enh #7128: Prerequisites - check for mixed table collations
|
||||
|
||||
1.16.2 (Unreleased)
|
||||
---------------------
|
||||
- Fix #7102: Fix content search with word ending with hyphen
|
||||
- Fix #7104: Missing `--text-color-default` CSS variable
|
||||
- Enh #7128: Prerequisites - check for mixed table collations
|
||||
|
||||
1.16.1 (July 1, 2024)
|
||||
---------------------
|
||||
|
@ -9,6 +9,7 @@
|
||||
namespace humhub\commands;
|
||||
|
||||
use DateTime;
|
||||
use humhub\libs\SelfTest;
|
||||
use Yii;
|
||||
use yii\console\Controller;
|
||||
use yii\console\ExitCode;
|
||||
@ -37,6 +38,16 @@ class CronController extends Controller
|
||||
*/
|
||||
public const MUTEX_ID = 'cron-mutex';
|
||||
|
||||
public function beforeAction($action)
|
||||
{
|
||||
Yii::$app->cache->set(SelfTest::PHP_INFO_CACHE_KEY, [
|
||||
'version' => phpversion(),
|
||||
'user' => get_current_user(),
|
||||
]);
|
||||
|
||||
return parent::beforeAction($action);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Runs the cron jobs
|
||||
|
@ -24,6 +24,8 @@ use yii\helpers\UnsetArrayValue;
|
||||
*/
|
||||
class SelfTest
|
||||
{
|
||||
public const PHP_INFO_CACHE_KEY = 'cron_php_info';
|
||||
|
||||
/**
|
||||
* Get Results of the Application SelfTest.
|
||||
*
|
||||
@ -481,6 +483,45 @@ class SelfTest
|
||||
}
|
||||
}
|
||||
|
||||
// Checks that WebApp and ConsoleApp uses the same php version and same user
|
||||
if (Yii::$app->cache->exists(self::PHP_INFO_CACHE_KEY)) {
|
||||
$cronPhpInfo = Yii::$app->cache->get(self::PHP_INFO_CACHE_KEY);
|
||||
|
||||
if ($cronPhpVersion = ArrayHelper::getValue($cronPhpInfo, 'version')) {
|
||||
$title = Yii::t('AdminModule.information', 'Settings') . ' - ' . Yii::t('AdminModule.information', 'Web Application and Cron uses the same PHP version');
|
||||
|
||||
if ($cronPhpVersion == phpversion()) {
|
||||
$checks[] = [
|
||||
'title' => $title,
|
||||
'state' => 'OK',
|
||||
];
|
||||
} else {
|
||||
$checks[] = [
|
||||
'title' => $title,
|
||||
'state' => 'WARNING',
|
||||
'hint' => Yii::t('AdminModule.information', 'Web Application PHP version: `{webPhpVersion}`, Cron PHP Version: `{cronPhpVersion}`', ['webPhpVersion' => phpversion(), 'cronPhpVersion' => $cronPhpVersion]),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
if ($cronPhpUser = ArrayHelper::getValue($cronPhpInfo, 'user')) {
|
||||
$title = Yii::t('AdminModule.information', 'Settings') . ' - ' . Yii::t('AdminModule.information', 'Web Application and Cron uses the same user');
|
||||
|
||||
if ($cronPhpUser == get_current_user()) {
|
||||
$checks[] = [
|
||||
'title' => $title,
|
||||
'state' => 'OK',
|
||||
];
|
||||
} else {
|
||||
$checks[] = [
|
||||
'title' => $title,
|
||||
'state' => 'WARNING',
|
||||
'hint' => Yii::t('AdminModule.information', 'Web Application user: `{webUser}`, Cron user: `{cronUser}`', ['webUser' => get_current_user(), 'cronUser' => $cronPhpUser]),
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check Runtime Directory
|
||||
$title = Yii::t('AdminModule.information', 'Permissions') . ' - ' . Yii::t('AdminModule.information', 'Runtime');
|
||||
$path = Yii::getAlias('@runtime');
|
||||
|
Loading…
x
Reference in New Issue
Block a user