Question: since node_validate() really does validate your new node (being a standard story node), why can't you use it?<br><br><div><span class="gmail_quote">On 6/7/06, <b class="gmail_sendername">Robrecht Jacques</b> <
<a href="mailto:robrechtj+drupal@gmail.com">robrechtj+drupal@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><span class="q">On 6/7/06, <b class="gmail_sendername">Earl Dunovant</b> <<a href="mailto:prometheus6@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">prometheus6@gmail.com</a>> wrote:
</span></div><div><div></div><div><span class="q"><span class="gmail_quote"></span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div><br>With no claim that it's the Right Way© </div></div></blockquote></span></div><div><div><br>Again, no validation at all.<br><br>I know how to create a node programmatically. But this way, you can't be sure it is valid.
<br><br>
Thanks anyway,<br></div><div><span class="sg">Robrecht </span></div><div></div></div><div><span class="e" id="q_10bad9e7cb0bbfcf_6"><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote">
function syndicator_item_to_node($item_id = NULL) {
<br> global $user;<br> if (is_null($item_id)) {<br> $iid = arg(2);<br> if (isset($iid)) {<br> $item = db_fetch_object(db_query(SYNDICATOR_PROMOTE_TO_NODE_QUERY, $iid));<br> }<br> }<br> else if (is_numeric($item_id)) {
<br> $item = db_fetch_object(db_query(SYNDICATOR_PROMOTE_TO_NODE_QUERY, $item_id));<br> }<br> if (isset($item)) {<br> $node = new stdClass();<br> $node->is_new = true;<br> $item->description = check_markup($item->description, $node->filter);
<br> $node->created = time();<br> $node->date = format_date($item->timestamp, 'custom', 'Y-m-d H:i:s O');<br> $node->type = variable_get('syndicator_publish_node_type', 'none');<br> $node->title = $item->title;
<br> $node->filter = variable_get('filter_default_format', FILTER_FORMAT_DEFAULT);<br> $node->body = theme('syndicator_published_content', $item);<br> $node->teaser = node_teaser(theme('syndicator_published_content', $item),
<br> variable_get('filter_default_format', FILTER_FORMAT_DEFAULT)); // might be unnecessary<br><br> $node_options = variable_get('node_options_' . $node->type, array());<br> $node->comment = variable_get('comment_' . $node->type, 2);
<br> unset($node->nid);<br> $node = node_submit($node);<br> $node->uid = $user->uid ? $user->uid : 1;<br> module_invoke('node', 'save', $node);<br> }<br>}<br><br><br></blockquote></div><div><span>
<br><div><span class="gmail_quote">
On 6/6/06, <b class="gmail_sendername">Robrecht Jacques</b> <<a href="mailto:robrechtj+drupal@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">robrechtj+drupal@gmail.com</a>> wrote:
</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div><div>- and the real question: how does the following sequence of
4.6 translate into 4.7:<br><pre>$node->type = 'story';<br>$node->uid = 1;<br>$node->title = ''; // invalid empty title!<br>$node->body = ''; // invalid empty body!<br><br>$node = node_validate($node); // if life was only that
<br><br><br><br> // that easy in 4.7... <br><br>if (form_get_errors()) {<br> // we detected the error... do something<br> unset($GLOBALS['form']);<br><br> // note: we unset $GLOBALS['form'] so the next time we
<br><br><br><br> // try this trick, form_get_errors() return the errors<br> // of the last run and not of the previous.<br> // If something like this would be possible in 4.7 it<br> // would be great, but form_set_error() in
<br><br>4.7 saves the<br><br> // errors in a static variable inside form_set_error()<br> // instead of in $GLOBALS['form']. I see no way to unset<br> // that...<br> $output .= node_view($node);<br>}<br>else {<br> // no errors? hmm, great, save it... quickly before
<br><br><br><br> // "they" introduce something else that breaks<br> // "common sense". Really: why call something<br> // foobar_validate() if it doesn't validate anything<br> // at all... Am I alone in this? I guess so.
<br><br><br><br> node_save($node);<br>}<br></pre></div></div></blockquote></div><br>
</span></div></blockquote></span></div><div></div><br>
</div></blockquote></div><br>