Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.x] Query for entry origin within the same collection #11514

Merged
merged 2 commits into from
Feb 28, 2025

Conversation

jasonvarga
Copy link
Member

@jasonvarga jasonvarga commented Feb 27, 2025

Seems to fix #10025

I'm honestly a bit skeptical about this fixing the issue, however in my tests, it definitely made a difference.

What I was doing was this...

In Tinkerwell, run this:

use Illuminate\Support\Facades\Http;
use Illuminate\Support\Collection;
use Illuminate\Http\Client\Pool;

$responses = collect(
  Http::pool(
    fn(Pool $pool) => Collection::times(
      50,
      fn() => $pool->get("http://the-site.test")
    )
  )
);

$responses->map
  ->status()
  ->countBy()
  ->all();

This will fire off 50 requests to the home page and output the number of each response status code.

While that's going, I would run artisan cache:clear from the site.

Before the PR, I would fairly consistently see the routeData on null error multiple times.

[
    200 => 43,
    500 => 7
]

After, I wouldn't see it. (I would occasionally see some other sorts of sporadic failures, but they were unrelated.)

[
    200 => 50,
]

The reason this seemingly unrelated line has anything to do with the error is because at some point along the way during building an index it needs to grab the origin. When you do Entry::find() (which is really just Entry::query()->where('id', $id)->first()) it'll need to load up all the id indexes for all collections. If you provide a collection to an entry query, it'll only load the id indexes for the collection(s) you pass it. In this case it'll load an index that's already loaded.

@afonic
Copy link

afonic commented Feb 27, 2025

This seems to solve it for us!

@jasonvarga jasonvarga merged commit fbb4589 into 5.x Feb 28, 2025
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Call to a member function routeData() on null
2 participants