node_service_save watchdog entry assumes it updated an existing node

seutje - February 26, 2009 - 13:11
Project:Services
Version:6.x-0.14
Component:Code
Category:bug report
Priority:normal
Assigned:snelson
Status:duplicate
Description

if you use node.save to create a new node, the node_service_save function still sorta assumes you updated an existing one, as it only does $node = node_load(...) inside the if ($edit['nid']) { ... } clause

so when there is no nid passed (when creating a brand new node) it tries to enter this watchdog entry:

<?php
  watchdog
('content', '@type: updated %title.',
    array(
'@type' => t($node->type), '%title' => $node->title),
   
WATCHDOG_NOTICE, l(t('view'), 'node/'. $node->nid));
?>

leading to a watchdog entry that looks like " : updated " linking to "node/" and causing loads of errors like

preg_match() expects parameter 2 to be string, array given in C:\xampp\htdocs\wielphase2\includes\bootstrap.inc op regel 761.

when watching the watchdog page, untill they eventually bump off the messages causing the error

as a temporary fix for myself, I added

<?php
$node
= node_load($nid);
?>

right under
<?php
// Fetch $nid out of $form_state
$nid = $form_state['nid'];
?>

this keeps the errors from showing up on the watchdog page, but it leads to silly log entries like
page: updated someTitle
page: created someTitle

when there never was an update, only a create

I'll try to make a proper patch for this later tonight after I get home, so I can grab a latest CVS and migrate the watchdog call to inside the if ($edit['nid']) {...} clause or maybe even remove it entirely, not sure if the drupal_execute doesn't already add a watchdog entry

#1

snelson - March 7, 2009 - 21:13
Assigned to:Anonymous» snelson
Status:active» duplicate

The watchdog call in node.save has been removed in Services dev, it was redundant as saving the node with drupal_execute logs the save to watchdog.

#2

seutje - July 3, 2009 - 07:13
Version:6.x-0.13» 6.x-0.14

issue persists in 0.14 but I can see it's removed in -dev

can we get an 0.15 so this thing doesn't bug me about it being a dev? :P

 
 

Drupal is a registered trademark of Dries Buytaert.