Closed (fixed)
Project:
Feeds
Version:
6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
4 Nov 2009 at 18:09 UTC
Updated:
3 Nov 2015 at 05:08 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
alex_b commentedPort the *link mapper of course.
Comment #2
alex_b commentedAs an example for the API, take a look at mappers/content.inc should be used. For documenting the Mapping API, I opened an issue #623466: Document mapping API.
Comment #3
pbuyle commentedI need this for my project so I started working on it.
I need to write some tests and create a patch file but here what i have at the moment
I don't know if using hash in the targets for subfields is the right way of doing it but it works.
Comment #4
pbuyle commentedHere is a patch file against HEAD with the mapper in #3 and its test case.
Comment #5
alex_b commentedContains tabs as indents...
Comment #6
pbuyle commentedSorry for the tabs, here is a fixed patch.
Comment #7
Renee S commentedThe patch in #6 worked beautifully for me.
Comment #8
mylos commentedYes also for me #6 is working ok. I import some CSV data with affiliate link and used this patch to map it to CCK link field.
You can see example here:
http://www.pine-chest-of-drawers.com/
Comment #9
fabsor commentedI just want to confirm that this patch worked flawlessly for me to!
Comment #10
Anonymous (not verified) commentedWorking for me too.
Comment #11
alex_b commented- Did some minor cleanup
- Tests throw 2 exceptions in the same place (getFormFieldsValues())
- getFormFieldsNames() and getFormFieldsValues() are missing comments
- I am not 100 % sure what the extended logic in link_feeds_set_target() is doing - mongolito404, could you comment that?
- Changed delimiters from # to : as this is the route we started taking with taxonomy mapper.
Comment #12
rjbrown99 commentedI tested the patch from #11 with a CSV import feed with 3 different URL sources/targets. All of them worked for me. Just wanted to provide some feedback.
Comment #13
summit commentedSubscribing, greetings, Martijn
Comment #14
pbuyle commentedIn link_feeds_set_target()
- $defaults is used to store the default title and attributes for the field
- Entries in $defaults are indexed by node type and field name (
$defaults[$node->type][$field_name])- For each value, the defaults are assigned to the field if not already set
- Each URL value is cleaned and validated by
(($v = link_cleanup_url($v)) && valid_url($v, true))- Title values are not validated and directly assigned to the field
Comment #15
tallsimon commentedsubscribing with interest, this makes me consider switching for next version of my site
Comment #16
asb commentedHi,
the patch from #11 applies cleanly against feeds 6.x-1.0-alpha9.
However (I'm not sure if I am in the right issue queue), I was expecting to become able to map an item from a feed (= "source") to a CCK 'link' field (= "target") at "Mapping for Node processor"; that still doesn't work.
I'm absolutely new to this module and simply want to put the "item URL" from an RSS feed into a CCK field - forgive me if I got something wrong...
Greetings, -asb
Comment #17
BenK commentedSubscribing and will test....
Comment #18
rjbrown99 commentedAlex how are we feeling about this in terms of committing it? It has been working well for me now for over a month.
Comment #19
alex_b commented#18: if I remember correctly, there are 2 exceptions when testing (#11).
After mongolito404's response in #14 this is the only reason why this issue is still NW.
Comment #20
Anonymous (not verified) commentedI just tested the patch in #11 and I get no test failures or exceptions. "Mapper: Link 123 passes, 0 fails, and 0 exceptions"
Comment #21
mchelensubscribing
Comment #22
dale42I've applied the patch in comment #11 (623444-11_mapper_link.patch) to the 6.x-2.x Feeds branch. SimpleTest reports no fails or exceptions and I'm happy with the mapping results from the iCal parser module (parser_ical).
Comment #23
eaton commentedAnother happy customer here. Just tested it against alpha11 and it's working well.
Comment #24
eaton commentedActually I took this for a spin and noticed that it works fine with purely textual fields but chokes if an enclosure is mapped to the link field. Adding this chunk:
inside of the main link_feeds_set_target() loop gets everything working nicely -- and allows me to create linkfields that point to the enclosures from a feed item. I can roll a patch, but wanted to do a quick sanity check with others more familiar with the system: is that solution the right approach, or a mistake?
Comment #25
alex_b commented#24: I'm actually surprised that this is necessary. FeedsEnclosure extends FeedsElement and FeedsElement implements a __toString() method - doesn't the conversion happen automatically or is an explicit conversion required?
Generally speaking, the third parameter in the mapping callback ($value) can be either a single value or an array. The value itself (or the values in the array) can be either of a simple type or an instance of FeedsElement.
Comment #26
eaton commentedI was a bit confused by it as well: both of those test lines print out the same 'test' string. But when the FeedsEnclosure object is passed into Link module and Drupal's helper functions (link_cleanup_url() and valid_url() specifically) things seem to get unhappy. link_cleanup_url() for example tries to call trim() on the FeedsEnclosure object directly, resulting in an empty string.
With the explicit conversion, everything works fine.
Comment #27
pvhee commentedAdded suggestion of #24 to patch of #11. Ran tests and all works fine. Ready to be committed?
Comment #28
rjbrown99 commentedI have been using this since December and have not found any problems or issues with it.
Comment #29
webwriter commentedWorking for me- thanks!
Comment #30
kars-t commentedThe patch works nicely and I am currently using it. But there are some problems with the coding standards and some thoughts about the test:
If you run coder there will be a lot of messages.
feeds_mapper_link.test
Line -1: @file block missing (Drupal Docs)
severity: normalLine 25: Use an indent of 2 spaces, with no tabs
'devel', 'feeds', 'feeds_ui', 'ctools', 'content', 'link'
severity: normalLine 35: Use an indent of 2 spaces, with no tabs
'access devel information',
severity: normalLine 143: Control statements should have one space between the control keyword and opening parenthesis
if(in_array($field_name, array('alpha', 'beta', 'gamma', 'omega'))) {
severity: normalLine 145: Control statements should have one space between the control keyword and opening parenthesis
if(in_array($field_name, array('alpha', 'gamma'))) {
severity: normalLine 157: Control statements should have one space between the control keyword and opening parenthesis
if(in_array($field_name, array('alpha', 'beta', 'gamma', 'omega'))) {
severity: normalLine 158: Control statements should have one space between the control keyword and opening parenthesis
if(!is_array($value)) $value = array('url' => $value);
severity: normalLine 160: Control statements should have one space between the control keyword and opening parenthesis
if(in_array($field_name, array('alpha', 'gamma'))) {
link.inc
severity: normalLine 30: string concatenation should be formatted with a space separating the operators (dot .) and non-quote terms
'name' => $name .' (' . t('title').')',
severity: normalLine 64: Use an indent of 2 spaces, with no tabs
$value = array($value);
severity: normalLine 75: Use uppercase for PHP constants, e.g. NULL, TRUE, FALSE
if ($sub_field != 'url' || (($v = link_cleanup_url($v)) && valid_url($v, true))) {
Dreditor
There is a tab.
Space after line end.
Tab again.
Another tab.
Arrays should have a "," after their last item as well. This happens several times.
Powered by Dreditor.
And about the test. You use
+ // Edit the imported node.
+ $this->drupalGet('node/2/edit');
which expects the existens of node id 2. Imho it would be better to select the nid by something else like the title. So you can use a random string.
And the URL from develompement seed. Again I believe it would be better to use something abstract. By this we should have some more reliability as the test constantly changes and it will exists forever.
Comment #31
pdrake commentedThere is a slight problem with the patch in #27 in that if you have define the field with a static title and are importing an empty URL field, it assigns the default values before it checks if there is a value being imported. This leaves you with a field with a static title defined and no URL. The expected behavior for records without a URL would be not to set any value, no? Not sure if I solved it the proper way but you can see what I did in the attached patch.
Comment #32
AntiNSA commentedcan someone tell me... I dont have the link file to patch in my mappers directory........ ?
Comment #33
webwriter commented@AntiNSA- the patch in #31 contains the link.inc file.
Comment #34
alex_b commented#31 NR
Comment #35
kars-t commentedStill some minor codingstyle issues.
Powered by Dreditor.
And I got many errors running the simpletest:
There are many errors like this. But the real error is here:
I run it on a clean D6 stage. Sorry seems to be more work about this :-/
[EDIT]
The last error is basically my fault. I didn't enable CCK on my stage. The lables are still missing but that part works as expected. So this should never happen as no one can select a link CCK field if its not active. But the question comes up if than the mapper plugin should get some wrapper or dependencie to cck? Maybe the test script should double check if the module is really enabled during the test?
Comment #36
skizzo commentedI have a CCK Link field type in my target and I applied patch #31 (first to 6.x-1.0-alpha14 and then to 6.x-1.x-dev).
In both instances clicking on Mapping results in a WSOD and the following error is logged
PHP Parse error: syntax error, unexpected $end in /var/www/drupal/sites/all/modules/feeds/mappers/link.inc on line 83Comment #37
Funkymoses commentedAlso getting WSOD error.
Comment #38
rjbrown99 commented+1 on the error on #31. It's just missing two close braces at the bottom. Add this -
I have no idea why they don't get applied as they seem to be in the patch itself. Mine cut off after the $node->$field_name = $field_data; line.
Comment #39
servantleader commentedsubscribing
Comment #40
servantleader commentedApplied #31 and fixed manually as in #38 and it worked. I am not sure why the patch is not working right.
Comment #41
servantleader commentedFixed the patch in 31. I think some lines got added after the patch was made. Also fixed code style issues in 35. Seems to be working (fixed all the WSOD stuff) but I have not looked at test results yet.
Comment #42
kars-t commented@servantleader
If you do a patch please set it to "Needs review" :)
Didn't real test it but there is minor coding convention thing here:
Don't use tabs.
Powered by Dreditor.
Comment #43
srobert72 commentedSubscribing
Comment #44
alex_b commented- Fix code style issues.
- Fix missing 'title' key warnings in getFormFieldsValues() with an isset() - don't feel sure about that. Why is that 'title' property missing in the first place? Needs Review.
Comment #45
Spark_man commentedI'm getting the following warning when I import feed items:
user warning: Field 'url' doesn't have a default value query:
INSERT INTO feeds_node_item (nid, id, feed_nid, imported, hash)
VALUES (147, 'my_test_feed_importer', 130, 1275400767,
'509e52a5402134355afe8dd9017ac239') in
C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\drupal-6.16\includes\common.inc
on line 3523.
I'm not sure if this is a "links" module problem, a CCK problem, a Feeds problem or a SQL problem.
I'm running Feeds15Alpha, the latest "links" module, the patch from #44 above. MySQL is ver 5.1.44 and PHP is 5.3.2.
Comment #46
kars-t commented@Spark_man Is your MySQL runnung in strict mode?
http://dev.mysql.com/doc/refman/5.0/en/server-sql-mode.html#sqlmode_stri...
Normally that shouldn't be a problem.
Comment #47
Spark_man commentedYes ... I removed the startup variable declaration and it eliminated the problem, but the question is, is this a code problem? I mean, if MySQL 5.x provides this feature as a safeguard against invalid data, shouldn't the code also ensure that it is properly populating the data fields or at least defining them in properly?
Comment #48
alex_b commented#47 - agreed, we should fix this: #819876: Field 'url' and 'guid' don't have default values
Comment #49
alex_b commentedCommitted, thank you http://drupal.org/cvs?commit=382142
Comment #52
AntiNSA commentedI cant get any of my custom cck fields mapped