Skip to content
Snippets Groups Projects

Return latest revision of content

1 unresolved thread

Closes #3446883

Contains refactored contrib from @bstan

Edited by Al Munnings

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • BRIAN STANNARD
  • @almunnings This looks good to me overall!! I just have one question, but that should not tragically change the approach.

    Not sure why my review comment isn't saving, but... do you have any concern with going to the database twice when the $storage is a TranslatableRevisionableStorageInterface?

    $identifier = $storage->getLatestRevisionId($entity->id());
    
          if ($storage instanceof TranslatableRevisionableStorageInterface) {
            $identifier = $storage->getLatestTranslationAffectedRevisionId($entity_id, $langcode) ?: $identifier;
          }
    Edited by BRIAN STANNARD
  • 123 if (!$entity instanceof RevisionableInterface) {
    124 return $entity;
    125 };
    126
    127 $entity_id = $entity->id();
    128 $entity_type_id = $entity->getEntityTypeId();
    129
    130 // Set the default langcode to the current context language.
    131 $langcode = $language ?: $context->getContextLanguage();
    132
    133 // Quickly resolve the latest revision.
    134 if (in_array($identifier, self::REVISION_LATEST)) {
    135 /** @var \Drupal\Core\Entity\RevisionableStorageInterface $storage */
    136 $storage = $this->entityTypeManager->getStorage($entity_type_id);
    137
    138 $identifier = $storage->getLatestRevisionId($entity->id());
  • Al Munnings added 2 commits

    added 2 commits

    • 9f5a7ff9 - getLatestTranslationAffectedRevisionId requires a langcode, getContextLanguage can return null.
    • e03a0e1d - Split tests to check works with and without translation

    Compare with previous version

  • Al Munnings added 1 commit

    added 1 commit

    • aa053e7a - I don't know if static:revision: does much here, removing

    Compare with previous version

  • Al Munnings added 1 commit

    added 1 commit

    • 74fd5b1e - Opportunity: Split apart the resolve/register methods as a lil cleanup.

    Compare with previous version

  • Al Munnings enabled automatic add to merge train when the pipeline for 397896fe succeeds

    enabled automatic add to merge train when the pipeline for 397896fe succeeds

  • Al Munnings started a merge train

    started a merge train

  • merged

  • Please register or sign in to reply
    Loading