1

How to target the initial revision of a node?

This gives me a list of node IDs in which the latest revision of the node is of author $user->id():

$query = \Drupal::entityQuery('node');
$query->condition('uid', $user->id());
$author_nids = $query->execute();

I would like the same but for nodes in which the initial revision was created by $user->id().

5
  • My understanding is that the 'uid' doesn't change, it's always the original author. There's a 'revision_uid' property on the base revision table if you need to query by the revision author instead. So in answer to your question, can you inspect the data? Is something changing the 'uid'?
    – kalpaitch
    Jun 3, 2021 at 8:09
  • has it always been that behaviour throughout all the drupal8 versions? I am not sure . Do u know how to do the drupal query to get the first revision_uid?
    – Matoeil
    Jun 3, 2021 at 12:22
  • the uid change when you edit a content and change "Authored by"
    – Matoeil
    Jun 3, 2021 at 12:47
  • that uid is contradictory with the initial revision or the last revision of the revision table depending what that node table uid shall be
    – Matoeil
    Jun 3, 2021 at 13:20
  • for all revisions $query = \Drupal::entityQuery('node'); $query->condition('revision_uid', $user->id()); $author_nids = $query->execute();
    – Matoeil
    Jun 3, 2021 at 13:43

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.