function ProjectSecurityData::getCoverageInfo

Same name in other branches
  1. 9 core/modules/update/src/ProjectSecurityData.php \Drupal\update\ProjectSecurityData::getCoverageInfo()
  2. 10 core/modules/update/src/ProjectSecurityData.php \Drupal\update\ProjectSecurityData::getCoverageInfo()
  3. 11.x core/modules/update/src/ProjectSecurityData.php \Drupal\update\ProjectSecurityData::getCoverageInfo()

Gets the security coverage information for a project.

Currently only Drupal core is supported.

Return value

array The security coverage information, or an empty array if no security information is available for the project. If security coverage is based on release of a specific version, the array will have the following keys:

  • security_coverage_end_version (string): The minor version the existing version will receive security coverage until.
  • additional_minors_coverage (int): The number of additional minor versions the existing version will receive security coverage.

If the security coverage is based on a specific date, the array will have the following keys:

  • security_coverage_end_date (string): The month or date security coverage will end for the existing version. It can be in either 'YYYY-MM' or 'YYYY-MM-DD' format.
  • (optional) security_coverage_ending_warn_date (string): The date, in the format 'YYYY-MM-DD', after which a warning should be displayed about upgrading to another version.

File

core/modules/update/src/ProjectSecurityData.php, line 125

Class

ProjectSecurityData
Calculates a project's security coverage information.

Namespace

Drupal\update

Code

public function getCoverageInfo() {
    if (empty($this->releases[$this->existingVersion])) {
        // If the existing version does not have a release, we cannot get the
        // security coverage information.
        return [];
    }
    $info = [];
    $existing_release_version = ModuleVersion::createFromVersionString($this->existingVersion);
    // Check if the installed version has a specific end date defined.
    $version_suffix = $existing_release_version->getMajorVersion() . '_' . $this->getSemanticMinorVersion($this->existingVersion);
    if (defined("self::SECURITY_COVERAGE_END_DATE_{$version_suffix}")) {
        $info['security_coverage_end_date'] = constant("self::SECURITY_COVERAGE_END_DATE_{$version_suffix}");
        $info['security_coverage_ending_warn_date'] = defined("self::SECURITY_COVERAGE_ENDING_WARN_DATE_{$version_suffix}") ? constant("self::SECURITY_COVERAGE_ENDING_WARN_DATE_{$version_suffix}") : NULL;
    }
    elseif ($security_coverage_until_version = $this->getSecurityCoverageUntilVersion()) {
        $info['security_coverage_end_version'] = $security_coverage_until_version;
        $info['additional_minors_coverage'] = $this->getAdditionalSecurityCoveredMinors($security_coverage_until_version);
    }
    return $info;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.