Download & Extend

Problem identified: Public vs Private Filestore

Project:image_import
Version:master
Component:Code
Category:bug report
Priority:critical
Assigned:syscrusher
Status:closed (fixed)

Issue Summary

I'm having a heck of a time getting import_images to work properly. I've carefully read all the documentation and looked at all the existing bug reports and commentary I can find on the Drupal site -- none seems to address my issue which may or may not be unique.

In brief, everything seems prepped for a good import. Individual image uploads work fine. Directory permissions look good. "Preview import" gives a good report:

DEBUG MODE ENABLED for image_import_import() function. There will be extra messages issued.
DEBUG: Image file extensions: gif,GIF,jpg,JPG,jpeg,JPEG,png,PNG,tif,TIF,tiff,TIFF
DEBUG: Caption file extensions: html,HTML,htm,HTM,txt,TXT,caption,CAPTION
DEBUG: Timestamp for file number 1 is 1129007322
DEBUG: Import called for (path=image_import/robin/DSC_0110.JPG)
DEBUG: Access checks succeeded for image_import/robin/DSC_0110.JPG
DEBUG: Title pattern is "%f".
DEBUG: Title is "DSC_0110.JPG".
DEBUG: Caption 0 characters, teaser 0 characters, for DSC_0110.JPG.
DEBUG: Image DSC_0110.JPG prechecks okay and should import successfully.
DEBUG: System image directory is 'var/www/localhost/files/images'.
DEBUG: Timestamp for file number 2 is 1129007321
DEBUG: Import called for (path=image_import/robin/DSC_0111.JPG)
DEBUG: Access checks succeeded for image_import/robin/DSC_0111.JPG
DEBUG: Title pattern is "%f".
DEBUG: Title is "DSC_0111.JPG".
DEBUG: Caption 0 characters, teaser 0 characters, for DSC_0111.JPG.
DEBUG: Image DSC_0111.JPG prechecks okay and should import successfully.
DEBUG: System image directory is 'var/www/localhost/files/images'.
DEBUG: Timestamp for file number 3 is 1129007320
DEBUG: Import called for (path=image_import/robin/DSC_0112.JPG)
DEBUG: Access checks succeeded for image_import/robin/DSC_0112.JPG
DEBUG: Title pattern is "%f".
DEBUG: Title is "DSC_0112.JPG".
DEBUG: Caption 0 characters, teaser 0 characters, for DSC_0112.JPG.
DEBUG: Image DSC_0112.JPG prechecks okay and should import successfully.
DEBUG: System image directory is 'var/www/localhost/files/images'.
DEBUG: Timestamp for file number 4 is 1129007319
DEBUG: Import called for (path=image_import/robin/DSC_0113.JPG)
DEBUG: Access checks succeeded for image_import/robin/DSC_0113.JPG
DEBUG: Title pattern is "%f".
DEBUG: Title is "DSC_0113.JPG".
DEBUG: Caption 0 characters, teaser 0 characters, for DSC_0113.JPG.
DEBUG: Image DSC_0113.JPG prechecks okay and should import successfully.
DEBUG: System image directory is 'var/www/localhost/files/images'.
DEBUG: Timestamp for file number 5 is 1129007318
DEBUG: Import called for (path=image_import/robin/DSC_0114.JPG)
DEBUG: Access checks succeeded for image_import/robin/DSC_0114.JPG
DEBUG: Title pattern is "%f".
DEBUG: Title is "DSC_0114.JPG".
DEBUG: Caption 0 characters, teaser 0 characters, for DSC_0114.JPG.
DEBUG: Image DSC_0114.JPG prechecks okay and should import successfully.
DEBUG: System image directory is 'var/www/localhost/files/images'.
DEBUG: Timestamp for file number 6 is 1129007317
DEBUG: Import called for (path=image_import/robin/DSC_0115.JPG)
DEBUG: Access checks succeeded for image_import/robin/DSC_0115.JPG
DEBUG: Title pattern is "%f".
DEBUG: Title is "DSC_0115.JPG".
DEBUG: Caption 0 characters, teaser 0 characters, for DSC_0115.JPG.
DEBUG: Image DSC_0115.JPG prechecks okay and should import successfully.
DEBUG: System image directory is 'var/www/localhost/files/images'.
DEBUG: Timestamp for file number 7 is 1129007316
DEBUG: Import called for (path=image_import/robin/DSC_0116.JPG)
DEBUG: Access checks succeeded for image_import/robin/DSC_0116.JPG
DEBUG: Title pattern is "%f".
DEBUG: Title is "DSC_0116.JPG".
DEBUG: Caption 0 characters, teaser 0 characters, for DSC_0116.JPG.
DEBUG: Image DSC_0116.JPG prechecks okay and should import successfully.
DEBUG: System image directory is 'var/www/localhost/files/images'.
DEBUG: Timestamp for file number 8 is 1129007315
DEBUG: Import called for (path=image_import/robin/DSC_0117.JPG)
DEBUG: Access checks succeeded for image_import/robin/DSC_0117.JPG
DEBUG: Title pattern is "%f".
DEBUG: Title is "DSC_0117.JPG".
DEBUG: Caption 0 characters, teaser 0 characters, for DSC_0117.JPG.
DEBUG: Image DSC_0117.JPG prechecks okay and should import successfully.
DEBUG: System image directory is 'var/www/localhost/files/images'.
DEBUG: Timestamp for file number 9 is 1129007314
DEBUG: Import called for (path=image_import/robin/DSC_0118.JPG)
DEBUG: Access checks succeeded for image_import/robin/DSC_0118.JPG
DEBUG: Title pattern is "%f".
DEBUG: Title is "DSC_0118.JPG".
DEBUG: Caption 0 characters, teaser 0 characters, for DSC_0118.JPG.
DEBUG: Image DSC_0118.JPG prechecks okay and should import successfully.
DEBUG: System image directory is 'var/www/localhost/files/images'.
DEBUG: Timestamp for file number 10 is 1129007313
DEBUG: Import called for (path=image_import/robin/DSC_0119.JPG)
DEBUG: Access checks succeeded for image_import/robin/DSC_0119.JPG
DEBUG: Title pattern is "%f".
DEBUG: Title is "DSC_0119.JPG".
DEBUG: Caption 0 characters, teaser 0 characters, for DSC_0119.JPG.
DEBUG: Image DSC_0119.JPG prechecks okay and should import successfully.
DEBUG: System image directory is 'var/www/localhost/files/images'.

However, the "Import images" command results in the following:
File copy failed: no directory configured, or it could not be accessed.
File copy failed for image_import/robin/DSC_0110.JPG to
File copy failed: no directory configured, or it could not be accessed.
File copy failed for image_import/robin/DSC_0111.JPG to
File copy failed: no directory configured, or it could not be accessed.
File copy failed for image_import/robin/DSC_0112.JPG to
File copy failed: no directory configured, or it could not be accessed.
File copy failed for image_import/robin/DSC_0113.JPG to
File copy failed: no directory configured, or it could not be accessed.
File copy failed for image_import/robin/DSC_0114.JPG to
File copy failed: no directory configured, or it could not be accessed.
File copy failed for image_import/robin/DSC_0115.JPG to
File copy failed: no directory configured, or it could not be accessed.
File copy failed for image_import/robin/DSC_0116.JPG to
File copy failed: no directory configured, or it could not be accessed.
File copy failed for image_import/robin/DSC_0117.JPG to
File copy failed: no directory configured, or it could not be accessed.
File copy failed for image_import/robin/DSC_0118.JPG to
File copy failed: no directory configured, or it could not be accessed.
File copy failed for image_import/robin/DSC_0119.JPG to

I get the same results before and after implementing the patch "gordon" provided on Sep. 5.

Version info:

Drupal 4.6.3
/* $Id: upload.module,v 1.31.2.5 2005/05/25 04:28:59 unconed Exp $ */
// $Id: image.module,v 1.146.2.9 2005/08/16 20:16:52 walkah Exp $
// $Id: image_import.module,v 1.14 2005/09/14 03:09:05 syscrusher Exp $

Variable info:

mysql> select * from variable where name='file_directory_path';
+---------------------+----------------------------------+
| name                | value                            |
+---------------------+----------------------------------+
| file_directory_path | s:24:"/var/www/localhost/files"; |
+---------------------+----------------------------------+

mysql> select * from variable where name like 'node_options_image%';
+---------------------------+-------------------------------------------+
| name                      | value                                     |
+---------------------------+-------------------------------------------+
| node_options_image        | a:2:{i:0;s:6:"status";i:1;s:7:"promote";} |
| node_options_image_import | a:2:{i:0;s:6:"status";i:1;s:7:"promote";} |
+---------------------------+-------------------------------------------+
2 rows in set (0.00 sec)

| image_import_default_import_path | s:15:"image_import/%U";



                                                                           |
| image_import_default_upload_path | s:41:"/var/www/localhost/htdocs/image_import/%U";

Any pointers would be appreciated -- all other site functions seem to work properly.

Comments

#1

Note: site is online at https://www.felix.org

#2

Thanks for an outstanding bug report! You thought of all the questions I would have asked and have answered them already! This bug report should be published somewhere as an example. :-)

The error you are receiving is actually being reported by the file_copy() function from files.inc, part of Drupal core. Luckily my module calls file_copy() directly rather than through an intermediary, so we can trace what's being passed to this function as parameters.

I've just now committed a new version of image_import.module to CVS that adds one new debugging statement, immediately before the file_copy() call, reporting exactly what we're passing to that function.

Please retrieve image_import.module from CVS and update your installation, then try again, and let me take a look at your debug output. Also, please provide the output of an "ls -ld" command on both of the parameters that are shown in the file_copy() call line. The new debug lines will look like this:

DEBUG: Invoking file_copy('image_import/cake.jpg', 'files/images', FILE_EXISTS_RENAME)

So in this example what we would need is the output of

ls -ld image_import/cake.jpg files/images

The "ls" command would of course be run from your Drupal root directory.

Thanks!

Scott

#3

P.S. The new image_import.module is a drop-in replacement for the one you have; you won't need to re-run the other installation steps in this particular case, just copy the file over your existing image_import.module.

#4

Have downloaded the new CVS version and replaced it in my modules directory. Version number is:

// $Id: image_import.module,v 1.15 2005/10/11 14:42:30 syscrusher Exp $

Began the same process of import. Preview shows:

    * DEBUG MODE ENABLED for image_import_import() function. There will be extra messages issued.
    * DEBUG: Image file extensions: gif,GIF,jpg,JPG,jpeg,JPEG
    * DEBUG: Caption file extensions: html,HTML,htm,HTM,txt,TXT
    * DEBUG: Timestamp for file number 1 is 1129507324
    * DEBUG: Import called for path=image_import/robin/DSC_0110.JPG
    * DEBUG: Access checks succeeded for image_import/robin/DSC_0110.JPG
    * DEBUG: Title pattern is "%f".
    * DEBUG: Title is "DSC_0110.JPG".
    * DEBUG: Caption 0 characters, teaser 0 characters, for DSC_0110.JPG.
    * DEBUG: Image DSC_0110.JPG prechecks okay and should import successfully.
    * DEBUG: Timestamp for file number 2 is 1129507323
    * DEBUG: Import called for path=image_import/robin/DSC_0111.JPG
    * DEBUG: Access checks succeeded for image_import/robin/DSC_0111.JPG
    * DEBUG: Title pattern is "%f".
    * DEBUG: Title is "DSC_0111.JPG".
    * DEBUG: Caption 0 characters, teaser 0 characters, for DSC_0111.JPG.
    * DEBUG: Image DSC_0111.JPG prechecks okay and should import successfully.
    * DEBUG: Timestamp for file number 3 is 1129507322
    * DEBUG: Import called for path=image_import/robin/DSC_0112.JPG
    * DEBUG: Access checks succeeded for image_import/robin/DSC_0112.JPG
    * DEBUG: Title pattern is "%f".
    * DEBUG: Title is "DSC_0112.JPG".
    * DEBUG: Caption 0 characters, teaser 0 characters, for DSC_0112.JPG.
    * DEBUG: Image DSC_0112.JPG prechecks okay and should import successfully.
    * DEBUG: Timestamp for file number 4 is 1129507321
    * DEBUG: Import called for path=image_import/robin/DSC_0113.JPG
    * DEBUG: Access checks succeeded for image_import/robin/DSC_0113.JPG
    * DEBUG: Title pattern is "%f".
    * DEBUG: Title is "DSC_0113.JPG".
    * DEBUG: Caption 0 characters, teaser 0 characters, for DSC_0113.JPG.
    * DEBUG: Image DSC_0113.JPG prechecks okay and should import successfully.
    * DEBUG: Timestamp for file number 5 is 1129507320
    * DEBUG: Import called for path=image_import/robin/DSC_0114.JPG
    * DEBUG: Access checks succeeded for image_import/robin/DSC_0114.JPG
    * DEBUG: Title pattern is "%f".
    * DEBUG: Title is "DSC_0114.JPG".
    * DEBUG: Caption 0 characters, teaser 0 characters, for DSC_0114.JPG.
    * DEBUG: Image DSC_0114.JPG prechecks okay and should import successfully.
    * DEBUG: Timestamp for file number 6 is 1129507319
    * DEBUG: Import called for path=image_import/robin/DSC_0115.JPG
    * DEBUG: Access checks succeeded for image_import/robin/DSC_0115.JPG
    * DEBUG: Title pattern is "%f".
    * DEBUG: Title is "DSC_0115.JPG".
    * DEBUG: Caption 0 characters, teaser 0 characters, for DSC_0115.JPG.
    * DEBUG: Image DSC_0115.JPG prechecks okay and should import successfully.
    * DEBUG: Timestamp for file number 7 is 1129507318
    * DEBUG: Import called for path=image_import/robin/DSC_0116.JPG
    * DEBUG: Access checks succeeded for image_import/robin/DSC_0116.JPG
    * DEBUG: Title pattern is "%f".
    * DEBUG: Title is "DSC_0116.JPG".
    * DEBUG: Caption 0 characters, teaser 0 characters, for DSC_0116.JPG.
    * DEBUG: Image DSC_0116.JPG prechecks okay and should import successfully.
    * DEBUG: Timestamp for file number 8 is 1129507317
    * DEBUG: Import called for path=image_import/robin/DSC_0117.JPG
    * DEBUG: Access checks succeeded for image_import/robin/DSC_0117.JPG
    * DEBUG: Title pattern is "%f".
    * DEBUG: Title is "DSC_0117.JPG".
    * DEBUG: Caption 0 characters, teaser 0 characters, for DSC_0117.JPG.
    * DEBUG: Image DSC_0117.JPG prechecks okay and should import successfully.
    * DEBUG: Timestamp for file number 9 is 1129507316
    * DEBUG: Import called for path=image_import/robin/DSC_0118.JPG
    * DEBUG: Access checks succeeded for image_import/robin/DSC_0118.JPG
    * DEBUG: Title pattern is "%f".
    * DEBUG: Title is "DSC_0118.JPG".
    * DEBUG: Caption 0 characters, teaser 0 characters, for DSC_0118.JPG.
    * DEBUG: Image DSC_0118.JPG prechecks okay and should import successfully.
    * DEBUG: Timestamp for file number 10 is 1129507315
    * DEBUG: Import called for path=image_import/robin/DSC_0119.JPG
    * DEBUG: Access checks succeeded for image_import/robin/DSC_0119.JPG
    * DEBUG: Title pattern is "%f".
    * DEBUG: Title is "DSC_0119.JPG".
    * DEBUG: Caption 0 characters, teaser 0 characters, for DSC_0119.JPG.
    * DEBUG: Image DSC_0119.JPG prechecks okay and should import successfully.

Looks good so far. Now to import:

    * DEBUG MODE ENABLED for image_import_import() function. There will be extra messages issued.
    * DEBUG: Image file extensions: gif,GIF,jpg,JPG,jpeg,JPEG
    * DEBUG: Caption file extensions: html,HTML,htm,HTM,txt,TXT
    * DEBUG: Timestamp for file number 1 is 1129507366
    * DEBUG: Import called for path=image_import/robin/DSC_0110.JPG
    * DEBUG: Access checks succeeded for image_import/robin/DSC_0110.JPG
    * DEBUG: Title pattern is "%f".
    * DEBUG: Title is "DSC_0110.JPG".
    * DEBUG: Caption 0 characters, teaser 0 characters, for DSC_0110.JPG.
    * DEBUG: Image DSC_0110.JPG prechecks okay and should import successfully.
    * DEBUG: System image directory is 'var/www/localhost/files/images'.
    * DEBUG: Invoking file_copy('image_import/robin/DSC_0110.JPG', 'var/www/localhost/files/images', FILE_EXISTS_RENAME)
    * DEBUG: Timestamp for file number 2 is 1129507365
    * DEBUG: Import called for path=image_import/robin/DSC_0111.JPG
    * DEBUG: Access checks succeeded for image_import/robin/DSC_0111.JPG
    * DEBUG: Title pattern is "%f".
    * DEBUG: Title is "DSC_0111.JPG".
    * DEBUG: Caption 0 characters, teaser 0 characters, for DSC_0111.JPG.
    * DEBUG: Image DSC_0111.JPG prechecks okay and should import successfully.
    * DEBUG: System image directory is 'var/www/localhost/files/images'.
    * DEBUG: Invoking file_copy('image_import/robin/DSC_0111.JPG', 'var/www/localhost/files/images', FILE_EXISTS_RENAME)
    * DEBUG: Timestamp for file number 3 is 1129507364
    * DEBUG: Import called for path=image_import/robin/DSC_0112.JPG
    * DEBUG: Access checks succeeded for image_import/robin/DSC_0112.JPG
    * DEBUG: Title pattern is "%f".
    * DEBUG: Title is "DSC_0112.JPG".
    * DEBUG: Caption 0 characters, teaser 0 characters, for DSC_0112.JPG.
    * DEBUG: Image DSC_0112.JPG prechecks okay and should import successfully.
    * DEBUG: System image directory is 'var/www/localhost/files/images'.
    * DEBUG: Invoking file_copy('image_import/robin/DSC_0112.JPG', 'var/www/localhost/files/images', FILE_EXISTS_RENAME)
    * DEBUG: Timestamp for file number 4 is 1129507363
    * DEBUG: Import called for path=image_import/robin/DSC_0113.JPG
    * DEBUG: Access checks succeeded for image_import/robin/DSC_0113.JPG
    * DEBUG: Title pattern is "%f".
    * DEBUG: Title is "DSC_0113.JPG".
    * DEBUG: Caption 0 characters, teaser 0 characters, for DSC_0113.JPG.
    * DEBUG: Image DSC_0113.JPG prechecks okay and should import successfully.
    * DEBUG: System image directory is 'var/www/localhost/files/images'.
    * DEBUG: Invoking file_copy('image_import/robin/DSC_0113.JPG', 'var/www/localhost/files/images', FILE_EXISTS_RENAME)
    * DEBUG: Timestamp for file number 5 is 1129507362
    * DEBUG: Import called for path=image_import/robin/DSC_0114.JPG
    * DEBUG: Access checks succeeded for image_import/robin/DSC_0114.JPG
    * DEBUG: Title pattern is "%f".
    * DEBUG: Title is "DSC_0114.JPG".
    * DEBUG: Caption 0 characters, teaser 0 characters, for DSC_0114.JPG.
    * DEBUG: Image DSC_0114.JPG prechecks okay and should import successfully.
    * DEBUG: System image directory is 'var/www/localhost/files/images'.
    * DEBUG: Invoking file_copy('image_import/robin/DSC_0114.JPG', 'var/www/localhost/files/images', FILE_EXISTS_RENAME)
    * DEBUG: Timestamp for file number 6 is 1129507361
    * DEBUG: Import called for path=image_import/robin/DSC_0115.JPG
    * DEBUG: Access checks succeeded for image_import/robin/DSC_0115.JPG
    * DEBUG: Title pattern is "%f".
    * DEBUG: Title is "DSC_0115.JPG".
    * DEBUG: Caption 0 characters, teaser 0 characters, for DSC_0115.JPG.
    * DEBUG: Image DSC_0115.JPG prechecks okay and should import successfully.
    * DEBUG: System image directory is 'var/www/localhost/files/images'.
    * DEBUG: Invoking file_copy('image_import/robin/DSC_0115.JPG', 'var/www/localhost/files/images', FILE_EXISTS_RENAME)
    * DEBUG: Timestamp for file number 7 is 1129507360
    * DEBUG: Import called for path=image_import/robin/DSC_0116.JPG
    * DEBUG: Access checks succeeded for image_import/robin/DSC_0116.JPG
    * DEBUG: Title pattern is "%f".
    * DEBUG: Title is "DSC_0116.JPG".
    * DEBUG: Caption 0 characters, teaser 0 characters, for DSC_0116.JPG.
    * DEBUG: Image DSC_0116.JPG prechecks okay and should import successfully.
    * DEBUG: System image directory is 'var/www/localhost/files/images'.
    * DEBUG: Invoking file_copy('image_import/robin/DSC_0116.JPG', 'var/www/localhost/files/images', FILE_EXISTS_RENAME)
    * DEBUG: Timestamp for file number 8 is 1129507359
    * DEBUG: Import called for path=image_import/robin/DSC_0117.JPG
    * DEBUG: Access checks succeeded for image_import/robin/DSC_0117.JPG
    * DEBUG: Title pattern is "%f".
    * DEBUG: Title is "DSC_0117.JPG".
    * DEBUG: Caption 0 characters, teaser 0 characters, for DSC_0117.JPG.
    * DEBUG: Image DSC_0117.JPG prechecks okay and should import successfully.
    * DEBUG: System image directory is 'var/www/localhost/files/images'.
    * DEBUG: Invoking file_copy('image_import/robin/DSC_0117.JPG', 'var/www/localhost/files/images', FILE_EXISTS_RENAME)
    * DEBUG: Timestamp for file number 9 is 1129507358
    * DEBUG: Import called for path=image_import/robin/DSC_0118.JPG
    * DEBUG: Access checks succeeded for image_import/robin/DSC_0118.JPG
    * DEBUG: Title pattern is "%f".
    * DEBUG: Title is "DSC_0118.JPG".
    * DEBUG: Caption 0 characters, teaser 0 characters, for DSC_0118.JPG.
    * DEBUG: Image DSC_0118.JPG prechecks okay and should import successfully.
    * DEBUG: System image directory is 'var/www/localhost/files/images'.
    * DEBUG: Invoking file_copy('image_import/robin/DSC_0118.JPG', 'var/www/localhost/files/images', FILE_EXISTS_RENAME)
    * DEBUG: Timestamp for file number 10 is 1129507357
    * DEBUG: Import called for path=image_import/robin/DSC_0119.JPG
    * DEBUG: Access checks succeeded for image_import/robin/DSC_0119.JPG
    * DEBUG: Title pattern is "%f".
    * DEBUG: Title is "DSC_0119.JPG".
    * DEBUG: Caption 0 characters, teaser 0 characters, for DSC_0119.JPG.
    * DEBUG: Image DSC_0119.JPG prechecks okay and should import successfully.
    * DEBUG: System image directory is 'var/www/localhost/files/images'.
    * DEBUG: Invoking file_copy('image_import/robin/DSC_0119.JPG', 'var/www/localhost/files/images', FILE_EXISTS_RENAME)

As you can see, the copy is being directed to an unknown location relative to the drupal home directory:

var/www/localhost/files/images

As expected, the ls -ld command you requested shows:

abelard htdocs # ls -ld image_import/robin/DSC_0110.JPG var/www/localhost/files/images
ls: var/www/localhost/files/images: No such file or directory
-rwxrwxr-x  1 apache wheel 2738784 Oct  9 23:26 image_import/robin/DSC_0110.JPG

The question for me is where in the setup is this location being incorrectly specified relative to the drupal director rather than absolute to root, which would make it correct. I've checked the settings for image and for upload, and I've looked directly in the variables table in mysql but have not found this setting.

#5

Thanks to your additional debugging statement, I know that the images were being directed to a nonexistent directory relative to the drupal "files" directory. I found under the top-level "settings" page that my "files" parameter was set as an absolute directory relative to root:

/var/www/localhost/htdocs/files

That seemed logical to me, as the temporary directory was also set relative to root:

/tmp

It seems, though, that somewhere in the drupal logic, the initial slash was being removed, and the files were being directed to:

var/www/localhost/htdocs/files/images

rather than:

/var/www/localhost/htdocs/files/images

I'm not yet familiar enough with the top-level drupal logic to know where this error is happening, but I'd like to post the problem somewhere.

In the meantime, I've changed the files location to "files", and image_import is now working properly. Thanks for you help -- logical troubleshooting is always painful, but it works.

RF

#6

Title:Upload succeeds, but "File copy failed"» Problem identified: Public vs Private Filestore

The problem above is caused by the assignment of $image_dir in line 723:

function image_import_do_node(&$node, $path) {
//  $debug = variable_get('image_import_debug', 0);
$debug = 1;
  $image_dir = _image_import_get_image_path();

The _image_import_get_image_path function assumes a public filestore and returns a path relative to the drupal home directory. If a private filestore is used, it returns the absolute path minus its initial '/' which gets catenated incorrectly to the drupal home directory.

The problem in _image_import_get_image is the statement in line 773:

  $path = preg_replace('#^/#','',$path);

If a private filestore is used, it is not correct to remove the initial slash. I haven't tested it yet, but the following mod to _image_import_get_image should do the trick:

function _image_import_get_image_path() {
  $imgpath  = variable_get('image_default_path','');
  $filepath = variable_get('file_directory_path','');

  $path = $filepath . '/' . $imgpath;
  $path = preg_replace('#//#','',$path,-1);

// file_downloads value is 1 for public, 2 for private
  $dl_type = variable_get('file_downloads','');
  if ($dl_type<>2) {
        $path = preg_replace('#^/#','',$path);
  }

  $path = preg_replace('#/$#','',$path);
  return $path;
}

#7

That fixed this same problem for me. Thanks.

#8

Category:support request» bug report
Assigned to:Anonymous» syscrusher
Status:active» fixed

Great work, folks. I've committed the patch, kindly provided by rxfelix, to HEAD and to DRUPAL-4-6 branches. It should be in the download page by tomorrow, if all goes well.

Thanks for the debugging help. I don't have any sites using public filestore, and didn't realize the leading slash was handled differently. This is why the Open Source community process works so well. I appreciate your contribution, both in finding the bug and in fixing it.

Scott

#9

Status:fixed» closed (fixed)
nobody click here