3

Reason: Receiving uid does not exist error. Upon investigating, this error appears only when we edit or save the preexisting columns paragraph. If we create new columns paragraph, the error doesn't appear as the uuid is different for the newly created columns paragraph.

This is the reason to update the uuid for a paragraph that is referenced on that page. In my custom module I have loaded all nodes using entity query below and loaded the referenced paragraph.

$nids = \Drupal::entityQuery('node')
  ->condition('type', 'page')
  ->execute();
$nodes = \Drupal\node\Entity\Node::loadMultiple($nids);

  foreach ($nodes as $n) {
   //Relevant apragraph for the content type
   $para = $n->get('field_page_content')->getValue();
   $para_2 = $n->get('field_banner_image')->getValue();

   foreach($para as $e){
     $p = \Drupal\paragraphs\Entity\Paragraph::load($e['target_id']);

    if($p->bundle() == "columns"){
      kint($p,'Paragraph Entity');
      kint($p->uuid(),'Paragraph UUID');

       $uuid = 'd12da227-890b-4eb7-86b1-93937e7d6d91';

       //save paragraph
       //$p->save();

    }
  }
}

How can I get this updated without recreating the columns paragraph as there are quite a few.

4
  • 2
    The UUID of the paragraph will be the unique identifier of the paragraph, not the owner of the paragraph. The UID of the paragraph will be the User ID of the owner of the paragraph. It's not clear from your post which one you actually want.
    – Jaypan
    Commented Mar 20, 2019 at 22:10
  • @Jaypan updates : Updated the question, I wan to update the UUID of the paragraph. How do I do this
    – Regokonda
    Commented Mar 20, 2019 at 23:43
  • Sorry, I don't have the answer to that. I just wanted to help you clarify your question as it was confusing. You may also want to state your end goal, as changing the UUID may not be the best way to go about it.
    – Jaypan
    Commented Mar 21, 2019 at 0:09
  • @Jaypan Thanks for notifying that. will add the reason for this issue soon
    – Regokonda
    Commented Mar 21, 2019 at 4:56

1 Answer 1

2

This is the route to go if you must add the uuid in this manner.

$uuid = 'd12da227-890b-4eb7-86b1-93937e7d6d91';
$p->set('uuid',$uuid);
$p->save();
1
  • Hi Matt thanks, great that worked. +1 for this.
    – Regokonda
    Commented Apr 1, 2019 at 6:20

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.