I have read similar issues, but after trying suggested remedies am wondering if I am either a) doing something obviously stupid (most probable) or b) am in a new-ish bug-zone. Basic scenario: Have Ubercart in a site with product nodes that have cck image_field for the product graphic. I have a webservice based on SOAP that I use to download a catalog of products. All the product fields are downloading fine, except the image. The first time I run the webservice, it shows. Then, on the daily download it wipes itself out from then on out. It is not visible as a thumbnail, as an original view, as anything. My 'file system path' global is set to 'sites/default/files'. Here is the 'code that makes the node':

$mime = 'image/jpeg'; 
	   $file_drupal_target = "sites/default/files/imagecache/product/" . urldecode($wine['Picture']);
	   $file_drupal_defaults = "sites/default/files/images/dload/default_wine_" . $counter . ".jpg";
	   
	   //$wine['PhotoPath'] . urldecode($wine['Picture']
	   //print_r();
	   $Wine_Pic_Path = "http://shop.bonterra.com/assets/images/wines/pictures/" . urldecode($wine['Picture']);  
	   //If copy operation fails then use default image
	   if (!file_copy($Wine_Pic_Path, $file_drupal_target, FILE_EXISTS_RENAME)) {
	        file_copy($file_drupal_defaults, $file_drupal_target, FILE_EXISTS_RENAME);
	   }
		
	   $file = new stdClass();
	   $file->filename = basename($file_drupal_target);
	   $file->filepath = $file_drupal_target;
	   $file->filemime = $mime;
	   $file->filesize = filesize($file_drupal_target);
	
	   $file->uid = 1;
	   $file->status = FILE_STATUS_TEMPORARY;
	   $file->timestamp = time();
	   $file->new = true;
	   drupal_write_record('files', $file);
	   
	   // change file status to permanent (default is temporary)
           file_set_status($file,1);
	   	   
	   if (!($data = db_fetch_object($qry_result))) {  // Query finds no record, so create new one		

			$node = new stdClass();
			node_object_prepare($node); // default node fields so we don't accidentally leave something off.
			
			$node->type = 'product'; 
			$node->status = 1;
			$node->format = '2';
			$node->pkg_qty = '1';
			$node->default_qty = '1';
			$node->shippable = '1';
			$node->title = $wine['ProductName'];
			$node->body = $wine['Description'];
			$node->teaser = $wine['Description'];
			
			$node->field_wine_guid[0]['value'] = $wine['WineID'];
			$node->field_story[0]['nid'] = '106';
			 
			$node->model = 'Bon-' . $wine['ProductSKU'];
			$node->list_price = $wine['Price1'];
			$node->cost = 3;
			$node->sell_price = $wine['Price1'];
			$node->taxonomy = array(16, 203, 218);  // 'Wines', 'Bonterra'-Product Story, Group 1 (checkout)
			
			$node->field_image_cache[0]['fid'] = $file->fid;
			$node->field_image_cache[0]['uid'] = 1;
			$node->field_image_cache[0]['status'] = 1;
			$node->field_image_cache[0]['list'] = 1;
			$node->field_image_cache[0]['filename'] = $file->filename;
			$node->field_image_cache[0]['filepath'] = $file->filepath;
			$node->field_image_cache[0]['filesize'] = $file->filesize;
			$node->field_image_cache[0]['filemime'] = $mime;
			$node->field_image_cache[0]['timestamp'] = $file->timestamp;
			
			node_save($node); 
		   
	   } else { 		// Query found record, so edit it
	   		
			$node = node_load($data->nid);
			$node->title = $wine['ProductName'];
			$node->body = $wine['Description'];
			$node->teaser = $wine['Description'];
			 
			$node->model = 'Bon-' . $wine['ProductSKU'];
			$node->list_price = $wine['Price1'];
			$node->cost = 3;
			$node->sell_price = $wine['Price1'];
			
			$node->field_image_cache[0]['fid'] = $file->fid;
			$node->field_image_cache[0]['uid'] = 1;
			$node->field_image_cache[0]['status'] = 1;
			$node->field_image_cache[0]['list'] = 1;
			$node->field_image_cache[0]['filename'] = $file->filename;
			$node->field_image_cache[0]['filepath'] = $file->filepath;
			$node->field_image_cache[0]['filesize'] = $file->filesize;
			$node->field_image_cache[0]['filemime'] = $mime;
			$node->field_image_cache[0]['timestamp'] = $file->timestamp;
			
			node_save($node); 
	   } 			//end if------------------------------------------------------   
   }  				// end foreach

Questions: Is it only possible to use the basic files folder for automated upload/download, or are subfolders of it ok? Is there a delete/clean function that would 'clear the way' for the next version of the file? Do I need to clean out the files table itself?

CommentFileSizeAuthor
#3 error.PNG21.28 KBniki v

Comments

MhueD’s picture

Some things to add: I have tried setting the FILE_STATUS_PERMANENT and FILE_EXISTS_REPLACE values...nothing changes. There is a query iterating with a foreach loop that contains the big if/then structure in the previous post:

     foreach ($nest_wines as $wine) {            
           $sql =  "SELECT * FROM {node} AS n JOIN {content_type_product} AS c ON n.nid=c.nid ";
	   $sql .= "WHERE type = 'product' and c.field_wine_guid_value = '" . $wine['WineID'] . "'";
	   
           $qry_result = db_query(db_rewrite_sql($sql));
fizk’s picture

Status: Active » Closed (fixed)

Please reopen if this is still an issue with ImageCache 6.x-2.0-rc1.

niki v’s picture

StatusFileSize
new21.28 KB

I'm using ImageCache 6.x-2.0-rc1 and I have read numerous threads in the forums re "disappearing images", whether image-cache or IMCE. I was having the same issues intermittently but I started to think the problem is not necessarily with Imagecache itself.
From what others are saying, it seems to creep in whenever there are a large number of modules installed and I found that even though I had css and js compression enabled, I was occasionally losing product images that I uploaded on a D6 site with Ubercart. My IMCE images on story content would also sometimes disappear.

When I installed Advanced CSS/JS Aggregation http://drupal.org/project/advagg I found that the site is faster and has stopped losing images - previously, the form was being loaded, even though it hadn't been created on the server.
I think that Drupal's own compression isn't adequate for ecommerce and similar sites and anytime the I.P. or server is having a flaky moment and slows down, the images are lost - since installing the aggregation module I now occasionally get the message as per attached screenshot and so far, no more lost images

Is this a plausible theory?