Node Search combined with Views content breaks pager

Created on 18 September 2017, almost 7 years ago
Updated 4 August 2023, about 1 year ago

Steps to reproduce

  1. Install latest Drupal 8, install profile standard.
  2. Install devel_generate (from devel) to generate a considerable amount of node content.
  3. Install block_field to create references to views.
  4. Generate enough (eg. 100) nodes.
  5. Create a random view, making sure that it has a few pages of content (so also make sure you enable the pager).
  6. Create a "Block (plugin)" field type in the page node type. (use default settings).
  7. Search for a common Lipsum term (eg. "imputo") within Drupal Search (search/node)
  8. Go to search results page 2
  9. Edit one of the search results, any one of them and refer the View created earlier in the block field.
  10. Go back to search results page 2
  11. Note that the pager has disappeared / changed in count of pages / other weird results (or if not, rebuild the caches and reload the page)
  12. Also note that the pager reappears when you reload the page

Debugging (untill now)

I've been debugging this a bit further and I've tracked this down this far:

  • The view gets rendered since it's part of the content of the node, I think this is done to highlight the correct keywords in the results
  • When it gets rendered it will attempt to initialise the pager and sets up the global pager variables in core/modules/views/src/Plugin/views/pager/SqlBase.php -> updatePageInfo(). It does this directly into the pager globals and uses the element id set in the $this->options['id'].
  • It seems that the aforementioned $this->options['id'] will be `0` probably because this is run in another scope then the globals for the results page. Or Views does not generate the new id correctly, I'm not sure.
  • Because `0` is used as pager id, the results pager id get overruled and will mix up the variables, causing weird results for the search results page

To be fixed in...?

I'm not entirely sure where this should be fixed, but I can imagine that this might be caused by the way Search renders the content of the results. Therefor I'm (for now) parking this issue in Search. Also, I'm not sure if this will only effect content with rendered Views content. I can imagine this also effecting other rendered Node content with pagers.

I'm also aware I'm using `block_field` which is a non-core module, but I think that this issue will also be caused by other means of implementing Views into node content (like hook_preprocess_node()).

Further research is probably better to be handled by the affecting modules maintainers.

πŸ› Bug report
Status

Closed: cannot reproduce

Version

11.0 πŸ”₯

Component
SearchΒ  β†’

Last updated 5 days ago

  • Maintained by
  • πŸ‡ΊπŸ‡ΈUnited States @pwolanin
Created by

πŸ‡³πŸ‡±Netherlands nielsva

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡³πŸ‡ΏNew Zealand quietone New Zealand

    There has been no discussion here for 6 years. The steps to reproduce require a contrib module, so we don't know if this is a core problem or not. There was a confirmation of the problem but that doesn't say if the contrib module was used or not.

    I testing this on Drupal 11.x and using the steps to reproduce I was not able to reproduce the problem.

    Given the above I am going to close this as cannot reproduce.

    If you are experiencing this problem on a supported version of Drupal reopen the issue, by setting the status to 'Active', and provide complete steps to reproduce the issue β†’ (starting from "Install Drupal core").

    Thanks!

Production build 0.71.5 2024