Problem/Motivation

The function getSchema in the class Drupal\patternkit\Entity\Pattern is checking if the schema is value with isset($schema). But schema is always defined and never null it's a Drupal\Core\Field\FieldItemList.

$schema = $this->get('schema');
    if (!isset($schema)) {
         $this->fetchAssets();
    }

Proposed resolution

  $item = $this->get('schema')->first();
    if (empty($item)) {
      $this->fetchAssets();
      $item = $this->get('schema')->first();
    }

Issue fork patternkit-3345356

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

churel created an issue. See original summary.

slucero’s picture

Good catch! This looks like a lot cleaner solution for fetching those values. For consistency I'd like to apply that same pattern to the other getter methods in that class as well, and then this should be good to go!

slucero’s picture

Status: Active » Needs review
Parent issue: » #3327256: Beta 7 Release Plan

  • slucero committed 3dbd80d9 on 9.1.x authored by churel
    Issue #3345356 by churel, slucero: getSchema is not able to fetch asset...
slucero’s picture

Status: Needs review » Fixed

Merging for inclusion in the Beta 7 release via #3327256: Beta 7 Release Plan.

Thanks for the work here!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.