- Issue created by @francismak
- Status changed to Needs review
about 1 year ago 8:35pm 24 August 2023 - last update
about 1 year ago Custom Commands Failed - last update
about 1 year ago Custom Commands Failed - ๐ณ๐ฑNetherlands Lendude Amsterdam
Yup, this is a regression, easily reproduced manually.
Here is a test and a proposed fix for this.
- Status changed to Needs work
about 1 year ago 9:07pm 24 August 2023 The Needs Review Queue Bot โ tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
This does not mean that the patch needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide โ to find step-by-step guides for working with issues.
- Status changed to Needs review
about 1 year ago 6:07am 25 August 2023 - last update
about 1 year ago 30,051 pass, 6 fail - last update
about 1 year ago 30,058 pass, 1 fail - ๐ณ๐ฑNetherlands Lendude Amsterdam
I ran checks and everything, apparently still got it wrong.
This should be better....
The last submitted patch, 5: 3381979-5-TEST-ONLY.patch, failed testing. View results โ
The last submitted patch, 5: 3381979-5.patch, failed testing. View results โ
- last update
about 1 year ago 30,059 pass - ๐ณ๐ฑNetherlands Lendude Amsterdam
Lets see if this gets all the fails fixed
- Status changed to RTBC
about 1 year ago 3:26pm 25 August 2023 - ๐บ๐ธUnited States smustgrave
Confirmed the issue following the steps in the IS.
After applying patch #8 the more link does appear in the preview even without "Always display the more link" setting. See screenshot
- last update
about 1 year ago 30,061 pass - last update
about 1 year ago 30,064 pass - last update
about 1 year ago 30,131 pass - last update
about 1 year ago 30,136 pass - last update
about 1 year ago 30,137 pass - last update
about 1 year ago 30,137 pass - last update
about 1 year ago 30,147 pass - last update
about 1 year ago 30,147 pass 37:03 35:51 Running- last update
about 1 year ago 30,155 pass - last update
about 1 year ago 30,162 pass - last update
about 1 year ago 30,165 pass - last update
about 1 year ago 30,169 pass - last update
about 1 year ago 30,206 pass - last update
about 1 year ago 30,206 pass 22:04 17:35 Running- last update
about 1 year ago 30,362 pass - Status changed to Needs work
about 1 year ago 8:53pm 30 September 2023 - ๐บ๐ธUnited States xjm
Saving credits: @francismak for a good issue report, @Lendude for the fix, and @smustgrave for manually testing.
-
+++ b/core/modules/views/src/Plugin/views/pager/Some.php @@ -18,6 +18,13 @@ + * The original number of items of the query before the limit is applied.
"items of the query" doesn't make sense to me. How about:
The total number of items in the result set before the pager limit is applied.
Is that an accurate description of what this quantity is? Because "limit" without any modifier means something specific in SQL, and you can't get "the number of items before the limit" from an SQL query. You can, however, get the whole result set from a view and then chop it up into pages based on the total number of results versus the items configured to display per page.
-
+++ b/core/modules/views/src/Plugin/views/pager/Some.php @@ -18,6 +18,13 @@ + protected int $numberOfItemsBeforeLimit; @@ -73,7 +80,18 @@ public function query() { + $this->numberOfItemsBeforeLimit = $this->total_items;
Along the lines of the above, I'd suggest a different name for the member property. Maybe
$totalItemsBeforePagerLimit
? -
+++ b/core/modules/views/src/Plugin/views/pager/Some.php @@ -73,7 +80,18 @@ public function query() { + // Use the original number of items if it has been set to determine if there + // are more records.
I don't understand this. Maybe:
Determine if there are more records by comparing the total number of items to the items per page.
-
+++ b/core/modules/views/src/Plugin/views/pager/Some.php @@ -73,7 +80,18 @@ public function query() { + return $this->getItemsPerPage() + && ($this->numberOfItemsBeforeLimit ?? $this->total_items) > $this->getItemsPerPage();
This is awfully complicated logic for a return statement. I'd suggest breaking this out into if/else statements at least. Quoting from the PHP coding standards โ , we shouldn't "attempt to win the Most Compact Condition In Least Lines Of Code Awardโข".
-
+++ b/core/modules/views/tests/src/Kernel/Plugin/SomePagerTest.php @@ -0,0 +1,36 @@ + * Tests the "Some" page.
I'm pretty sure this should be pager, rather than page.
-
+++ b/core/modules/views/tests/src/Kernel/Plugin/SomePagerTest.php @@ -0,0 +1,36 @@ + * Tests "Some" pager hasMoreRecords().
This is a bit... gnomic. How about:
Tests that the "more" link works correctly with the"Some" pager.
And we can add
@see
toInsert\Namespace\Here\Some::hasMoreRecords()
.
-
- Status changed to Needs review
about 1 year ago 11:54am 9 October 2023 - last update
about 1 year ago Custom Commands Failed - ๐ฎ๐ณIndia akshay_d Bangalore
Thanks @xjm for the feedback and @Lendude for making the progress on this issue is good to have in core.
Latest feedback looks valuable to me I have updated those with patch while using the above patch on my project.
Please Review and let me know if i can improve further.
- last update
about 1 year ago Custom Commands Failed - last update
about 1 year ago 30,383 pass - ๐ฎ๐ณIndia akshay_d Bangalore
Sorry for the multiple alert this should FIX the CS now.
Thanks all
- Status changed to RTBC
about 1 year ago 9:16pm 11 October 2023 - ๐บ๐ธUnited States smustgrave
Seems @xjm points have been addressed.
- last update
about 1 year ago 30,394 pass - ๐ฎ๐ณIndia guptahemant
One additional thing i am observing is that after the changes done in https://www.drupal.org/project/drupal/issues/3265798 ๐ [view:total-rows] problem in Display a 'Specified number of items' pager Fixed , if we try to access `$view->total_rows` in custom code, then it returns the count after the pager is applied and not the actual number of results.
Scenario
in custom code implement:
`hook_views_pre_build` and add something like:`$view->getPager()->setItemsPerPage(3);`
Then implement: `hook_views_pre_render` and then do something like:
```
dump($view->total_rows);
```
Assuming initial results were 6, but after calling setItemsPerPage, the total_rows count come out as 3.Not sure if i am doing something incorrect here. but if i comment the code from https://www.drupal.org/project/drupal/issues/3265798 ๐ [view:total-rows] problem in Display a 'Specified number of items' pager Fixed then the total_rows count reflects correctly.
- ๐ฎ๐ณIndia akshay_d Bangalore
@smustgrave, @Lendude, @xjm
Is this still needs some work as its throwing WSOD on the unpublished entities with the indexed views block (Using search_api) with the "some" pager.
Backtrace report:
Steps to reproduce :
- Create a indexed view block (using search_api).
- Place the block on any unpublished node.
- Visit the unpublished node page it will throw WSOD error.
Is the above relevant to fix as a core bug or is it separate thing ?
- last update
about 1 year ago 30,394 pass, 2 fail The last submitted patch, 13: 3381979-13.patch, failed testing. View results โ
- Status changed to Needs work
12 months ago 12:22am 2 December 2023 - ๐บ๐ธUnited States alison
I'm actually running into this bug not just with the "preview" but with my view block display as shown on my site -- but y'all are only running into this bug with the view preview? (I'm trying to figure out if I've run into the same bug or something different.)
(Or maybe it's not just me, per @tjmoyer over here: https://www.drupal.org/project/drupal/issues/3265798#comment-15159116 ๐ [view:total-rows] problem in Display a 'Specified number of items' pager Fixed )
About me:
- Drupal 10.1
- View block display with "display a specified number of items" (I reduced it to "1" for testing)
- More link: Yes ("always show" unchecked -- but when I check it, it does show)
- Link display: Custom link (b/c we've got custom argument stuff going on)
When I view a page where the view block display is placed, the "more" link doesn't show unless I enable "always show." Furthermore, we happen to still be working on the Drupal 10 upgrade for this particular site, so I can see that the "more" link behavior works fine on the Drupal 9 version of the site, and is broken on the Drupal 10 version of the site.
- ๐บ๐ธUnited States alison
FWIW, I tried the patch on #13 applies cleanly and fixes the bug for me (on core 10.1) ๐
(Sorry for the comment noise due to me not thinking to try it before posting my previous comment........)
- last update
12 months ago 29,723 pass - ๐ฆ๐บAustralia genebobmiller
Patch #13 solved the problem initially but I'm seeing the problem re-occurring after a while and requiring a cache clear to bring back the 'more' link.
- Status changed to RTBC
10 months ago 4:44pm 25 January 2024 - ๐ญ๐บHungary szato
Using patch #13 with D 10.1.8 fixed the issue.
Switching to RTBC - failing tests for D 11.x in #13 doesn't seem to be relevant.
The caching issue mentioned in #20 didn't show up for me: tested by unpublishing/publishing contents and the more link was hidden/shown as it should be.
- last update
10 months ago 26,073 pass, 1,835 fail - Status changed to Needs work
10 months ago 6:26pm 29 January 2024 The Needs Review Queue Bot โ tested this issue.
While you are making the above changes, we recommend that you convert this patch to a merge request โ . Merge requests are preferred over patches. Be sure to hide the old patch files as well. (Converting an issue to a merge request without other contributions to the issue will not receive credit.)
- ๐บ๐ธUnited States jjpost
The patch only works when caching on the view is disabled. When selecting "Advanced -> Caching" and set it to either tag based or time, the more link only shows up the first time it displays, but stops working the next time the page is loaded. Only the first page load after a cache clear the "postExecute" method is triggered.
- ๐ท๐ธSerbia sakiland
Here's a great elaboration ๐ More link disappears when time-based views cache is enabled Needs work for the issue, and why we have issue with caching.
- ๐ง๐ชBelgium msnassar
@akshay_d
I couldn't reproduce the issue in #16...
I followed your steps and besides I used both block and embed display types...
Also tested it with/without having indexed items...
For me: $this->total_items is "0" in all cases! - ๐ฌ๐งUnited Kingdom 2dareis2do
Re-upload #13 patch as my composer expects patch to be relative to the core install.
I have a peculiar issue with one view that is filtered by a certain content type. For some reason it appears to only show half of the required items! If I switch the content type then it appears fine.
Also, with this same view, the more link has disappeared from the block version of this view. Applying this patch seems to fix the more link issue for me.
Many thanks
- First commit to issue fork.
- Merge request !9063Issue #3381979 by Lendude, akshay_d, smustgrave, francismak: More link is... โ (Open) created by Grimreaper
- ๐ซ๐ทFrance Grimreaper France ๐ซ๐ท
Hi,
Patch from comment 28 fixed the issue for me on Core 10.3.1. But it does not apply with Composer.
So, I have created a MR against 11.x to push the issue forward. And here is a patch from the MR for Composer usage. (it applies on 10.3.1 too).
- ๐ฌ๐งUnited Kingdom 2dareis2do
For support for applying patches with multiple patch levels you may need to patch composer patches.
- ๐จ๐ฆCanada tame4tex
I feel the solution pursued so far may possibly be the wrong approach.
It was the solution to ๐ [view:total-rows] problem in Display a 'Specified number of items' pager Fixed that triggered this regression. It was fixing the value returned for the token
[view:total-rows]
that resulted inPagerPluginBase::$total_items
always being set to the number of limited query results for the "Some" pager.But what if this assumption was incorrect, what if
[view:total-rows]
should not always return number of limited query results. For example, if I am using the "Some" pager, limited to 5 results when there are 20 and I have a "More link" enabled, I think it would be valid for me to want to add the text "Displaying 5 or 20 results". In which case I would want[view:total-rows]
to return 20.If the code is changed to only override
PagerPluginBase::$total_items
in the postExecute() if a "More link" is not enabled, then this issue would be fixed.I have opened another issue ( ๐ฑ "Some" Pager Plugin and [view:total-rows] Regression Issue Active ) to discuss this proposal as it may require other actions unrelated to this issue.
- ๐ง๐ฏBenin delacosta456
hi
#32 applied correctly on D10.3.6.
But on page refresh the link ALWAYS disappear and only come back afterdrush cr