Problem/Motivation

When we use pager there still exists a call to the parent getNextUrls() method which tries to get the next page URL from the response header:

  public function getNextUrls(string $url): array {
    $next_urls = [];

    $headers = $this->getResponse($url)->getHeader('Link');
    if (!empty($headers)) {
      $headers = explode(',', $headers[0]);
      foreach ($headers as $header) {
        $matches = [];
        preg_match('/^<(.*)>; rel="next"$/', trim($header), $matches);
        if (!empty($matches) && !empty($matches[1])) {
          $next_urls[] = $matches[1];
        }
      }
    }

    return array_merge(parent::getNextUrls($url), $next_urls);
  }

It adds an additional request that looks unneeded when the pager is used.
As I understand it's made for BC reasons. The code was used before the pager was added.

Proposed resolution

When some pager is selected prevent the parent method call because in that case, it is unneeded. Use it only if the pager is not selected.

CommentFileSizeAuthor
#2 3466499_2.patch1.38 KBinit90
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

init90 created an issue. See original summary.

init90’s picture

Status: Active » Needs review
StatusFileSize
new1.38 KB
init90’s picture

Component: Tests » Plugins
init90’s picture

Issue summary: View changes

heddn’s picture

I can't tell if the lack of a call to parent will break anyone. I wouldn't think it would, but that's the sticky thing here.

  • heddn committed 30c875db on 6.0.x authored by init90
    Issue #3466499 by init90, heddn: Omit an extra request when the pager is...
heddn’s picture

Status: Needs review » Fixed

I'm going to merge this anyway. We can always revert it pretty easily if it causes issues. And performance fixes are a thing too.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.