Problem/Motivation
VBO uses PrivateTempStore to store data such as the selected items for update.
However, sometimes the temp store name includes the view id and display id and some times it does not.
This can lead to inconsistent behaviour whereby sometimes the temp store data can be found and some times it cannot be found.
The result can be selected items are not cleared or items are selected for an action that have not actually been selected for the view.
For example:
/**
* Initialize the current view tempstore object.
*/
protected function getTempstore($view_id = NULL, $display_id = NULL): PrivateTempStore {
if (!isset($this->viewTempstore)) {
$this->tempStoreName = 'views_bulk_operations_' . $view_id . '_' . $display_id;
$this->viewTempstore = $this->tempStoreFactory->get($this->tempStoreName);
}
return $this->viewTempstore;
}
If $view_id and $display_id are null, then the tempStoreName becomes views_bulk_operations__ whereas if the $view_id and $display_id parameters are passed, then they become part of the tempStoreName.
Steps to reproduce
The related bugs are known, but difficult to reproduce. It happens with certain workflows involving multiple VBO enabled Views or multiple operations / cancellations etc.. within a single VBO enabled View. This patch ensures the temp store name is consistent for a View.
Proposed resolution
Pass the $view_id and $display_id parameters to the related temp store functions implemented in ViewsBulkOperationsFormTrait
Remaining tasks
Update the function calls
User interface changes
N/A
API changes
N/A
Data model changes
N/A
Issue fork views_bulk_operations-3572714
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 #3
davidwhthomas commentedMR attached for review, with thanks for the useful module.
Comment #4
davidwhthomas commentedComment #5
astonvictor commentedtested and it works for me
Comment #6
graber commentedI think it'll be enough to reinitialize tempstore in
if
$this->tempStoreNameis different and throw an exception if$this->viewTempstore === NULLand$view_idor$display_idisNULL.Comment #7
pminf@graber Why should it be possible to access the tempstore without passing
$view_idand$display_id? From my understanding both are necessary to make sure you get the correct tempstore. Therefor I would change the function to:Comment #8
graber commentedIt's just that those values are saved statically in a single request so you don't have to pass them all the time.
Comment #9
davidwhthomas commentedI've just updated to version 4.4.8
I added some debug logging, performed various VBO operations, (incl. cancel, select all, etc..)
I was unable to produce a log where tempstore name was inconsistent.
My concern remains there might be some edge case where the `$view_id` or `$display_id` is NULL resulting in a shared tempstore name such as `views_bulk_operations__` However, I'm unable to replicate that issue.
I think ok to close this one for now, could always re-open if the issue persists.
Comment #12
davidwhthomas commentedAh, I just understood Graber's comment in #6 in more detail,
I can try adding that update to a new MR branch for this.
Comment #14
davidwhthomas commentedComment #17
davidwhthomas commentedMR update ready for review. It includes the suggestion from #6 and helps ensure no unexpected edge cases regarding the temp store name.
Comment #18
peri22 commentedI checked MR !171 against the '4.4.x' HEAD. Every call to the tempstore helpers without IDs happens after the tempstore has already been initialized with both, so the new exception does not affect any existing code paths.
The pipeline is green. RTBC.
Comment #19
graber commentedLooks good, thanks!