Commit dce1e81f authored by heddn's avatar heddn Committed by heddn
Browse files

Issue #3063129 by heddn, tatarbj: Backport DiskSpace

parent 2e5593b5
<?php
/**
* Disk space checker.
*/
class DiskSpace implements ReadinessCheckerInterface {
/**
* Minimum disk space (in bytes) is 10mb.
*/
const MINIMUM_DISK_SPACE = 10000000;
/**
* Megabyte divisor.
*/
const MEGABYTE_DIVISOR = 1000000;
/**
* {@inheritdoc}
*/
public static function run() {
return static::diskSpaceCheck();
}
/**
* Check if the filesystem has sufficient disk space.
*
* @return array
* An array of translatable strings if there is not sufficient space.
*/
protected static function diskSpaceCheck() {
$messages = [];
if (disk_free_space(DRUPAL_ROOT) < static::MINIMUM_DISK_SPACE) {
$messages[] = t('Logical disk "@root" has insufficient space. There must be at least @space megabytes free.', [
'@root' => DRUPAL_ROOT,
'@space' => static::MINIMUM_DISK_SPACE / static::MEGABYTE_DIVISOR,
]);
}
return $messages;
}
}
......@@ -27,7 +27,7 @@ class ReadinessCheckerManager {
static::$checkers['warning'][0][] = 'MissingProjectInfo';
static::$checkers['warning'][0][] = 'ModifiedFiles';
static::$checkers['warning'][0][] = 'PhpSapi';
static::$checkers['error'][0][] = 'PhpSapi';
static::$checkers['error'][0][] = 'DiskSpace';
static::$checkers['error'][0][] = 'ReadOnlyFilesystem';
return static::$checkers;
......
......@@ -11,6 +11,7 @@ files[] = ModifiedFilesService.php
files[] = ReadinessCheckers/ReadinessCheckerManager.php
files[] = ReadinessCheckers/ReadinessCheckerInterface.php
files[] = ReadinessCheckers/BlacklistPhp72Versions.php
files[] = ReadinessCheckers/DiskSpace.php
files[] = ReadinessCheckers/FileOwnership.php
files[] = ReadinessCheckers/MissingProjectInfo.php
files[] = ReadinessCheckers/ModifiedFiles.php
......
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