Problem/Motivation
Views bulk actions load entities directly instead of using the plugin manager.
The core action is a plugin with a manager. It also has an internal way of handling the different "types" of plugins.
See \Drupal\Core\Action\ActionManager
However when views generates the bulk action form it relies on the loading of the action config entities directly, causing plugins that are derived/defined in code not to be displayed.
See \views_views_data() the stanza below // Registers an action bulk form per entity.
Steps to reproduce
- Install Drupal with standard profile
- Create at least one node
- Add a new Action plugin class to the standard namespace (with type "node"). Example action plugin attached
- Flush the caches
- Review the available bulk actions on /admin/content
Expected: The new action is visible in the dropdown
Actual: It's not visible (since it doesn't have an underlying config entity)
Proposed resolution
Use the manager plugin instead of the loading of the action entities directly.
The forced adding of extra config entities has the potential to generate a lot of bloated extra code to provide a very simple functionality. Compared to the deriver logic. An example can be found here: https://www.drupal.org/node/2912390
Remaining tasks
Make existing config entity implementations compatible with this logic.
Test coverage.
User interface changes
API changes
Data model changes
Release notes snippet
| Comment | File | Size | Author |
|---|---|---|---|
| #26 | reroll-2912390-20.patch | 6.93 KB | sahana _n |
| #20 | interdiff_19_20.txt | 2.02 KB | ameymudras |
| #20 | 2912390-20.patch | 6.61 KB | ameymudras |
| #19 | 2912390-19.patch | 6.18 KB | mstrelan |
| #19 | MyAction.php_.txt | 651 bytes | mstrelan |
Issue fork drupal-2912390
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
suranga.gamage commentedComment #3
suranga.gamage commentedSimple patch that swaps out the direct loading for the plugin manager based building of the forms.
Comment #4
suranga.gamage commentedComment #5
suranga.gamage commentedComment #6
suranga.gamage commentedComment #7
suranga.gamage commentedFix the submit for the bulk action form.
Still to do/validate
- Check or this still respects bulk
- Validate that only actions that don't require extra options are displayed.
Comment #19
mstrelan commentedI've reviewed this for Bug Smash Initiative. I was able to reproduce the issue and have update the issue summary a bit to try make it a bit clearer, including an example action plugin. Had to re-roll the patch which I've also attached. We need to add test coverage as the next step.
Can you clarify why is meant by "Make existing config entity implementations compatible with this logic."?
Comment #20
ameymudras commentedTrying to fix CCF with the above patch
Comment #21
smustgrave commentedNot ready for review as this still needs tests and open question in #19
Comment #23
adaragao commentedDoesn't work with Drupal 10.3.2
Comment #24
adaragao commentedDoesn't work with Drupal 10.3.2
Comment #25
adaragao commentedPlease delete this and the previous comment. I had a network problem and submitted the same post multiple times. Sorry.
Comment #26
sahana _n commentedHi,
1. I rerolled the patch.
2. I modified the module and created the config file. (system.action.action_name.yml)
I was able to see the action in the dropdown.
If I missed anything, please let me know. I would greatly appreciate any guidance.
Comment #27
sahana _n commentedComment #29
smustgrave commentedPreviously tagged for tests which are still needed
Comment #30
adaragao commentedThank you sahana _n.
But still, composer install wasn't able to apply the patch.
I'm I missing something ?