Commit fa3afd60 authored by Chris Wells's avatar Chris Wells Committed by Ben Mullins
Browse files

Issue #3280006 by chrisfromredfin: May 2022 - Update Fixture

parent fc7d8b41
Loading
Loading
Loading
Loading
+1 −1

File changed.

Preview size limit exceeded, changes collapsed.

+1 −1

File changed.

Preview size limit exceeded, changes collapsed.

+2 −2
Original line number Diff line number Diff line
@@ -349,8 +349,8 @@ function project_browser_hacky_fixture_maker(&$sandbox) {
        'created' => $project['created'],
        'changed' => $project['changed'],
        'project_usage_total' => $project['project_usage_total'] ?? 0,
        'maintenance_status' => $project['taxonomy_vocabulary_44']['id'],
        'development_status' => $project['taxonomy_vocabulary_46']['id'],
        'maintenance_status' => $project['field_maintenance_status']['id'],
        'development_status' => $project['field_development_status']['id'],
        'status' => $project['status'],
        'field_security_advisory_coverage' => $project['field_security_advisory_coverage'],
        'flag_project_star_user_count' => $project['flag_project_star_user_count'] ?? 0,
+5 −8
Original line number Diff line number Diff line
@@ -91,8 +91,6 @@ class DrupalOrgProject {

  protected $field_project_components = [];

  protected $field_project_docs;

  protected $field_project_license;

  protected $field_project_screenshots = [];
@@ -174,7 +172,6 @@ class DrupalOrgProject {
    $this->field_project_ecosystem = $project['field_project_ecosystem'];
    $this->field_security_advisory_coverage = $project['field_security_advisory_coverage'];
    $this->field_project_issue_version_opts = $project['field_project_issue_version_opts'];
    $this->field_project_docs = $project['field_project_docs'];
    $this->field_supporting_organizations = $project['field_supporting_organizations'];
    $this->field_project_images = $project['field_project_images'];
    $this->field_project_license = $project['field_project_license'];
@@ -219,16 +216,16 @@ class DrupalOrgProject {
    }

    // Module categories.
    $this->field_module_categories = $project['field_module_categories'];
    $this->field_module_categories = $project['taxonomy_vocabulary_3'];

    // Maintenance status.
    if (array_key_exists('field_maintenance_status', $project) && $project['field_maintenance_status']) {
      $this->field_maintenance_status = $project['field_maintenance_status'];
    if (array_key_exists('taxonomy_vocabulary_46', $project) && $project['taxonomy_vocabulary_46']) {
      $this->field_maintenance_status = $project['taxonomy_vocabulary_46'];
    }

    // Development status.
    if (array_key_exists('field_development_status', $project) && $project['field_development_status']) {
      $this->field_development_status = $project['field_development_status'];
    if (array_key_exists('taxonomy_vocabulary_44', $project) && $project['taxonomy_vocabulary_44']) {
      $this->field_development_status = $project['taxonomy_vocabulary_44'];
    }
  }

+19 −6
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@

namespace Drupal\project_browser\Plugin\ProjectBrowserSource;

use GuzzleHttp\Exception\RequestException;
use Composer\Semver\Semver;
use Drupal\Component\Serialization\Json;
use Drupal\Core\Database\Connection;
@@ -397,12 +398,24 @@ class MockDrupalDotOrg extends PluginBase implements ProjectBrowserSourceInterfa
   * @see https://www.drupal.org/drupalorg/docs/apis/rest-and-other-apis
   */
  public function getProjectsFromSource(array $query = []): array {
    try {
      $response = $this->httpClient->request('GET', "https://www.drupal.org/api-d7/node.json", [
        'on_stats' => static function (TransferStats $stats) use (&$url) {
          $url = $stats->getEffectiveUri();
        },
        'query' => $query,
      ]);
    }
    catch (RequestException $re) {
      // Try a second time because sometimes d.o times out the request.
      $response = $this->httpClient->request('GET', "https://www.drupal.org/api-d7/node.json", [
        'on_stats' => static function (TransferStats $stats) use (&$url) {
          $url = $stats->getEffectiveUri();
        },
        'query' => $query,
      ]);
    }

    if ($response->getStatusCode() !== 200) {
      throw new \RuntimeException("Request to $url failed, returned {$response->getStatusCode()} with reason: {$response->getReasonPhrase()}");
    }