Skip to content

Conversation

@stooit
Copy link
Contributor

@stooit stooit commented May 6, 2025

When $entity->isPublished() is used in Seed.php it is returning the default language published state, rather than the translated revision.

By passing in an entity loaded via getTranslation we get the true published status of the translated revision.

(This behaviour appears to have been introduced in a relatively recent version of Drupal core).

@stooit stooit force-pushed the feat/lang-published-status branch from 4575149 to 4c60fb7 Compare May 6, 2025 22:50
steveworley
steveworley previously approved these changes May 7, 2025
@kepol
Copy link
Contributor

kepol commented Jul 8, 2025

Assigning to myself for review, testing, and merging.

@kepol kepol self-assigned this Jul 8, 2025
@kepol kepol added bug Something isn't working multilingual Drupal 8 / 9 / 10 labels Jul 8, 2025
@kepol
Copy link
Contributor

kepol commented Jul 8, 2025

It makes more sense to me to put the logic in Seed::seedNode so that any code that calls it will get this change rather than us having to remember to do this any time we call Seed::seedNode. I'll update the code to reflect this.

For example, it's called here too:

  public function onNodeInsert(NodeInsertEvent $event) {
    $entity = $event->getEntity();
    $langcode = $event->getLangcode();

    Seed::seedNode($entity, $langcode);
  }
function _quant_entity_update_op(EntityInterface $entity) {

  $langcode = $entity->language()->getId();
  
  switch ($entity->getEntityTypeId()) {
    case 'node':
      Seed::seedNode($entity, $langcode);
      break;
    
    case 'taxonomy_term':
      Seed::seedTaxonomyTerm($entity, $langcode);
      break;
  }

}

@kepol
Copy link
Contributor

kepol commented Jul 8, 2025

This would also be an issue with taxonomy terms

@kepol kepol dismissed steveworley’s stale review July 8, 2025 23:11

I'm going to do some updates based on my comments

@kepol
Copy link
Contributor

kepol commented Jul 8, 2025

I made the change but need to test it

@kepol
Copy link
Contributor

kepol commented Jul 9, 2025

I've created a branch for 2.x (feat/lang-published-status-2x) and tested against Drupal 11 using cron and it worked as expected... if the translation was unpublished then it didn't send it over when it wasn't supposed to and did when it was

I still need to test the feat/lang-published-status branch against D10

@kepol
Copy link
Contributor

kepol commented Jul 10, 2025

I have tested this branch with D10 and the 2.x version on D11 and my testing notes are here:

https://www.drupal.org/project/quantcdn/issues/353482

There is one issue but it's unrelated to what is being fixed here so I'm marking this approved and will get it merged into 1.x and 2.x accordingly

@kepol kepol merged commit d52b3f4 into 8.x-1.x Jul 10, 2025
2 checks passed
@kepol kepol removed the needs work label Jul 10, 2025
@kepol kepol removed their assignment Jul 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants