<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:arial, helvetica, sans-serif;font-size:12pt"><avglsdata id=avglsdata></avglsdata>
<DIV></DIV>
<DIV>This probably does belong in development, because I encountered something simialr last night building a D7 site from scratch. Well, actually, it probably should be in the D7 issues queue.</DIV>
<DIV> </DIV>
<DIV>I had added a few images to articles, then realized I hadn't set the correct file path. I changed my filepath setting and went back to those nodes. I removed the current image, then added the picture again (same edit session). Every one resulted in this error. Worse, the error overlays the page with no way to clear it except to go to another page. AFAICT, the image was actually loaded again.<BR> </DIV>
<P><FONT color=#ff007f size=4 face="bookman old style, new york, times, serif"><EM><STRONG>Nancy</STRONG></EM></FONT></P>
<P> </P>
<P><FONT face="arial, helvetica, sans-serif">Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L. King, Jr.</FONT></P>
<DIV><BR></DIV>
<DIV style="FONT-FAMILY: arial, helvetica, sans-serif; FONT-SIZE: 12pt"><BR><FONT size=2 face=Tahoma>
<DIV style="FONT-FAMILY: times new roman, new york, times, serif; FONT-SIZE: 12pt">
<HR SIZE=1>
</DIV>
<DIV style="FONT-FAMILY: times new roman, new york, times, serif; FONT-SIZE: 12pt"><B><SPAN style="FONT-WEIGHT: bold">From:</SPAN></B> Blaine Lang</DIV>
<DIV style="FONT-FAMILY: times new roman, new york, times, serif; FONT-SIZE: 12pt"></FONT> </DIV>
<STYLE>
<!--
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;margin-bottom:.0001pt;font-size:12.0pt;font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:purple;text-decoration:underline;}
p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
        {margin:0in;margin-bottom:.0001pt;font-size:10.0pt;font-family:"Courier New";}
_filtered {margin:1.0in 77.95pt 1.0in 77.95pt;}
div.Section1
        {}
-->
</STYLE>
<DIV style="FONT-FAMILY: times new roman, new york, times, serif; FONT-SIZE: 12pt" class=Section1>
<P class=MsoPlainText><FONT size=2 face="Courier New"><SPAN style="FONT-SIZE: 10pt">I am working on an enhancement to the filedepot module for a multifile uploader - drag & drop files to a hotspot on the browser. It was all working nicely but now consistently getting duplicate entry errors in both the node_access and the CCK table </SPAN></FONT></P>
<P class=MsoPlainText><FONT size=2 face="Courier New"><SPAN style="FONT-SIZE: 10pt"> </SPAN></FONT></P>
<P class=MsoPlainText><FONT size=2 face="Courier New"><SPAN style="FONT-SIZE: 10pt">The filedepot_folder is a node and the files are attachments - using the filefield CCK widget.</SPAN></FONT></P>
<P class=MsoPlainText><FONT size=2 face="Courier New"><SPAN style="FONT-SIZE: 10pt"> </SPAN></FONT></P>
<P class=MsoPlainText><EM><I><FONT size=2 face="Courier New"><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt">Duplicate entry '16-0-all' for key 1 query: INSERT INTO node_access (nid, realm, gid, grant_view, grant_update, grant_delete) VALUES (16, 'all';, 0, 1, 0, 0)</SPAN></FONT></I></EM></P>
<P class=MsoPlainText><FONT size=2 face="Courier New"><SPAN style="FONT-SIZE: 10pt"> </SPAN></FONT></P>
<P class=MsoPlainText><EM><I><FONT size=2 face="Courier New"><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt">Duplicate entry '16-1' for key 1 query: INSERT INTO content_field_filedepot_file (vid, nid, delta, field_filedepot_file_fid, field_filedepot_file_list, field_filedepot_file_data) VALUES (16, 16, 1, 234, NULL, NULL)</SPAN></FONT></I></EM> </P>
<P class=MsoPlainText><FONT size=2 face="Courier New"><SPAN style="FONT-SIZE: 10pt"> </SPAN></FONT></P>
<P class=MsoPlainText><FONT size=2 face="Courier New"><SPAN style="FONT-SIZE: 10pt">I've stripped the module code down to only the following and modules HOOK_nodeapi is just doing a return so no other code in filedepot should be involved.</SPAN></FONT></P>
<P class=MsoPlainText><FONT size=2 face="Courier New"><SPAN style="FONT-SIZE: 10pt"> </SPAN></FONT></P>
<P class=MsoPlainText><FONT color=black size=2 face="Courier New"><SPAN style="COLOR: black; FONT-SIZE: 10pt">$node = node_load($file->nid, NULL, TRUE);</SPAN></FONT></P>
<P class=MsoPlainText><FONT color=black size=2 face="Courier New"><SPAN style="COLOR: black; FONT-SIZE: 10pt">$field = content_fields('field_filedepot_file', 'filedepot_folder');</SPAN></FONT></P>
<P class=MsoPlainText><FONT color=black size=2 face="Courier New"><SPAN style="COLOR: black; FONT-SIZE: 10pt">$validators = filefield_widget_upload_validators($field);</SPAN></FONT></P>
<P class=MsoPlainText><FONT color=black size=2 face="Courier New"><SPAN style="COLOR: black; FONT-SIZE: 10pt"> </SPAN></FONT></P>
<P class=MsoPlainText><FONT color=black size=2 face="Courier New"><SPAN style="COLOR: black; FONT-SIZE: 10pt">$nodefile = field_file_save_file($file->tmp_name, $validators, $this->tmp_storage_path);</SPAN></FONT></P>
<P class=MsoPlainText><FONT color=black size=2 face="Courier New"><SPAN style="COLOR: black; FONT-SIZE: 10pt">// Need to populate the CCK fields for the filefield field - so node_save will update the CCK field</SPAN></FONT></P>
<P class=MsoPlainText><FONT color=black size=2 face="Courier New"><SPAN style="COLOR: black; FONT-SIZE: 10pt">$node->field_filedepot_file[] = $nodefile;</SPAN></FONT></P>
<P class=MsoPlainText><FONT color=black size=2 face="Courier New"><SPAN style="COLOR: black; FONT-SIZE: 10pt">node_save($node);</SPAN></FONT></P>
<P class=MsoPlainText><FONT color=black size=2 face="Courier New"><SPAN style="COLOR: black; FONT-SIZE: 10pt"> </SPAN></FONT></P>
<P class=MsoPlainText><FONT color=black size=2 face="Courier New"><SPAN style="COLOR: black; FONT-SIZE: 10pt">// Clear CCK data cache so the new value will be loaded for display purposes</SPAN></FONT></P>
<P class=MsoPlainText><FONT color=black size=2 face="Courier New"><SPAN style="COLOR: black; FONT-SIZE: 10pt">cache_clear_all('content:' . $node->nid . ':' . $node->vid, 'cache_content');</SPAN></FONT></P>
<P class=MsoPlainText><FONT color=black size=2 face="Courier New"><SPAN style="COLOR: black; FONT-SIZE: 10pt"> </SPAN></FONT></P>
<P class=MsoPlainText><FONT color=black size=2 face="Courier New"><SPAN style="COLOR: black; FONT-SIZE: 10pt">I was suspecting a race condition as the files I'm uploading are small test files and thought the node_save was not completed before another update was attempted but attempts to remove this potential race condition still cause the same issue.</SPAN></FONT></P>
<P class=MsoPlainText><FONT color=black size=2 face="Courier New"><SPAN style="COLOR: black; FONT-SIZE: 10pt"> </SPAN></FONT></P>
<P class=MsoPlainText><FONT color=black size=2 face="Courier New"><SPAN style="COLOR: black; FONT-SIZE: 10pt">Often the first 2 or 3 files get attached just fine to the folder node and then the next file triggers the SQL error then a few more may save ok and then SQL error but the pattern is not consistent.</SPAN></FONT></P></DIV></DIV></div></body></html>