Omit an extra request when the pager is used

Created on 7 August 2024, 11 months ago

Problem/Motivation

When we use pager there still exists a call to the parent <?PHP 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.

πŸ“Œ Task
Status

Active

Version

6.0

Component

Tests

Created by

πŸ‡ΊπŸ‡¦Ukraine init90 Ukraine

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024