getVersionExtra example

if ($existing_version = $this->getProjectExistingVersion($sa)) {
      $existing_project_version = ExtensionVersion::createFromVersionString($existing_version);
      $insecure_versions = $sa->getInsecureVersions();
      // If a site codebase has a development version of any project, including       // core, we cannot be certain if their development build has the security       // vulnerabilities that make any of the versions in $insecure_versions       // insecure. Therefore, we should err on the side of assuming the site's       // code does have the security vulnerabilities and show the advisories.       // This will result in some sites seeing advisories that do not affect       // their versions, but it will make it less likely that sites with the       // security vulnerabilities will not see the advisories.       if ($existing_project_version->getVersionExtra() === 'dev') {
        foreach ($insecure_versions as $insecure_version) {
          try {
            $insecure_project_version = ExtensionVersion::createFromVersionString($insecure_version);
          }
          catch (\UnexpectedValueException $exception) {
            // An invalid version string should not halt the evaluation of valid             // versions in $insecure_versions. Version numbers that start with             // core prefix besides '8.x-' are allowed in $insecure_versions,             // but will never match and will throw an exception.             continue;
          }
          

  private function getSecurityCoverageUntilVersion() {
    $existing_release_version = ExtensionVersion::createFromVersionString($this->existingVersion);
    if (!empty($existing_release_version->getVersionExtra())) {
      // Only full releases receive security coverage.       return NULL;
    }

    return $existing_release_version->getMajorVersion() . '.'
      . ($this->getSemanticMinorVersion($this->existingVersion) + static::CORE_MINORS_WITH_SECURITY_COVERAGE)
      . '.0';
  }

  /** * Gets the number of additional minor releases with security coverage. * * This function compares the currently installed (existing) version of * the project with two things: * - The latest available official release of that project. * - The target minor release where security coverage for the current release * should expire. This target release is determined by * getSecurityCoverageUntilVersion(). * * For the sake of example, assume that the currently installed version of * Drupal is 8.7.11 and that static::CORE_MINORS_WITH_SECURITY_COVERAGE is 2. * * Before the release of Drupal 8.8.0, this function would return 2. * * After the release of Drupal 8.8.0 and before the release of 8.9.0, this * function would return 1 to indicate that the next minor version release * will end security coverage for 8.7. * * When Drupal 8.9.0 is released, this function would return 0 to indicate * that security coverage is over for 8.7. * * If the currently installed version is 9.0.0, and there is no 9.1.0 release * yet, the function would return 2. Once 9.1.0 is out, it would return 1. * When 9.2.0 is released, it would again return 0. * * Note: callers should not test this function's return value with empty() * since 0 is a valid return value that has different meaning than NULL. * * @param string $security_covered_version * The version until which the existing version receives security coverage. * * @return int|null * The number of additional minor releases that receive security coverage, * or NULL if this cannot be determined. * * @see \Drupal\update\ProjectSecurityData\getSecurityCoverageUntilVersion() */

  public function testGetVersionExtra(string $version, array $expected_version_info): void {
    $version = ExtensionVersion::createFromVersionString($version);
    $this->assertSame($expected_version_info['extra']$version->getVersionExtra());
  }

  /** * Data provider for expected version information. * * @return mixed[][] * Arrays of version information. */
  public function providerVersionInfos(): array {
    // Data provider values are:     // - The version number to test.
Home | Imprint | This part of the site doesn't use cookies.