Automattic / Automattic/jetpack
Infinite scroll - Bug of Click option with object cache
- Dominant language
- PHP
- Stars
- 1.8k
- Forks
- 898
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 774
Description
There seems to be an object cache-related bug in Infinite Scroll in the latest stable as well as the Bleeding Edge | 8.5-alpha-377-ga9c7093
In particular, when "Load more posts in page with a button" is selected, user options seems to be ignored, while when "Load more posts as the reader scrolls down" is selected, user options are respected.
I'm testing with Redis as object cache, using the following plugin: https://wordpress.org/plugins/redis-cache/
Assume a basic IS integration:
```
add_theme_support( 'infinite-scroll', array(
'container' => 'content-row',
'render' => 'ci_theme_infinite_scroll_render',
'footer' => false,
'wrapper' => false,
'posts_per_page' => get_option( 'posts_per_page' ),
) );
```
This should respect the user's option to have IS with either a 'click' or 'scroll', according to the Jetpack setting (mirrored in Settings > Reading).
Steps to reproduce the problem:
Go to Jetpack Settings > Writing and enable "Load more posts in page with a button" (i.e. 'click').
1) Problem: Visit blog. IS works as if 'scroll' was selected.
2) Problem: Go to Settings > Reading. "Infinite Scroll Behavior" is checked, as if 'scroll' was selected.
3) Problem: Uncheck "Infinite Scroll Behavior" in Settings > Reading. Save changes. Once the page reloads, the "Infinite Scroll Behavior" checkbox is again checked, user action wasn't saved.
4) Problem: Visit blog. IS still works as if 'scroll' was selected. Neither settings page 'click' option is respected.
Now go to Jetpack Settings > Writing and enable "Load more posts as the reader scrolls down" (i.e. 'scroll').
1) Visit blog. IS works on 'scroll', as selected.
2) Go to Settings > Reading. "Infinite Scroll Behavior" is correctly checked.
3) Uncheck "Infinite Scroll Behavior". Save changes. Checkbox is now correctly unchecked.
4) Visit blog. IS works on 'click', as expected due to step 3.
The above issues don't manifest if there's no object cache backend.
I'd guess that the process of persisting the IS values are slightly different for 'click' and 'scroll', with 'scroll' code being more correct than 'click's code.
Contributor guide
Research direction
Reproduce the issue using the Jetpack Writing and WordPress Reading settings with Redis object caching enabled, comparing the click and scroll options in the Infinite Scroll integration. Trace how each option is persisted and restored; done means both choices remain consistent across the settings pages and the blog behavior matches the selected option.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php, redis, wordpress
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100