Closed (won't fix)
Project:
FeedAPI
Version:
6.x-1.x-dev
Component:
Code feedapi_node
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
31 Jan 2009 at 10:56 UTC
Updated:
18 Jun 2011 at 11:21 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
avpadernoI am changing the priority as this issue causes interference with other modules.
Comment #2
avpadernoI am referring to the code at line 277 where the code is
$node = new stdClass();; at line 355 the code is thennode_save($node);.The module calls
node_object_prepare(), but that function callsnode_invoke_nodeapi($node, 'prepare'), notnode_invoke_nodeapi($node, 'load')(see the function documentation). In this way, all the node properties a module would add into the node are not initialized.Comment #3
Anonymous (not verified) commentedThis is really murdering all of the data added to the node object during a node via hook_nodeapi. The xmlsitemap module doesn't have a chance since the updated node looses its data from the object before its saved. I'll look at uploading a patch soon.
Comment #4
avpadernoI think that the problem is not limited to XML Sitemap, but it's common to all the modules that add additional data in
hook_nodeapi('load'), and save them inhook_nodeapi('insert')(orhook_nodeapi('update')).Comment #5
avpadernoChecking better the code, the part of the code I am referring to is executed for content that the project modules import from a feed; being this the case, the module is not modifying an existing node, but it's creating a new node (therefore there should not be any lose of data added by third party modules).
I still think that the way used by the module to initialize the node object it creates is not the correct one.
Comment #6
aron novakSee this:
http://lists.drupal.org/pipermail/development/2008-March/029152.html
If you're ready to step up with a fast and sane way to create nodes (with a patch), i'd be the happiest to trash out the old code.
Comment #7
avpadernoThe code could simply add a call to
node_invoke_nodeapi($node, 'load'). It doesn't resolve all the problems, but at least it would be more compatible with the modules that usehook_nodeapi('load'),and it would not break the modules that load their data inhook_nodeapi('load'), and save their data (after they are changed by the user) inhook_nodeapi('insert')(orhook_nodeapi('update')).Comment #8
pillarsdotnet commentedNoticed this problem when my feedapi-created forum topics didn't show up in forum listings.
Tried adding a call to node_invoke_nodeapi($node, 'load') before the node_object_prepare() call.
No joy.
Tried adding a node_submit() call.
No joy.
lotsa-lotsa-lotsa debugging output -- gonna try creating a new content type and re-creating forums via views.
Wish me luck...
Comment #9
metamatsu commentedThe uid in the {node_revisions} table is not getting set correctly for feedapi-created nodes.
It is always getting set to uid=0, even though the uid is set properly in the {node} table.
Could this be what is causing problems for other modules like pathauto?
http://drupal.org/node/201110#comment-1488576
http://drupal.org/node/432454#comment-1471514
Comment #10
hefox commentedA use case where basically they wanted to keep their feeds up to date but add extra information like taxonomy and cck.
However since feedapi was not calling node_load that data was being lost (calling node_invoke_nodeapi load for new nodes).
Here is part of the diff; we haven't had the time to update to newest feedapi so haven't had the time to make a real patch ATM.
> if (!$feed_item->nid) {
> $node = new stdClass();
> node_invoke_nodeapi($node, 'load');
> // Determines the node type.
> if (empty($settings['content_type'])) {
> $ct_types = node_get_types();
> $ct_options = array();
> if (is_array($ct_types)) {
> foreach ($ct_types as $key => $data) {
> if (!feedapi_enabled_type($key)) {
> $ct_options[$key] = $data->name;
> }
> }
> }
> if (array_key_exists('story', $ct_options)) {
> $node->type = 'story';
> }
> else {
> $node->type = current(array_keys($ct_options));
> }
> }
> else {
> $node->type = $settings['content_type'];
> }
>
> if (feedapi_enabled_type($node->type)) {
> if ($error_msg !== TRUE) {
> drupal_set_message(t('Please disable FeedAPI for !item content-type.', array('!item' => $node->type)), 'error');
> $error_msg = TRUE;
> }
> return FALSE;
> }
>
> // Get the default options from the cont
> $options = variable_get('node_options_'. $node->type, FALSE);
> if (is_array($options)) {
> $node->status = in_array('status', $options) ? 1 : 0;
> $node->promote = in_array('promote', $options) ? 1 : 0;
> $node->sticky = in_array('sticky', $options) ? 1 : 0;
> }
> else {
> $node->status = 1;
> }
> } else {
> $node = node_load($feed_item->nid);
> }
This does not address the issue picking up data /changes to the form during hook_form_alter. Drupal execute would do that, but that'd defiantly be a lot slower. (I've used it a few times to create /update nodes). Could patch it for drupal execute and batchapi also for when running manual refresh (personally I've only used modules patched for batch api so not to knowledgeable about it).
My suggestion is for those with that problem figure out what changes the modules in conflict are doing and mock it in presave or such :/.
Comment #11
socialnicheguru commentedwhere does this snippet go? I'd be willing to test if I knew which file and approx line number and approx what it will replace.
Comment #12
hefox commentedOoops, sorry for not putting it.
At home and my set up is lacking and don't have the altered file in front of me, so I'm based off the above, memory, and looking at a fresh copy of feedapi.
It's in feedapi_node => feedapi_node.module
The function is function _feedapi_node_save
Around the area where it says "Constructs the node object."
(That function is both update and save; is called by _feedapi_node_update with nid in the $feed_item of the old node).
I haven't looked to see if they've changed anything specifically here (since I was using an old version), so I suggest just redoing what I did instead of that snippit;
in an if not nid, move everything related to creating a new node together including a new call near the top to node_invoke_nodeapi($node, 'load') if nid isn't supplied
else node_load($feed_item->nid)
Comment #13
aron novakLet's give drupal_execute a try. I know that it's slow but if people have so many headaches with the current situation, maybe it's worth to try.
Here is a patch. The patch: does not support cross-feed deduping and feedapi_inherit.
Please try it out and tell if your node-related problems have gone or not.
If you can confirm that this approach is seamless (but slow), we can consider to make this as the default way to create nodes.
Comment #14
aron novakThe patch is okay at the moment, but likely won't apply soon (because of planned commits)
Here is a ready-to-use package, which includes the patch of #13 : http://aron.novaak.net/files/feedapi.zip
The tests and the feedbacks are really welcomed!
Comment #15
avpadernoI still find easier to make third-party modules kick in by adding a code line like
node_invoke_nodeapi($node, 'load').Comment #16
aron novak#15: as i know, for example CCK field default values are not propagated by only this line
Comment #17
avpadernoLooking at the code implemented by cck.module I would think that calling
node_invoke_nodeapi()is enough to populate the node object with data coming from the CCK fields.Maybe I misunderstood the following code, taken by that module:
Comment #18
aron novak#17 - Kiam, it seems that you're right. i will double check if it works correctly. In fact drupal_execute is somewhat hackish, so i'd be really happy to use only one line to solve many problems :)
Comment #19
alex_b commenteddrupal_execute() is going to be too slow.
The core issue is that if feedapi does an update, there is no node_load() before it does a node_save(). drupal_execute() would slow down insert and update.
Why don't we add a node_load() when in updateing a node and make it optional with a hidden but documented drupal variable?
Comment #20
aron novak"The core issue is that if feedapi does an update, there is no node_load() before it does a node_save()." - just a note: this is not only about the updates. This is a problem at the node create process as well, for example CCK fields are not populated with the default values.
See this: http://drupal.org/node/489046
Comment #21
pillarsdotnet commentedI haven't used feedapi in a long time. Is this still an issue, or should it be closed?
Comment #22
Anonymous (not verified) commentedThe maintainer will have to answer but if no patching w.r.t. the invalid object being passed to node_save, then it is still a bug. That said however based on the project page this module is replaced by the feeds module so the bug may forever reside as a "known issue" in this queue until D6 is no longer supported.
Comment #23
pillarsdotnet commented