1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-23 07:12:41 +01:00

Add a setup warning for major clock skew issues

Summary: See IRC. A user had a database set to 8 hours ahead of their web host. Try to catch and warn about these issues.

Test Plan: Artificially adjusted skew, saw setup warning.

Reviewers: avivey, chad

Reviewed By: chad

Differential Revision: https://secure.phabricator.com/D14371
This commit is contained in:
epriestley 2015-10-30 12:06:47 -07:00
parent f48a833704
commit 4d13b6c6a8

View file

@ -319,9 +319,11 @@ final class PhabricatorMySQLSetupCheck extends PhabricatorSetupCheck {
->addMySQLConfig('innodb_buffer_pool_size');
}
$conn_w = id(new PhabricatorUser())->establishConnection('w');
$ok = PhabricatorStorageManagementAPI::isCharacterSetAvailableOnConnection(
'utf8mb4',
id(new PhabricatorUser())->establishConnection('w'));
$conn_w);
if (!$ok) {
$summary = pht(
'You are using an old version of MySQL, and should upgrade.');
@ -339,6 +341,28 @@ final class PhabricatorMySQLSetupCheck extends PhabricatorSetupCheck {
->setMessage($message);
}
$info = queryfx_one(
$conn_w,
'SELECT UNIX_TIMESTAMP() epoch');
$epoch = (int)$info['epoch'];
$local = PhabricatorTime::getNow();
$delta = (int)abs($local - $epoch);
if ($delta > 60) {
$this->newIssue('mysql.clock')
->setName(pht('Major Web/Database Clock Skew'))
->setSummary(
pht(
'This host is set to a very different time than the database.'))
->setMessage(
pht(
'The database host and this host ("%s") disagree on the current '.
'time by more than 60 seconds (absolute skew is %s seconds). '.
'Check that the current time is set correctly everywhere.',
php_uname('n'),
new PhutilNumber($delta)));
}
}
protected function shouldUseMySQLSearchEngine() {