[6.x] Fix: pagination warm failures are reported against the wrong URL - #15279
Open
steveparks wants to merge 3 commits into
Open
[6.x] Fix: pagination warm failures are reported against the wrong URL#15279steveparks wants to merge 3 commits into
steveparks wants to merge 3 commits into
Conversation
The pagination pool reuses the main pass's rejection handler:
```php
$pool = new Pool($this->client(), $requests, [
'concurrency' => $this->concurrency(),
'fulfilled' => function (Response $response, $index) use ($urls) {
$this->components->twoColumnDetail($this->getRelativeUri($urls->get($index)), '<info>✓ Cached</info>');
},
'rejected' => [$this, 'outputFailureLine'],
]);
```
but `outputFailureLine()` resolves its URI from the **compiled URI list**:
```php
public function outputFailureLine($exception, $index): void
{
$uri = $this->getRelativeUri($this->uris()->get($index));
...
```
`$index` here is an index into the *pagination* pool — `0` for the first page being warmed, `1` for the second — not into `uris()`. So a failed paginated request is reported under whatever unrelated URL happens to sit at that offset in
the main list. The `fulfilled` handler two lines above gets this right, which is what makes the asymmetry look unintentional.
Two consequences:
- The output names a URL that did not fail, and stays silent about the one that did. That is the exact output someone reads when working out why pagination is not caching, so it actively misleads during the investigation it exists for.
- When the pagination pool has more entries than the compiled list has left at that offset, `uris()->get($index)` returns `null` and `getRelativeUri(string $uri)` is called with it — a deprecation on PHP 8.1+, fatal under stricter settings.
### The fix — two edits
**1. Let the failure line be produced for a given URL**, by splitting the message formatting out of the index lookup. No behaviour change to the existing method:
**2. Point the pagination pool at it**, resolving the index against `$urls` the way `fulfilled` already does.
### Notes
- Pure output correctness; nothing about what gets warmed changes.
- The status line is the useful part of that message — a paginated page turned away at the edge reports `403 Forbidden` — which is why it is worth keeping the existing formatting rather than falling back to `$exception->getMessage()`.
Correcting typo introduced after trying to get indentation right for linting when I submit the PR !
Contributor
Author
|
I've clearly done something wrong here (worse than indentation!) — the tests pipeline seems to keep hanging |
Member
|
Don't worry about it. It's not you. GitHub Actions is having issues 😞 |
Contributor
Author
|
Phew! Thanks for letting me know |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The pagination pool reuses the main pass's rejection handler:
but
outputFailureLine()resolves its URI from the compiled URI list:$indexhere is an index into the pagination pool —0for the first page being warmed,1for the second — not intouris(). So a failed paginated request is reported under whatever unrelated URL happens to sit at that offset inthe main list. The
fulfilledhandler two lines above gets this right, which is what makes the asymmetry look unintentional.Two consequences:
uris()->get($index)returnsnullandgetRelativeUri(string $uri)is called with it — a deprecation on PHP 8.1+, fatal under stricter settings.The fix — two edits
1. Let the failure line be produced for a given URL, by splitting the message formatting out of the index lookup. No behaviour change to the existing method:
2. Point the pagination pool at it, resolving the index against
$urlsthe wayfulfilledalready does.Notes
403 Forbidden— which is why it is worth keeping the existing formatting rather than falling back to$exception->getMessage().