Problem/Motivation
After security update to prepopulate-7.x-2.1 'container' fields stopped working.
- node reference field using an autocomplete widget #1
- Drupal Commerce Price
Proposed resolution
- make containers fields work again without reverting the security issue
Remaining tasks
User interface changes
API changes
Data model changes
Hello,
So far I was using this code in the url to be able to prepopulate the field :
edit[field_myfield][und][0][value]=my_value
After upgrading to 2.1 this does not work anymore
Can you tell me if I need to change something?
Thank you :)
| Comment | File | Size | Author |
|---|---|---|---|
| #55 | prepopulate-2679839-55.patch | 2.27 KB | danielveza |
| #44 | prepopulate-container_elements_and_text_format-2679839-44.patch | 475 bytes | szeidler |
| #38 | container_elements_and-2679839-38.patch | 332 bytes | joelpittet |
| #36 | interdiff.txt | 1.58 KB | dylan donkersgoed |
| #36 | prepopulate-2679839-36.patch | 3.92 KB | dylan donkersgoed |
Comments
Comment #2
.bert commentedI'm having the same issue.
Looks like the `$limited_types` changed. In my case, I was using prepopulate on a node reference field using an autocomplete widget, although this would apply to an entity reference field as well.
Those fields have a `#type` of `container` and get excluded from processing right at the root of the array, rather than cycling through array items to get to the actual field.
Not sure if this is by design, can someone provide some insight there? Are all container types meant to be excluded, or do we need to find another way of walking through the array?
Comment #3
jbrauer commentedThis is a somewhat unfortunate side-effect of hardening the field types. It would be ideal that instead the module whitelist the fields that can use prepopulate. In the alternative in the meantime it's possible we can come up with a means of allowing some specific container cases.
Comment #4
wipeout_dude commentedSame issue here.. I mostly use prepopulate for entity reference fields but use it for various other fields as well none of which are working..
Is a roll back to the previous version the quickest fix for now to get things working again?
Comment #5
jbrauer commentedI do not recommend rolling back. Since the security advisory has been released it's now public how one could exploit the previous versions if they were determined to do so.
I hope to have a patch with an option posted today that will allow sites to override the type check for specific fields they want to allow being pre-populated. In the meantime if you urgently need to allow certain types of fields and are willing to accept the risk you can of course modify the blacklist in the module until other options exist.
Comment #6
whthat commentedSimilar issues, tweaking the blacklists did work for the time being.
Forms built using Entityforms is whats causing issues for me. The "container" type which is blacklisted wraps every field on Entityforms. I'm sure we can find a better way to exclude this one.
Comment #7
jbrauer commentedComment #8
elc commented$limited_types including the 'container' type broke every instance of use here. Pretty much every field there is comes in a container which has neutered the module's functionality.
For now I've commented this out as I already have extra code in place to indirectly give protection for this path. I'm guessing it'll need an update if there's a major change to how this module works.
Comment #9
shi99 commentedThanks for tip on commenting out "container" from the $limited_types.
I will use this for now.
Comment #10
cameron tod commentedConfirming that commenting out 'container' band-aids the issue.
Attached a temporary patch for users who find this issue and need a quick fix.
Comment #11
jbrauer commentedComment #12
jbrauer commentedmarked the patch as hidden so it's not found without reading the issue and understanding it is not a fix for the issue and is not a good general solution but something sites may consider in the short term.
Comment #13
jbrauer commentedComment #14
scuba_flyHave the same issue.
Module has become unusefull so I would suggest putting this to Major.
Will try and see if I can create a patch for this in a couple of days.
Also my previous patch does not work any more since the update:
https://www.drupal.org/node/1424774#comment-10821574
Comment #15
scuba_flyAdded a check that checks container children if they are in the allowed types.
Comment #16
elc commentedThis patch does not work for my instance - Entity Forms + Fields - as what is being searched for does not match. This should be the same on all Entity + Field situations. Have returned to commenting out 'container'.
As an example, this is my $_REQUEST['edit'] array that does not work with this patch.
And these are the relevant parts of their field defs.
Comment #17
scuba_flyNot a nice way, and the code is not really maintainable since it gets quite complex.
But what is the motivation behind setting text_format as limited type?
Comment #18
elc commentedI'm sorry, I don't know where you've picked up 'text_format' as key a key piece of the pie - none of my fields have anything to do with text_format.
I haven't read back further to see if I've missed a comment in this thread the uses it, but I can't find it in a text search of the page.
If this patch is to allow the single type of field of 'text_format' to be used in a container, it's a bit not useful for all of the other fields out there. I'd have thought something that steps into a container and did the same walk inside it would be the way to go, but I'm afraid I haven't scraped enough free time together to look into coding anything here.
Comment #19
nwom commented#17 sadly doesn't work for me when prepopulating a Relation Add field. The following error message is shown as well:
Edit: The #10 band-aid does not work for me either.
Edit 2: Reverting to 7.x-2.0 temporarily fixes the issue.
Comment #20
scuba_fly@ #18
text_format is in the array list in de code as limited values. Which is why text_format does not work as well as the container field. This is changed since the security update. I'm not sure why it has changed but it is the 'cause' of this issue.
Kind regards,
scuba_fly
Comment #21
MickL commentedModule not working anymore after security update. Rolling back is not an option. This issue is critical.
Comment #22
tommybyskovlund commentedMarked #2691065 as duplicate of this issue
Comment #23
thelocaltourist commentedApplied patch from #17 and received the same error message as #19. The field I was trying to prepopulate was a title field from the Title Field module.
Error msg:
Notice: Undefined index: #type in _prepopulate_request_walk() (line 80 of /sites/all/modules/prepopulate/prepopulate.module).Comment #24
robertgarrigos commentedThe url to populate an entity reference field has changed. Where it used to be
edit[name_of_field][und]=id_valuenow it works asname_of_field=id_valueComment #25
dpico commentedThanks Robert! What's the syntax when the referred field is multivalued? I'm trying name_of_field[0]=id_value but it doesn't work.
Comment #26
robertgarrigos commentedSorry, dpico. I could only find out this one. term reference field is not working either.
Comment #27
dpico commentedThanks Robert! Let's see if someone can say something about this.
By the way, if this is a critical bug for version 2.1 and it's still not solved, shouldn't that version NOT be offered as the standard download version in the project's webpage? This is the version that everyone is downloading right now.
Comment #28
robertgarrigos commenteddpico, you can use hidden patch at #11 to solve this for now. It is not a fix, yet.
Comment #29
nwom commentedSadly 2.1 should be offered, since it fixed an exploit. Luckily, in my case the project is an intranet site, where anyone outside of the network will not have access to the site.
Comment #30
dpico commentedThat's my case as well. Do you think if will be safe to revert to a previous version? I'm afraid the database would be corrupted or that something disastrous like that can happen if I revert. If I do, is it enough to install 2.0 and execute update.php?
Comment #31
nwom commentedDowngrading isn't a problem, since an update.php wasn't necessary when updating from 2.0 to 2.1 (no tables were changed).
Just for future reference though, if a database update is ever required then a downgrade is not possible with any module. In those cases, an uninstall of the updated module is required, and then a re-install of the downgraded version.
Luckily the prepopulate module doesn't have any settings, so uninstalling and re-installing the older version is an option as well, without needing to configure anything.
With any module change, you should however always clear all cache (via Performance), and run a database cron.
Comment #32
nwom commentedFor those that use Prepopulate on only Entity Reference fields, you can instead use Entity Reference Prepopulate Token module in combination with the dev version of the Entity Reference Prepopulate module.
Using those two modules, you have the choice to use either tokens, panels substitutions, URL query parameters, or Organic Group Contexts. In addition to this, you can specify whether the field should be hidden or disabled when prepopulated. Also, you can specify that the field should only be shown when prepopulated. Lastly, you can configure it to redirect to a page if the prepopulate value is not available.
The Entity Reference Prepopulate module works when creating nodes and also optionally when editing nodes. However, the Entity Reference Prepopulate Token module only works when creating nodes for now. I however created a feature request issue for edit support as well: #2723867: Apply action on edit
Comment #33
clemens.tolboomWhy is this not deleted
What is the meaning of this? I guess to check for the language variant. I do get
on it.
I want to propose another patch based on #17 but written differently which has probing/debug for user-1. We can remove those if needed. That still needs the fix mentioned above.
And it does not fix setting a 'container' integer field.
Comment #34
clemens.tolboomMy field is failing on
is not numeric but a Drupal Commerce Price field. So which fields will break.
Comment #35
clemens.tolboomAnother rewrite could be something like
which gives some debugging options why it is not working as expected.
Comment #36
dylan donkersgoed commentedThe patch from comment #33 works for me but generates a warning because a certain value isn't checked before it's used. I've attached another patch to fix this. This may be part of a larger issue (though it's not causing me any problems), see clemens.tolboom's comment.
Comment #37
schifazl commentedPatch #36 works well for my use case (prepopulating date fields). Thanks!
Comment #38
joelpittetI had luck with just removing 'container', i'm not sure which scenario uses text_format as a type, maybe that's a separate issue?
Try this patch
Comment #39
nwom commented@joelpittet: Thanks, but this temporary fix was also suggested as shown in #10. It is only a quick fix supposedly, but isn't a permanent solution to the problem. Sadly, it also only works for some people, in my case my Relation Add fields did not work.
It would appear that #36 is the closest to the real solution so far.
Comment #40
joelpittetThe logging doesn't need to be added in #36, a debugger should be able to get you through this better with much more context variables for the problem. That patch assumes devel module is installed.
I kind of know what it was doing before, but the patch in #36 (and before) is kind of confusing to follow what it's doing. That could likely be just me though...
Comment #41
jphelan commented#36 is working for me
Comment #42
crutch commented#10 (#38) worked for us. It will be necessary to apply this to live sites temporarily until better fix. Thanks!
Comment #43
charginghawk commentedRe: various comments here about text_format, I ran into a similar issue (using the Drupal Commons distro, not sure if it's reproducible using Drupal core). My body field, for some reason, had type text_format. I noticed, however, that it also had a #base_type element that passed muster. So, I propose this edit:
Comment #44
szeidler commentedI needed to extend to patch, to also remove the
text_formatproperty from the limited types. The reason is, that textfields using the "Text processing = Filtered text" in the field configuration, injects the #type = text_format into the field instance.Comment #45
suncorjohn commentedCould someone help me install the patch referenced in comment #36?
I've never installed a patch before.
The issue I'm having is trying to pre-populate a field in a dropdown.
Are there any detailed instructions on how to install the patch, what module files need to be edited and where in the file or is the whole file just updated?
Regards,
John
Comment #46
jphelan commentedYou'll find instructions here: https://www.drupal.org/patch/apply
Comment #47
crutch commentedsuncorjohn,
The patch itself from #38 looks like this.
To manually do this, you would go to the module directory "prepopulate" then to the file "prepopulate.module", then go to about line 56 and look for the first part which is "$limited_types = array (".
A minus sign in front of a line is a removal. A plus sign in front of a line is an addition. In this case you simply just remove the line
'container',Save the file. Flush all caches. Try it out.
Keep in mind this is just a temporary fix.
Of course #36 would be more tedious to do manually but can be done manually.
Comment #48
suncorjohn commentedThanks crutch,
Removed the 'container' line in the file "prepopulate.module" per your instructions.
Still having issues pre-populating field in dropdown select list.
The field key is product_name. The fields in the webform are:
product_1|Product 1
product_2|Product 2
product_3|Product 3
Tried the following links, which did not work:
Do I need to select a default value?
Here is a link to the test page: http://www.atlantisrail.com/test-pre-fill
Any assistance would be appreciated.
Regards,
John
Comment #49
crutch commentedTry this tutorial it may help. http://drupalwoo.com/content/blog/webform-passing-info-through-url
Work with the "default value" of the webform field itself and make sure token module is installed.
Note the comments regarding webform 7.x-3 vs 7.x-4
Comment #50
suncorjohn commentedcrutch,
Went through the tutorial, noted comments regarding webform 7.x-4. As I mentioned, it works for text field but does not work for dropdown select options. When I set the default value and save the form, the default value is not set?
I set the default value for the select options dropdown to:[current-page:query:product_name].
My link URL is set to:
<a href="/webform-pre-fill-test?product_name=[product_2]" target="_self">LINK PRE-FILL DROPDOWN</a>Comment #51
suncorjohn commentedI give up, this just does not work, thanks anyway everyone.
Comment #52
madt#36 worked for me.
Comment #53
firfin commentedShame that a security fix is causing this much problems and that it seems to be so difficult to get around this.
Maybe this is a silly thought, but might it not be a better options to revert the security update and find another solution for that problem?
Just my two cents. Shame to see this module in this state though, useless with entityform at least.
Comment #54
daniel-san commentedPatch #36 successful on Drupal 7.52, Prepopulate 7.x-2.1
Comment #55
danielvezaUpdated patch from #36 that just removes all the logging, because I don't want that.
Comment #56
giupenni commentedPatch #36 successful on Drupal 7.52, Prepopulate 7.x-2.1
But I don't understand: why this module is out if it not works?
If this patch works why it is not been yet committed?
Comment #57
scuba_flyLooks like #36 is RTBC
But #55 is a far more maintainable code. Can we get reviews on #55?
Comment #58
giupenni commentedOk, I've tested also #55 and seems work perfectly.
Comment #59
aboros commentedI've just run into this issue with entityreference autocomplete and the patch in #55 worked perfectly. The patch applied without issues and prepopulating the field works as expected.
Comment #60
Sinan Erdem commented#55 works for me. Thanks!
Comment #61
siramsay commentedjust tested #55 and can confirm it working
had been using #10 to solve this as a temporary measure but now with proper solution no need.
Comment #62
schifazl commentedI too confirm that patch #55 works!
Comment #63
giupenni commentedI've tested the patch in another project and seems work perfectly
Comment #64
Daniel Schaefer commented#55 is working. We should release it, the 7.1 version marked as stable does not work! In case anyone still has doubts, try it out on simplytest.me.
Comment #65
gumanov commented+1 for patch #55.
Works great, Thanks!
Comment #66
airb commented#55 works good. thanks!
Comment #67
plato1123 commented#55 works, hurray! Can we get it rolled into a release?
Comment #68
bobsu commented+1 for patch #55.
It's working.
Comment #69
madjr commentedcould the patch be at least included in the Dev Version?
Dev version at simplytest.me
https://simplytest.me/project/prepopulate/7.x-2.x
doesn't seem to work either...
Comment #70
kingandyPatch in #55 works for me too.
Comment #71
dave kopecekPatch #55 works for me.
Comment #72
jbrauer commentedMerged thanks.
Comment #75
WildSonic commentedI am feeling this module is totally broken while using it...
Seems like that many value handlers of the arrays and the form formats are changed in the newest drupal core.
I've followed all the introductions from the module handbook page,
but end up finding out only the value of title and options(publishing status etc.)can be passed through the url ,
except for these two fields, I've tried all the suggestions about Taxonomy and CCK fields but sadlly nothing just happends at all!
Agree with #56
why this module is out if it not works?
If this patch works why it is not been yet committed?
Spending all my afternoon working on this issue.
Sincerely hope the author could write some tips about the " verision broken issue" to whomever wants to try this module.Especially the new ones for drupal.Wish others don't have to spend their all day on it ...
Comment #76
danielvezaHi Wildsonic, looks like this patch has been committed to the latest dev version. Maybe check that you're using the up to date dev version of this module?
Comment #77
tanasi commentedThe patch works for me too. Too bad the stable version doesn't work. Spend half a day searching for the reason. I still think it's misleading to have 2.1 as green..
Comment #78
WildSonic commentedGave up on this module since last time's failure,tested the dev-version today, works fine for taxonomy ,thanks !
Comment #79
jamesfk commented+1 for pushing the dev to a new release.
I ran into this problem trying to prepopulate a Profile2 field on a Profile2 Registration Path and after a few hours of head-scratching and then debugging the prepopulate managed to find the container line that was causing the problem, and I'm happy to say the dev version fixed it without introducing security issues.