When I try to add a new node using node.save I receive the message:

Attempt to assign property of non-object in /home/server/public_html/sites/all/modules/services/services/node_service/node_service.inc on line 148.

Solved using:

if(!edit->uid && edit->uid!=NULL) instead of if(!edit->uid)

I'm not really sure that this is correct. any clue about this error?.

CommentFileSizeAuthor
#8 710590.patch1.07 KBgdd
#6 710590.patch851 bytesgdd
#4 services-710590.patch785 bytessolipsist

Comments

P.Smith’s picture

I'm having a problem creating a node, too, with node.save.

I should have thought more about this before. $edit is an array ($user is an object so don't change anything with that) but in this part it is being treated as an object. Code change needed:

if (!$edit['uid']) {
      global $user;
      $edit['uid'] = $user->uid;
    }
robin van emden’s picture

I can confirm that this code change is both needed and that the change works. Rather a show-stopper, maybe mark this one critical?

un11imig’s picture

Priority: Normal » Critical

Ok, I put this as critical.

solipsist’s picture

Status: Active » Needs review
StatusFileSize
new785 bytes

Attaching patch file.

Status: Needs review » Needs work

The last submitted patch, services-710590.patch, failed testing.

gdd’s picture

Status: Needs work » Needs review
StatusFileSize
new851 bytes

Not sure why that last patch failed, but I just rolled this one. Lets see if its ok.

BillyMG’s picture

And here I was about to file a new issue with my patch for it when I suddenly found this issue. The only difference with my patch is that I also changed line 153:

-    $form_state['values'] = (array) $edit;
+    $form_state['values'] = $edit;

After all, there's no sense in casting it again, not that it really matters other than being confusing. Other than that, I can confirm that this patch worked for me.

gdd’s picture

StatusFileSize
new1.07 KB

Good catch, here's a reroll

waldmanm’s picture

Just ran into this problem with 2.0-beta1, applied the patch in #8, and can confirm it solves the problem.

gdd’s picture

Status: Needs review » Fixed

Commited, thanks everyone.

Status: Fixed » Closed (fixed)

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