Skip to content

Commit d52b3f4

Browse files
authored
Merge pull request #249 from quantcdn/feat/lang-published-status
Ensure translation is loaded via getTranslation().
2 parents 1ed63ec + 1547540 commit d52b3f4

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

src/Plugin/QueueItem/NodeItem.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,30 @@ public function send() {
6060
$entity = \Drupal::entityTypeManager()->getStorage('node')->loadRevision($this->vid);
6161
}
6262

63+
if (!$entity) {
64+
\Drupal::logger('quant_seed')->error(
65+
'Failed to load entity for node ID: @id, revision ID: @vid',
66+
[
67+
'@id' => $this->id,
68+
'@vid' => $this->vid,
69+
]
70+
);
71+
return;
72+
}
73+
6374
foreach ($entity->getTranslationLanguages() as $langcode => $language) {
6475
if (!empty($this->filter) && !in_array($langcode, $this->filter)) {
6576
continue;
6677
}
78+
79+
\Drupal::logger('quant_seed')->notice(
80+
'Processing language @langcode for node @id',
81+
[
82+
'@langcode' => $langcode,
83+
'@id' => $this->id,
84+
]
85+
);
86+
6787
Seed::seedNode($entity, $langcode);
6888
}
6989
}

src/Seed.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,10 @@ public static function unpublishRedirect($redirect) {
212212
* Seeds taxonomy term.
213213
*/
214214
public static function seedTaxonomyTerm($entity, $langcode = NULL) {
215+
216+
// Use the translation to ensure correct metadata such as published state.
217+
$entity = $entity->getTranslation($langcode);
218+
215219
$tid = $entity->get('tid')->value;
216220

217221
$url = Utility::getCanonicalUrl('taxonomy_term', $tid, $langcode);
@@ -264,6 +268,9 @@ public static function seedTaxonomyTerm($entity, $langcode = NULL) {
264268
*/
265269
public static function seedNode(EntityInterface $entity, $langcode = NULL) {
266270

271+
// Use the translation to ensure correct metadata such as published state.
272+
$entity = $entity->getTranslation($langcode);
273+
267274
$nid = $entity->get('nid')->value;
268275
$rid = $entity->get('vid')->value;
269276

0 commit comments

Comments
 (0)