Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment | File | Size | Author |
---|---|---|---|
#3 | 3160169-3.patch | 939 bytes | jameszhang023 |
Comments
Comment #2
jameszhang023 CreditAttribution: jameszhang023 commentedWorking on this.
Comment #3
jameszhang023 CreditAttribution: jameszhang023 commentedReview please, thanks.
Comment #4
jungle@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.
Comment #5
jungleFound a meta issue. #2002650: [meta, no patch] improve maintainability by removing unused local variables
Comment #6
alexpottThis 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!