Since #1270890: provide a way to provide entity-related views fields went into Views, it is now possible to write back-end independent fields. Based on that it is pretty simple to implement a VBO field that works with the database backend, Search API (there is also an issue in the Search API issue queue #1123454: Integration with views bulk operations (vbo)) and so on.
I was taking a look at it and fixing the handler for normal entities would be pretty simple, as we could just reuse the views_handler_field_entity, which would also remove some code in the views_bulk_operations_handler_field_operations class. Then I realized that there is also support for entity revisions, which makes this approach complicated.
Directly extending the vbo handler from views_handler_field_entity would break the revisions, writing two separate handlers, one for the entities (whereas this extends field_entity handler) and one for revisions (extending the basic field handler), would duplicate much vbo specific code. So I decided to let the VBO handler stay pretty much the same as it was before and to add a specific field entity based handler. As this one can not extend from the vbo handler and the views entity field handler at the same time, some code is copied from the entity field handler.
I'm not really happy with this solution yet, but couldn't think of a better one. So waiting for your opinion.
Comment | File | Size | Author |
---|---|---|---|
#36 | INTERDIFF.txt | 425 bytes | andrewbelcher |
#36 | 1334374-36-use_generic_entity_tables.patch | 6.36 KB | andrewbelcher |
#15 | vbo-views_entity_tables-1334374-15.patch | 3.69 KB | David Hernández |
#11 | vbo-views_entity_tables-1334374-11.patch | 3.67 KB | akozma |
#9 | vbo-views_entity_tables-1334374-9.patch | 3.69 KB | rooby |
Comments
Comment #1
Anonymous (not verified) CreditAttribution: Anonymous commentedHi mh86,
is this patch still valid? You wrote you are not really happy with the current solution. So I wanted to ask if you have something new in the pipeline, before I try the patch.
I think using a generic is the right way to go. I'm using Search API with nodes and want to have VBO support as well. If you combine them you got a pretty slick user interface, not pretty but functional.
Comment #2
bojanz CreditAttribution: bojanz commentedI think the generic entity handler support in Views needs to be extended to support revisions first.
Comment #3
bojanz CreditAttribution: bojanz commentedBased on #2.
I'll look into fixing the generic entity handler support in Views for revisions, before returning to this patch.
Comment #4
rooby CreditAttribution: rooby commentedRegarding #2, is there an issue open for that for views?
Comment #5
bojanz CreditAttribution: bojanz commentedNot yet, only dereine's comment at #1320942: Using field 'Content revision: Revert link (Revert link)' produces 'Warning: illegal offset type in node_access() (line 2857...'.
Comment #6
rooby CreditAttribution: rooby commentedThanks, that issue should cover it.
Comment #7
rooby CreditAttribution: rooby commentedThe patch at
#1344946-1: Recoverable fatal error: Object of class stdClass could not be converted to string in translation_supported_type()
has been committed to views, which also fixes
#1320942: Using field 'Content revision: Revert link (Revert link)' produces 'Warning: illegal offset type in node_access() (line 2857...'
That should make our lives easier here.
Comment #8
rooby CreditAttribution: rooby commentedI've decided that it's time I actually learned how this all works as I've reached the limit of hacking around :)
I think I may have been a little hasty in #7, so I don't believe that is the help we needed.
Comment #9
rooby CreditAttribution: rooby commentedActually, in attempting to fix the rest of the problem in #1320942: Using field 'Content revision: Revert link (Revert link)' produces 'Warning: illegal offset type in node_access() (line 2857...' I discovered that the rest has been fixed in #1475640: Content Revision Delete and Revert links do not render. So on with this.
How about this patch or something similar.
It would probably be best for it to be renamed to views_bulk_operations_handler_field_entity_operations but for the sake of being able to see what has changed I've left that for now.
With the latest views and vbo dev I am using this patch and a patch for search_api and search api vbo is working properly for my small amount of testing :)
I have also tested a little with vbo and a node_revisions view and it is also working.
(adapted from the patch in the op)
Comment #10
bojanz CreditAttribution: bojanz commentedI don't see that working with revisions. You're passing $entity_id instead of $entity_vid as the checkbox value, which means that the correct revision can't get loaded.
Furthermore, seems to me Views still needs a bit of work to handle this properly. It's on my todo list, jut a matter of time.
Comment #11
akozma CreditAttribution: akozma commentedA small modification on patch #9 to get the entity object and not the entity id to get work the function entity_extract_ids correctly.
Insted of $entity = $this->get_value($row); i'm using $entity = $row->entity;
Comment #12
mitchell CreditAttribution: mitchell commentedThis might not be necessary since Views Rules provides generic entity handler support for Views. There's a subtle, yet profound, difference between them, in that View Rules adds support for performing views loops in Rules using its entity wrapper, whereas VBO exposes the results as a list. I'm sure someone else could offer a much better explanation, but the subtle difference is apparent when using them. As a user, what differentiates them is their methodologies and depth of integration.
I had originally followed this issue hoping to do exactly what I just recently did for Views Rules' #1650604-2: Example and/or video which uses Views XML Backend to do some really nice things with the Drupal Planet RSS feed.. locally. I don't know yet how to reconcile these new tools with VBO, but here's the exchange I had with bojanz just a few min ago:
Comment #13
Anonymous (not verified) CreditAttribution: Anonymous commentedSince it has been a while since the last message...
What's the current status of VBO + Search API? I am using Search API (with SOLR) and I would like to use VBO to build a "backend" interface to manage nodes.
Any help/info/suggestions would be really appreciated.
Thanks!
Comment #14
rerooting CreditAttribution: rerooting commentedGood news!
http://drupal.org/sandbox/AlexArnaud/1910528
This sandbox project works using the above patch and some code I remember seeing suggested elsewhere.
The only problem was that it is node centric, in a very minor way.
This code here specifically:
For crm_core, I just tweaked it to:
Theres probably some ways that this sandbox project could be improved to implement a more entity type generic solution.
Also wanted to say, Views Rules looks really neat, but doesn't seem to do what I need to do with VBO and search_api index views in this case. I will suggest it to the crm_core folks as I am sure they are interested in finding ways of creating 'smart groups' which Views Rules and taxonomy would be excellent for!
Comment #15
David Hernández CreditAttribution: David Hernández commentedPatch from #11 didn't applied when using git command, breaking deploys with drush make. Here's a reroll that should work.
Comment #16
f5.andrii CreditAttribution: f5.andrii commentedChanged one line to force patch above work with OG VBO actions:
Comment #17
David Hernández CreditAttribution: David Hernández commentedThe last patch it's working fine for me. Marking it as RTBC.
Comment #18
pfournier CreditAttribution: pfournier commentedUpdated the patch for the latest dev release (7.x-3.1+31-dev).
Sorry for the two patches. The smallest one is the good one.
Comment #19
pfournier CreditAttribution: pfournier commentedComment #20
pfournier CreditAttribution: pfournier commentedSorry, patch 18 was incomplete and broken. Here is a working patch.
Comment #21
bojanz CreditAttribution: bojanz commented#2 is still valid.
I rewrote the views get_result_entities() function for D8 to support revisions, that needs to be backported to D7.
There is an issue at #1802438: get_result_entities() Doesn't support revisions.
Comment #22
pfournier CreditAttribution: pfournier commentedThis is identical to patch 20, but uses get_value() to retrieve the row entity id. Safer.
Comment #23
andrewbelcher CreditAttribution: andrewbelcher commentedUnfortunately this patch breaks processing of all pages. This is because:
views_handler_field_entity::get_value()
This handler works based off of
$view->row_index
rather than$values
passed into it. This seems like a strange thing for views to have done, but given that, the following code no longer works:Firstly,
$view->row_index
will need updating on each loop. Secondly,$vbo->view
is actually the original view which only has the first page of results, so once it gets passed there, the key in$this->entities
no longer exists.Also,
$vbo->get_value()
returns an entity, where as the selection expects an ID. The issues are similar in the queued selection.I have attached an update patch that takes this into account. This now works perfectly and enables Search API to be used as a back end with the patch from #1123454: Integration with views bulk operations (vbo).
Comment #24
andrewbelcher CreditAttribution: andrewbelcher commentedCorrection - the above patch means Search API doesn't need anything doing to it to work, which is great as previously it was having to implement a method that had no real meaning just to make VBO work.
Comment #25
andrewbelcher CreditAttribution: andrewbelcher commentedOk, looked at this in the light of some of the comments about revisions and have re-worked it to support revisions. I have also put a patch up to views (#1802438: get_result_entities() Doesn't support revisions #12) which brings revision support into
get_result_entities()
which we make use of here, so this patch is dependant on that one.Comment #26
dasjoi tried the patch with vbo 3.2. while i can configure the vbo field handler, it doesn't seem to execute for me.
what's also strange is, that the vbo field handler will disappear after adding another display to the view. at this point it seems to save the view, discard the missing vbo handlers. i can get those back registered by visiting the views overview page. unfortunately, then, the whole procedure just begins...
Comment #27
drunken monkeyAh, pity to hear. So this is "Needs work" again, then?
Anyways, thank you still a lot for your work on this, pfournier and andrewbelcher!
Comment #28
botrisI can confirm the patch from #25 to work with Search Api 7.x-1.11 & VBO 7.x-3.2
Comment #29
gilgabar CreditAttribution: gilgabar commentedI also had success with the patch in #25. I am now able to add a VBO field handler to a view of a Search API index of my custom entity type. I was unable to reproduce the issue reported in #26.
Comment #30
laszlo.csongor CreditAttribution: laszlo.csongor commentedI can confirm that patch from #25 is working with Search Api 7.x-1.13 & VBO 7.x-3.2, however there is an issue when using the patched VBO 7.x-3.2 together with Flag 7.x-3.5 (https://www.drupal.org/project/flag).
Any suggestions on how can I solve this?
Comment #31
valthebaldI think we should move this to RTBC, and maybe address issue from #30 in a separate issue (not sure if it will belong to VBO or to flag)
Comment #32
kiss.jozsef CreditAttribution: kiss.jozsef commentedI can confirm too that patch from #25 is working with Search Api 7.x-1.13 & VBO 7.x-3.2 but it breaks the Load a list of entity objects from a VBO View and Load a list of entity ids from a VBO View rules actions .
In views_bulk_operations_action_load_list() the foreach runs only once the entity_metadata_wrapper breaks it, and in the
$vbo->get_value($result) function the $this->view->row_index is empty.
Comment #33
damien_vancouver CreditAttribution: damien_vancouver commentedAnother confirmation that #25 works against VBO 7.x-3.2. After application and cache clearing I'm able to add a Bulk Operations field handler and everything is working as expected. I had no other problems, but am using only the "pass arguments to a page" handler.
In order to get it working I needed not only this patch but also the code from #35 at #1123454: Integration with views bulk operations (vbo) (also here: https://www.drupal.org/node/1591360)
Over on the Search_API queue, #1123454: Integration with views bulk operations (vbo) is waiting for this patch to be committed in order to move forward with their end of the problem (the code from #35 on that thread). We probably need a re-roll of #25 against current -dev.
Comment #34
andrewbelcher CreditAttribution: andrewbelcher at FreelyGive commentedNo re-roll required - still applies cleanly! Another +1 for getting this committed as it is working smoothly for me.
Comment #35
andrewbelcher CreditAttribution: andrewbelcher at FreelyGive commentedJust had a quick chat with @bojanz on IRC, remaining tasks are:
- Update the minimum version of views to 7.x-3.12 as that's where #1802438: get_result_entities() Doesn't support revisions landed.
- Write a test to demonstrate it's working and prevent regression.
Comment #36
andrewbelcher CreditAttribution: andrewbelcher at FreelyGive commentedAfter another chat with @bojanz on IRC, we decided in light of the fact that there is currently no test coverage at all, we wouldn't hold this up on automated tests. Given that I have:
1) Updated the patch to include the views version dependency.
2) Done manual testing with 500 nodes with both the node base table and a search api db index using the patch from #1123454-89: Integration with views bulk operations (vbo).
Have set to needs review for the version addition, but other than that it hasn't changed since it was RTBC...
Comment #37
bojanz CreditAttribution: bojanz at Centarro commentedI'll do a final test today.
Comment #38
alexverb CreditAttribution: alexverb as a volunteer commentedWorks for me also with the search API patch.
Comment #39
ArtusamakI confirm that the patch is working for me too. Thank you!
Comment #41
joelpittet#1123454: Integration with views bulk operations (vbo) is committed, and this one has been RTBC for some time, so I'm committing it. Thanks for testing this!
Comment #43
joelpittetConsidering reverting this as it seems to cause issue from some entities like ubercart. Not totally sure why yet so needs some investigation.
Comment #44
joelpittet#2856944: 'Please select at least one item' - after upgrading to 7.x-3.4
Comment #45
joelpittetThis looks like it needed a fix because of this patch too, FYI #2853029: views_bulk_operations_action_load_list not working