The pager disappears from a view with VBO enabled whenever a page after 1 is selected, if the Items Per Page option is exposed. I was able to reproduce this on a fresh install of Drupal 8.9.16 with VBO 3.13. I added 13 nodes and created a view of them with 5 items per page. The pager works correctly while Items Per Page is not exposed. After exposing the Items Per Page option, the pager disappears on pages after 1.
I tracked this down to the getLabels function of ViewsBulkOperationsActionProcessor.php. When this calls $this->populateQueue, it attempts to set the Items Per Page to 0 with
$this->view->setItemsPerPage($batch_size);
This works while Items Per Page is not exposed, but when it is exposed Views ignores this and sets it back to the specified value - this appears to be hardcoded into core, it checks for items_per_page in the query string at line 270 of core/modules/views/src/Plugin/views/pager/SqlBase.php
Since ViewsBulkOperationsActionProcessor.php uses a ViewExecutable to get its info, the Pager Manager will override the pager for the actual View on the page. This causes the unintended behavior - in my case the pager is disappearing because the filtered version of the view from ViewsBulkOperationsActionProcessor returns less than 1 page worth of results.
The same problem may happen with exposed offset, I didn't test that.
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | 3222477-8.patch | 803 bytes | rajab natshah |
| #4 | 3222477-4-pager-broken-when-items-per-page-exposed.patch | 902 bytes | hughworm |
Issue fork views_bulk_operations-3222477
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
kkasson commentedComment #3
hughworm commentedI have the same issue with version 4.0.0, and the same workaround.
Comment #4
hughworm commentedI have a fix for this issue but it needs a bit of finessing and testing.
The ViewsBulkOperationsActionProcessor::populateQueue() method executes the view which overwrites the view pager.
A simple fix I've made is to change the pager id before executing the view.
Question is what id to use; for simplicity I just add 1000 to the real pager id, but maybe this needs to be configurable.
Patch attached.
Comment #5
qusai taha commentedThanks, @hughworm for the patch, the patch working well.
The patch fix issue when selecting more than items then clicking on the pager, the pager was broken, but after applying the patch the pager worked well.
Comment #6
rajab natshahPatch #4 is working
Tested with views_bulk_operations-4.0.0
Thank you, Hugh for patching this issue
Comment #7
rajab natshahAfter one more round of testing with costumed "Exposed items per page options"
Is better.
or the pass of the current selected "Exposed items per page options" filter
Having a custom change for the "Exposed items per page options" in the following view pages:
Comment #8
rajab natshahComment #9
rajab natshahAfter the fix:
Content Table - Page 1 - Selected 3 - (Items per page selected 5 )
Content Table - Page 2 - with Selected 3 from page 1- (Items per page selected 5 )
Media Grid - Page 1 - Selected 2 - (Items per page selected 24 )
Media Grid - Page 2 - with Selected 2 from page 1- (Items per page selected 24 )
Comment #10
rajab natshahComment #11
rajab natshahComment #12
rajab natshahComment #14
graber commentedComment #15
graber commentedCan we try setting the pager ID to a negative value (-10 for example)? If that'll not work, I'd go for a big positive integer like 1000 so there are no chances this'll interfere with anything.
@Rajab Natshah, your MR reverts many other changes already introduced, please start over if you're willing to continue this work.
Comment #17
rajab natshahThank you, Marcin for having time to follow up on this issue.
Created a new branch 3222477-2--from-4.0.x in the same issue fork.
A new MR was created with the needed changes only :)
Comment #18
graber commentedThank you, #15 needs to be addressed.
Comment #20
graber commentedComment #21
rajab natshahThanks, Marcin for commenting and the release :)
Please, allow me to have this follow up comment.
In #7
I had a testing round with 1000 before
1000 May brack when having a display of pager around 10 pages with a custom exposed selection of 50, 100 in the page
As the need to do any bulk operation is paired with the selection of a big number of items. Content admins will need to switch to show 50 or 100 in custom views with VBO.
Having the option id with the items per page will make sure
So that the patch in #8 was uploaded.
I hope that this point is clearer now.
I thought it was clear in #7, and #8
Comment #22
graber commented@Rajab Natshah, I don't understand you unfortunately.
Can you please add a testing scenario that'll fail now on 4.1.1?
Comment #23
graber commentedProbably making it
$pager->options['id'] = 1000;wasn't good, TBH I missed the+=and tests passed. But I still need to know what fails now.Comment #24
graber commented@Rajab, please check the above solution. Made the ID bigger by 1000 and added a check if a view does have a pager.
Comment #26
graber commentedI decided to merge this as it was already tested. If something will go wrong, we'll just probably have one more hotfix release, no matter how bad it'll look.
Thanks for being watchful Rajab!
Comment #27
rajab natshahThanks, Marcin for following up on the issue and the quick fix release.
Your logic is better with the check for the pager options array.
Working on
#3271292: Update Views Bulk Operations (VBO) from 4.1.0 to ~4.1 and remove committed patches
Following with a full round of testing for sure
I will look into
@todo Check if we can use something else to set this value.