Add to structure within hook - running out of memory

I am trying to add a new structure entry within a hook.

  // add new attendee
  foreach($orderPage->cart() as $cartItem) {
    $cartItemPage = page($cartItem['id']);
    $attendees = $cartItemPage->attendees()->yaml();
    $attendees[] = [
      'name' =>  $cartItemPage->name(),
    ];
    $cartItemPage->save([
      'attendees' => Yaml::encode($attendees)
    ]);
  }

I get this error:

Allowed memory size of 134217728 bytes exhausted (tried to allocate 221184 bytes)

Now if i just change:

$attendees[] = [
      'name' =>  'Bob Smith',
    ];

It works fine, any ideas why this is happening ?

$attendees[] = [
      'name' =>  $cartItemPage->name()->value(),
    ];

this fixes the error, but the structure field is empty

Then $cartItemPage->name()->value() probably doesn’t return anything?

yeah :joy: