Skip to content

Subsequent structured Entry URLs are null due to blink #5046

Closed

Description

@jasonvarga

Bug description

In a structured collection, if you were to create multiple entries, only the first one will have a URL.

This only occurs on the same request where you create them. Upon refreshing the page, they will all have URLs as expected.

How to reproduce

Have a structured collection, then create some entries.

$a = tap(Entry::make()->collection('pages')->etc())->save();
$b = tap(Entry::make()->collection('pages')->etc())->save();
$c = tap(Entry::make()->collection('pages')->etc())->save();

$a->url(); // outputs the url
$b->url(); // null
$c->url(); // null

Logs

No response

Versions

Statamic 3.2.30

Installation

Other (please explain)

Additional details

This is happening because we blink the tree contents here:

public function tree($tree = null)
{
return $this->fluentlyGetOrSet('tree')
->getter(function ($tree) {
$key = "structure-{$this->handle()}-{$this->locale()}-".md5(json_encode($tree));
return Blink::once($key, function () use ($tree) {
return $this->structure()->validateTree($tree, $this->locale());
});
})
->args(func_get_args());
}

Activity

  1. jasonvarga commented on Jan 10, 2022

    @jasonvarga
    MemberAuthor

    A workaround is to explicitly put the entries into the tree (which happens when you create an entry through the control panel).

    $collection->structure()->in('en')
      ->append($one)
      ->append($two)
      ->append($three)
      ->save();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions