Problem/Motivation

public function validate($entity, Constraint $constraint) {
    $term_storage = $this->entityTypeManager->getStorage($entity->getEntityTypeId());
    assert($term_storage instanceof TermStorageInterface);

    // Newly created entities should be able to specify a parent.
    if ($entity && $entity->isNew()) {
      return;
    }

    $is_pending_revision = !$entity->isDefaultRevision();
    $pending_term_ids = $term_storage->getTermIdsWithPendingRevisions();
    $ancestors = $term_storage->loadAllParents($entity->id());
    $ancestor_is_pending_revision = (bool) array_intersect_key($ancestors, array_flip($pending_term_ids));

    $new_parents = array_column($entity->parent->getValue(), 'target_id');
    $original_parents = array_keys($term_storage->loadParents($entity->id())) ?: [0];
    if (($is_pending_revision || $ancestor_is_pending_revision) && $new_parents != $original_parents) {
      $a = 1;
      $this->context->buildViolation($constraint->message)
        ->atPath('parent')
        ->addViolation();
    }

    $original = $term_storage->loadUnchanged($entity->id());
    if (($is_pending_revision || $ancestor_is_pending_revision) && !$entity->weight->equals($original->weight)) {
      $this->context->buildViolation($constraint->message)
        ->atPath('weight')
        ->addViolation();
    }
  }

$a = 1; is one-line debug code. introduced in #2880149: Convert taxonomy terms to be revisionable, see the commit

Proposed resolution

Remove it.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jungle created an issue. See original summary.

jameszhang023’s picture

Assigned: Unassigned » jameszhang023

Working on this.

jameszhang023’s picture

Assigned: jameszhang023 » Unassigned
Status: Active » Needs review
FileSize
939 bytes

Review please, thanks.

jungle’s picture

Status: Needs review » Reviewed & tested by the community

@jameszhang023, thanks for submitting the patch.

Assuming testing will pass. Setting to RTBC.

This one is inspired by #3156070: Unused local variables from ConfigSchemaTest file, wondering should we file a meta issue for removing unused variables.

jungle’s picture

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

This is debug that somehow got left in.

Committed and pushed ec71190699 to 9.1.x and a23766579b to 9.0.x and 5f8df0e91f to 8.9.x. Thanks!

  • alexpott committed ec71190 on 9.1.x
    Issue #3160169 by jameszhang023: Unused variable $a in \Drupal\taxonomy\...

  • alexpott committed a237665 on 9.0.x
    Issue #3160169 by jameszhang023: Unused variable $a in \Drupal\taxonomy\...

  • alexpott committed 5f8df0e on 8.9.x
    Issue #3160169 by jameszhang023: Unused variable $a in \Drupal\taxonomy\...

Status: Fixed » Closed (fixed)

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