My goal: When a new feed item is added as a node, automatically assign taxonomy based on what is in the feed item.
How I think I am going to achieve it: If the feed item contains tags, use that to find proper terms in my taxonomy tables and assign those to the added node.
The problem: The tags are parsed as the string "Array" instead of the actual content.

When using this RSS feed:

<?xml version="1.0" ?>
<rss version="2.0">
<channel>
    <title>FEED TITLE</title>
    <link>http://www.example.com</link>
    <description>FEED DESCRIPTION</description>

    <item>
        <title>ITEM TITLE</title>
        <description><![CDATA[ITEM DESCRIPTION]]></description>
        <category domain="taxonomy/category">General Programming</category>
        <category domain="taxonomy/category">PHP</category>
        <pubDate>Tue, 15 Apr 2008 16:00:50 EDT</pubDate>
        <guid>8525697573E188525004F5C38</guid>
    </item>
</channel>
</rss>

The parsed source returned by _parser_common_syndication_RSS20_parse() contains wrong information. Pay attention to the "tags" entry:

stdClass Object
(
    [title] => FEED TITLE
    [description] => FEED DESCRIPTION
    [options] => stdClass Object
        (
            [link] => http://www.example.com
        )

    [items] => Array
        (
            [0] => stdClass Object
                (
                    [title] => ITEM TITLE
                    [description] => ITEM DESCRIPTION
                    [options] => stdClass Object
                        (
                            [original_author] => FEED TITLE
                            [timestamp] => 1208289650
                            [original_url] => 
                            [guid] => 8525697573E188525004F5C38
                            [tags] => Array
                        )

                )

        )

)

This is caused by this line of code:
$additional_taxonomies['RSS Categories'] = (string)explode('/', $news['category']);

I do not know why it is trying to explode it using "/", I have not had the chance to review the whole source code yet.

But I know that this will ALWAYS return the string "Array" because explode() returns an array and it is casting it as a string. An array casted as a string returns "Array" for me.

print (string)Array("hi")."\n"; <---- "Array\n"

Does anyone happen to knows what the "tags" entry of the parsed source was supposed to contain and what it was used for?

Let me know if this is not clear or if you have any questions.

CommentFileSizeAuthor
#4 246938.patch1.47 KBroychri

Comments

Leeteq’s picture

Subscribing.

aron novak’s picture

Thanks a lot. It's fixed for both 5.x and 6.x (you need the dev package until the next official release)
You'll find such a structure:

tags => array => (
0=> 'tag1',
1=> 'tag2',
)

aron novak’s picture

Status: Active » Fixed
roychri’s picture

Status: Fixed » Needs review
StatusFileSize
new1.47 KB

Thanks a bunch Aron,

What about when the tag has a domain attribute like in my example?

  <category domain="taxonomy/category">General Programming</category>

I coded something that handles this case and create a structure that include both the value and the domain attribute when present.

Would anyone be interested if the FeedApi supports the domain attribute of the tag?

My argument is that since RSS2.0 supports it, the module should too. But maybe no one uses it?

Attached is the patch of my changes. What do you think?

aron novak’s picture

Yes, ATOM and RSS2.0 also support some categorization of "taxomomy" terms.
Sure, the module has to support it.
But I prefer another structure:
- no domain info present:

$feed->options->tags = array(
 [0] = 'tag1',
 [1] = 'tag2',
);

Domain info:

$feed->options->tags = array(
 [0] = 'tag1',
 [1] = 'tag2',
);
$feed->options->domains = array(
'domain1' => array(0, 2, 6),
'domain2' => array(1, 3, 4),
);

I do not want to alter the structure, so i'd like to add another property with domain info. What do you think, is it acceptable to you?

roychri’s picture

Status: Needs review » Needs work

I love it! :)

I agree with you about not altering the structure and your suggestion makes a lot of sense.

What do you think of the way I extract the domain from the feed in my patch?

aron novak’s picture

Status: Fixed » Postponed (maintainer needs more info)

roychri:
The latest devel package will contain full domain / scheme extraction for RSS/ATOM at common syndication parser and simplepie parser too.

aron novak’s picture

Assigned: Unassigned » aron novak
Status: Needs work » Fixed
Anonymous’s picture

Status: Postponed (maintainer needs more info) » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.