Deep into the night I toiled, in that weird hybrid state of half exhaustion half code writing genius until two very large pages of code were written, I ran the script expecting errors all over the place and .... it worked flawlessly. Images uploaded and saved as nodes, derivative images created, main node uploaded, wiki syntax scanned, images renamed, image nodes renamed, files renamed and DONE!
Satisfied I went to bed.
OH NO THERE WAS HIDDEN FAIL!
My cck fields are being clobbered. I painstakingly loaded an example node, replicated it's field structure perfecty but with the new values that were being uploaded called node_submit() then called node_save() and... node_submit is deleting all my painstakingly constructed fields. The checkbox text fields are being removed, the taxonomy fields are gone the only field that survives the carnage is the CCK Money field.
So does anyone have any idea on how to correctly save cck fields from the commandline, from what I've been able to gather node_submit followed by node_save should work but I am running into a brickwall.
Comments
For anyone who runs into the
For anyone who runs into the same problem, I finally solved it. A node loaded with node_load() does not represent the format that node_save() accepts. I am presuming that node_sumit() should pass the node to the relevant cck modules which should then alter the node structure to represent the correct format for node_save() to erm save. Unfortunately those cck modules seem to be expecting form inputs and don't directly work on the node structure.
So basically in order to correctly save a node, all cck fields (or at least the ones I'm using) expect the format
$node->cck_field[0]['value'] = "whatever";
For taxonomy values with content_taxonomy whatever was a term tid.
For others I'm not sure, but some variation on the above.