backdrop-issues icon indicating copy to clipboard operation
backdrop-issues copied to clipboard

Empty search results gives error re mini pager

Open leeksoup opened this issue 1 year ago • 4 comments

Description of the bug

When using the site search with the mini pager, I get errors if there are no results found.

Steps To Reproduce

To reproduce the behavior:

  1. Go to 'admin/config/search/settings'
  2. Enable mini pager for search results and save the config.
  3. Go to the site search page at 'search/node'
  4. In the search box, enter something that doesn't exist on the site, say 'arknvpanmezxq'
  5. Click 'Search'

Actual behavior

These errors appear, in addition to the expected message about no results found.

Warning: Trying to access array offset on value of type null in theme_views_mini_pager() (line 1146 of /var/www/backdrop1/core/modules/views/templates/views.theme.inc).
Warning: Trying to access array offset on value of type null in theme_views_mini_pager() (line 1148 of /var/www/backdrop1/core/modules/views/templates/views.theme.inc).
Warning: Trying to access array offset on value of type null in theme_views_mini_pager() (line 1151 of /var/www/backdrop1/core/modules/views/templates/views.theme.inc).

Expected behavior

Should not get those errors. :)

Additional information

Add any other information that could help, such as:

  • Backdrop CMS version: 1.27.0
  • Web server and its version: Apache/2.4.54
  • PHP version: 8.1.15
  • Database sever (MySQL or MariaDB?) and its version: 10.5.18-MariaDB
  • Operating System and its version: Fedora 35
  • Browser(s) and their versions: Brave 1.61.104

leeksoup avatar Mar 26 '24 22:03 leeksoup

The code in question:

  // Current is the page we are currently paged to.
  $pager_current = $pager_page_array[$element] + 1;    // line 1146
  // Max is the maximum page number.
  $pager_max = $pager_total[$element];                          // 1148
  // End of marker calculations.

  if ($pager_total[$element] > 1) {                                      // 1151

It appears that $pager_page_array and $pager_total are both NULL in this case.

This looks simple enough that I could do a PR for it....

leeksoup avatar Mar 27 '24 02:03 leeksoup

The PR is ready to be reviewed/tested.

leeksoup avatar Mar 27 '24 03:03 leeksoup

I tested the steps to reproduce on a fresh site and was able to recreate the problem exactly as described.

I tested again on the sandbox site and the problem did not occur. So, the fix works for me in terms of resolving the described problem.

stpaultim avatar Apr 12 '24 22:04 stpaultim

RTBC

herbdool avatar Apr 18 '24 03:04 herbdool

Thanks @leeksoup, @herbdool, @docwilmot, and @stpaultim for fixing this issue! I have merged https://github.com/backdrop/backdrop/pull/4684 into 1.x and 1.27.x. Great job!

quicksketch avatar Apr 26 '24 01:04 quicksketch