Hi,
We plan on doing an upgrade of our (very basic drupal) website from d6 to d7. We use this module and also freelinking prepopulate is enabled on our website.
There are no issues we struggled with in the d6 version, but after we did an upgrade (and also an upgrade of the freelinking module) to d7, I found 2 small bugs (wich I solved) in the prepopulate module and I like to share them with you, so it can be fixed in one of the next versions. I would make a patch, if I knew how :-), so I am just gonna say what's wrong and also post my solution.
Like I said, our installation is very basic (d7 7.23), but the following modules have to be enabled to recreate the issue:
* Freelinking
* Freelinking Prepopulate
* Taxonomy and/or Book module (one of these two is enough in fact, but in my case it's both)
Now, in the freelinking settings page (admin/config/content/freelinking), you can find a fieldset "CREATENODE PLUGIN SETTINGS", the problem is right there ... look at the attachment to have a clear view on the issue, it's quite obvious what the problem is I guess?
The problem occurs in two files: "modules/freelinking_prepopulate/freelinking_prepopulate.module" & "modules/freelinking_prepopulate/freelinking_prepopulate.utilities.inc"
In D6 we have following code in ...
"freelinking_prepopulate.module", starting on line 99
foreach (freelinking_prepopulate_list_fields('nodecreate') as $key => $value) {
$options[$key] = $value['title'];
}
"freelinking_prepopulate.utilities.inc", starting on line 180
return array_intersect_key($fields, $plugins[$plugin]);
After the migration to D7, the code is a bit refactored so we have the following code in ...
"freelinking_prepopulate.module", starting on line 107
$nodecreate[] = freelinking_prepopulate_list_fields('nodecreate');
if (isset($nodecreate)) {
foreach ($nodecreate as $key => $value) {
$options[$key] = $value['title'];
}
}
"freelinking_prepopulate.utilities.inc", starting on line 193
if (is_array($fields && $plugins[$plugin])) {
return array_intersect_key($fields, $plugins[$plugin]);
}
The first problem is in "freelinking_prepopulate.utilities.inc", in the "if" statement, the is_array function is used, but it can only be used in for one array at a time, not two or more, and definitely how it's used in this case (boolean expression ...), we fix this by changing it to:
if (is_array($fields) && is_array($plugins[$plugin])) {
return array_intersect_key($fields, $plugins[$plugin]);
}
The second problem is in the file "freelinking_prepopulate.module". The return value of the function "freelinking_prepopulate_list_fields" is already an array and we're putting it in another array, hence the "$nodecreate[]", but we just want to put the return array in this variable, not in another array ... so it can be fixed by changing in to:
$nodecreate = freelinking_prepopulate_list_fields('nodecreate');
if (isset($nodecreate)) {
foreach ($nodecreate as $key => $value) {
$options[$key] = $value['title'];
}
}
In my opinion this is a clean solution for this two small bugs. I hope you agree with my solution and maybe fix the issue is one of the following releases.
Kind regards,
Maarten
| Comment | File | Size | Author |
|---|---|---|---|
| freelinking_prepopulate_bug.png | 29.04 KB | ploviem86 |
Comments
Comment #2
gisleThe problem described above, which manifests itself in various way including an "illegal choice" message from Freelinking Prepopulate on Freelinking Settings form is fixed in the last dev snapshot of the 7.x-3.x branch.
If the node is part of a Book, then Freelinking Prepopulate works.
It should be noted that prepopulating with a taxonomy term does not work in Drupal 7.
Basically, it looks as if taxonomy_node_get_terms() didn't make it into Drupal 7, and while there has been attempts to provide a replacement, e.g.: https://www.drupal.org/node/909968#comment-7798269 none of them seem to work will all types of taxonomy terms.
Rather than groping around in the database for these terms, I've removed the ability to prepopulate with a taxonomy term in the 7.x-3.x branch.
I haven't tested the prepopulate with OG yet.
Comment #4
gisleThis should be fixed in version 7.x-3.4.
Please see the release notes.
Comment #5
gisleUpdating status.
Comment #6
gisleAccording to #1504124: Support OG contexts in freelinking_prepopulate, there is a similar problem with prepopulate and OG.
Comment #8
gisleCorrected status.