Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Provide support for the default taxonomy form. This is a challenge, because it's difficult to know how fieldAPI interacts with the node form.
Comment | File | Size | Author |
---|---|---|---|
#52 | 1187424-taxonomy-form.patch | 29.54 KB | agentrickard |
#51 | 1187424-taxonomy-form.patch | 29.69 KB | agentrickard |
#40 | 1187424-taxonomy-form.patch | 29.1 KB | agentrickard |
#36 | Notices on the Workbench Access configuration screen | 34.02 KB | agentrickard |
#36 | Configuration per field instance | 20.94 KB | agentrickard |
Comments
Comment #1
agentrickardFor reference, here's a first stab at this, which shows just how difficult this is going to be.
Comment #2
aaronpinero CreditAttribution: aaronpinero commentedBy "default taxonomy form" are you referring to a default taxonomy field? My issue with this module is that, while it's very easy to set up and use, it appears to ignore the taxonomy terms assigned to each node. Instead, it creates the new node edit form element where you select the editorial section. Not only is this limiting (since you can currently only select one editorial section) but it means that all the content on the site which already has associated taxonomy terms must be edited to match the selected editorial section with the assigned terms.
Comment #3
agentrickardCorrect. Blame FieldAPI for this.
Comment #4
agentrickardIt might be easier -- and even preferable -- to simply declare a widget formatter for taxonomy terms that uses Workbench Access.
That approach would use hook_field_widget_info() to declare Workbench Access as the widget handler.
Comment #5
agentrickardWe discussed on scrum today that using FieldAPI is not appropriate for various reasons.
Comment #6
agentrickardHere's a patch that gets pretty close. Could use a good code review.
Comment #7
agentrickardUgh. The fact that taxonomy fields are version/revision sensitive makes this all that much harder.
Comment #8
agentrickardThe problem with field revisions makes this very, very nasty.
Perhaps we _should_ be taking over the field element and forcing stateless term assignment?
Needs real-world testing to decide.
Comment #9
Nick Lewis CreditAttribution: Nick Lewis commentedTesting this patch. Noticed that debug code is added in several places.
Comment #10
agentrickardHooray!. Please remove and repost.
Comment #11
philipz CreditAttribution: philipz commentedsubscribing
Comment #12
wheadley CreditAttribution: wheadley commentedsubscribing
Comment #13
duellj CreditAttribution: duellj commentedUpdated patch to remove debugging code. My use case is default menu integration, so I'll be testing this against #1101638: Default menu form support
Comment #14
duellj CreditAttribution: duellj commentedAnd the actual patch :)
Comment #15
agentrickardAnd with menus, the "stateless" data issue doesn't exist.
Comment #16
agentrickardI wonder if https://drupal.org/project/taxonomy_entity_index will help here?
Comment #17
jerrac CreditAttribution: jerrac commentedI was referred to this issue by #1276792: Enable Hierarchical Select when multiple section assignments are allowed. But, reading through this, I'm not sure what it's really about. Something about how fields and taxonomy works...
Anyway, I can apply the patch from #14, but how should I test it? What is it supposed to do? What kind of tests would help you?
Comment #18
agentrickardIt should allow you to use a native Taxonomy Field to control access to a node -- without this patch, Workbench Access generates its own form element.
Comment #19
Rade CreditAttribution: Rade commentedSubscribe
Comment #20
philipz CreditAttribution: philipz commentedPatch #14 works for me but I needed to make a modification.
First it's not so obvious perhaps how to set it up. You need to go to admin/config/workbench/access/settings and uncheck "Require a Workbench Access form element". The second step is to add a taxonomy term reference field (to the vocabulary you're using for Workbench Access) to your content types. This forces Workbench Access to use (and filter) the taxonomy term field and not add its own.
The problem I had was with the language code in workbench_access.module file. After saving the term was assigned but error was displayed:
and no section was attached. My node language ['pl'] was different from term field language ['und'].
I changed this line:
$data = $node->{$field}[$node->language];
to
and all works fine.
Thanks duellj ! I didn't try your patch until now because I was trying to write my custom module to do the same thing but it was too specific :)
Comment #21
agentrickardSo the patch needs a re-roll.
Honestly, we haven't been dealing with multi-language sites yet, so this kind of testing is priceless.
Thanks!
Comment #22
amateescu CreditAttribution: amateescu commentedRe-rolled the patch from #14 with the changes suggested by @philipz in #20.
Tested with the default taxonomy widget and with Hierarchical Select 7.x-2.x-alpha5 in a multilanguage site and everything works great!
Comment #24
amateescu CreditAttribution: amateescu commentedFixed those exceptions.
Comment #25
agentrickardExcellent work.
Still needs some independent review, especially around revisioned data.
Comment #26
thekevinday CreditAttribution: thekevinday commentedThis re-breaks the issue defined here: https://drupal.org/node/1256692
#20 explains how to use a taxonomy field.
If "Require a Workbench Access form element" is still checked, then the workbench section will not appear under a vertical tab.
If "Require a Workbench Access form element" is unchecked, then this patch functions as expected.
Comment #27
itaine CreditAttribution: itaine commented#24 works like a charm!
Found 1 problem though... those without permission are able to edit the access form. I've attached a pic to better explain.
The one on top is the default workbench access form and the one below it is the term reference field. Further testing raises the question, how do you control who can change/view the access group(s)? Or am I missing something?
Update: Is it suppose to be the following permission that controls who can see the form or not? If so, not working.
View Workbench Access information
Comment #28
agentrickardIf using the default form, WA currently doesn't enforce access control to the form.
Note that http://drupal.org/project/field_property was created to help address the issues raised in point #8.
Issues to work out:
* How to ensure the form element exists?
* Should we force Field Property module to be installed?
* How to handle autocomplete field widgets?
Comment #29
Taxoman CreditAttribution: Taxoman commentedWould it create update headaches if the "current"/next release temporarily relied on Field_property module?
If not, that could serve just to get such a feature "in", so that there will be more time to work out just how this could/should be handled internally without such dependency.
Comment #30
pozdneev CreditAttribution: pozdneev commentedWhen saving the node after editing, the patch from #24 does not respect permissions that already exist.
Say, you have a "Node" associated with "Term1" and "Term2".
The "Editor" is associated only with "Term1".
(See attachment.)
So, when the "Editor" changes the "Node", he/she is allowed to (re)associate the "Node" only with "Term1".
Thus, as soon as the changes are saved by the "Editor", the "Node" loses its' association with the "Term2".
Any ideas how to avoid this?
Comment #31
Taxoman CreditAttribution: Taxoman commentedthere should be an automatic check for that on node save:
- nobody should be allowed to remove terms they are not permitted to use
Comment #32
agentrickardThe patch should already account for that:
$form['workbench_access']['workbench_access_fixed']
elements should be accounted for during node save.And yes, I think we may require Field Property, though I don't know how we would inform the user to install it, since #1195590: Is taxonomy really required? removes the dependency on Taxonomy module.
Comment #33
coderintherye CreditAttribution: coderintherye commentedPerhaps I'm missing something, but what's the problem with (pseudo-code):
?
Comment #34
agentrickard@nowarninglabel
That discussion is happening in the other issue. The plan is to use hook_requirements() to set those messages.
Comment #35
agentrickardAnd I found a decent solution to the problem.
This is mostly done (?) pending proper testing. Take a look!
TODO:
* Handle autocomplete fields (nasty bit of logic there, including overriding the menu callback or the query, which has a 'term_access' tag on it) or remove support for them.
* Write tests.
Comment #36
agentrickardScreen shots of the configuration UI.
Comment #37
coderintherye CreditAttribution: coderintherye commentedLooks like the right direction, but that's a lot of code to review, will look at applying it into our dev environment on Monday. Meanwhile, I can at least say that the patch applies cleanly to a dev checkout and doesn't appear to have broken anything.
Personaly, I would push towards removing the autocomplete fields, as I can't see it adding enough value to be worth the trouble, but that's just my two cents.
Comment #38
agentrickardI don't really expect a line-by-line code review.
I think the code itself can be run through Coder and have tests for functionality. I think the big deal is that it applies cleanly and works as expected.
I'm tempted to drop autocomplete support, but in some cases, it's very important (e.g. if you have 100+ terms). And if it is easy to support, then we should.
I suspect that a query_alter() that only fires on path autocomplete/taxonomy may actually do the trick.
Comment #39
Taxoman CreditAttribution: Taxoman commentedMany sites have lots of taxonomy terms where the lack of autocomplete support would come close to a showstopper. It is not uncommon to have 200+ terms in a vocabulary.
Comment #40
agentrickardUpdated patch with autocomplete handling working. Had to do some handstands, but it does work.
Questions:
Comment #41
coderintherye CreditAttribution: coderintherye commentedI'd vote for following a permission model, perhaps similar to how http://drupal.org/project/active_tags active tags does it.
Comment #42
agentrickardThat will put even more burden on site admins to configure the module correctly, but is probably the only "real" solution.
Comment #43
Taxoman CreditAttribution: Taxoman commentedI wouldnt worry about that kind of burden on admin shoulders, as long as it comes with logical gui and configuration options - which is important to get right, and, of course - a real challenge.
Comment #44
Taxoman CreditAttribution: Taxoman commentedThe screenshots in #36 looks promising;
- what would the brief description/guideline text below each of the "News access control field" and "Basic access control field" be?
Comment #45
agentrickardDoes it need one?
Comment #46
robeano CreditAttribution: robeano commentedRequesting another review by @stevector. Assigning. Other issues are relying on the completion of this one. Raising priority to major.
Comment #47
stevectorI got this error when saving a node. I have Workbench Moderation also enabled. I'm not sure if that is a factor. The problem seems to be that
$node->language is set to "en" and my taxonomy field is keyed on "und." Can someone with more experience on Drupal's language handling chime in with how that should be straightened out?
Comment #48
stevectorComment #49
agentrickardInteresting. Are you using language handling at all?
Comment #50
duellj CreditAttribution: duellj commentedWhen applying the patch in #40, I get the following when viewing a taxonomy page:
It's odd, because the menu item is supposed to be cached the first time, so it shouldn't be running taxonomy_term_load each time (triggering the infinite loop).
Comment #51
agentrickard@duellj
Now that's pretty odd. For some reason, calling menu_get_item() on a taxonomy page causes infinite recursion. So we have to simulate that function.
Comment #52
agentrickardRemoved outdated docblock.
Comment #53
ronny89 CreditAttribution: ronny89 commentedi tried to apply the patch without success (the applying itself actually worked).
(plenty error messages)in both cases calling /admin/config/workbench/access/settings eventually showed up nothing but a blank window.
Comment #54
agentrickard@ronny89
I don't think that error has anything to do with this patch. Workbench Access never calls
drupal_load()
. Please make sure you are patching against the 7.x-1.x-dev branch.The rest of those errors look like a cascading failure from the first, which I cannot replicate.
Comment #55
ronny89 CreditAttribution: ronny89 commentedsorry, you are right, i patched the 7.x-1.0 release.
so, i installed the current 7.x-1.x-dev.
after patching this, there are no more error messages, but still the settings screen doesn't show up.
Comment #56
agentrickardThat still doesn't really tell me anything.
Comment #57
ronny89 CreditAttribution: ronny89 commented1. as mentioned above the admin/config/workbench/access/settings-page. the three others do work and show expected behaviour.
2. in admin/reports/dblog nothing is reported. i do not have access to logs on the server, but i could ask for it.
3. yes, it was / still is configured. just as i had done an upgrade.
4. yes.
5. nothing unusual.
Comment #58
agentrickardIt may have something to do with the reading of the Fields. Do you have Field UI enabled?
Comment #59
ronny89 CreditAttribution: ronny89 commentedyes, it's enabled too.
may i provide more detailed debugging information in any form?
btw, i also checked the "source view" of the client browser. it's purely blank.
Comment #60
agentrickardYou need to look in the server logs (or Drupal's watchdog) and report the actual error. It's obviously fatal. The obvious choice is out of memory, which you can fix easily.
Comment #61
Dave ReidMarked #1341654: Make worflow_access field configurable (via term-reference?) as a duplicate of this issue.
Comment #62
Sheldon Rampton CreditAttribution: Sheldon Rampton commented@agentrickard
The patch at #52 seems to be working fine for me.
Comment #63
agentrickardThanks. I think the only thing missing is the "do we add a new item on autocomplete" behavior.
Comment #64
Taxoman CreditAttribution: Taxoman commentedSurely there must be a permission to check for regarding the autocomplete?
What is the effect of doing nothing about that part; - just let the user try to save the form with several new terms, and then get an error that prevents saving the form?
As long as 1) that message is understandable for novice users, and 2) the terms entered are not lost, but retained so it is possible to edit/correct and copy/cut the terms that are preventing the save, then perhaps it is ok to do nothing.
- hmmm, can they be visually emphasized (identified), or controlled against the dropdown after the error occurs? If having entered 10-15 tags, and number 3,7 and 12 are new, how to identify them conveniently?
Edit:
- this makes me wonder if the Active_tags module (or one of its competitors) could come in handy here: would it be possible through such a widget to make sure that the new tags were emphasized somehow?
- notice: #1257268: Active Tags does not remember tags on form submit if form doesn't validate
- and this will have to go in too first: #1229538: Please add a js fallback
- http://drupal.org/project/active_tags
- http://drupal.org/project/autocomplete_deluxe
Comment #65
offerman CreditAttribution: offerman commented#59: experienced the same problem here.
No messages in the PHP logs.
Drupal logs stated: "Warning: require_once(.../drupal-7.9/sites/all/modules/workbench_access/workbench_access.admin.inc) [function.require-once]: failed to open stream: Permission denied in menu_execute_active_handler() (line 501 of .../drupal-7.9/includes/menu.inc)."
Solved it by flushing the cache.
Comment #66
agentrickardI would expect that taxonomy_autocomplete_validate would check for a permission to create new terms, but it does not.
This actually feels like a core bug to me. And there is an issue for it #1078878: Autocomplete term widget: disable creation of new terms.
Apparently, http://drupal.org/project/content_taxonomy can also handle this issue, but I really hate those kinds of dependencies.
ATM, my opinion is that we should commit the patch and then deal with the fallout.
Anyone second that? If so, mark "RTBC".
Comment #67
Sheldon Rampton CreditAttribution: Sheldon Rampton commentedI second that.
Comment #68
Dave ReidConfirmed this is working as expected. I might have a follow-up or two for a couple cleanups for code, but let's get this in.
Comment #69
agentrickardPatch no longer applies cleanly to head. Dammit.
Comment #70
agentrickardI had committed a very minor fix that blocked the patch. Corrected.
Comment #71
agentrickardI am very concerned that this only works for form-based data entry. Opening a new issue. #1360734: Confirm default forms work programatically
Comment #73
ronny89 CreditAttribution: ronny89 commented@65 hm, neither have still any message nor does flushing help.
btw, i turned off as many modules as possible, but still don't get that settings-page.
Comment #74
rosborn CreditAttribution: rosborn commentedLooks as if there was a lot of work devoted to this issue (many thanks) and I know this is now labelled as fixed, but there hasn't been an official update of this module since August, 2011. Will there be one soon, or will I have to install the dev version to get this to work?