I'm using XAMPP and Drupal in a subdirectory. When enabling the filenode and services module, defining an endpoint and enabling file retrieve, the module relies on $_SERVER['DOCUMENT_ROOT'] for reading the underlying file. In my setup, its value does not contain the subfolder for drupal, so the file path is incorrect and leads to the error message:

fopen(/Applications/XAMPP/xamppfiles/htdocs/sites/default/files/ladung30.pdf) [<a href='function.fopen'>function.fopen</a>]: failed to open stream: No such file or directory in /Applications/XAMPP/xamppfiles/htdocs/drupal/sites/all/modules/services/resources/file_resource.inc on line 265.

The attached patch was already discussed here for drupal itself. It adds a new function to retrieve the path and corrects the "file resource" file.

CommentFileSizeAuthor
#4 1405202-file-getcwd-4.patch775 bytescotto
patch.diff2.21 KBerikwegner

Comments

marcingy’s picture

Status: Active » Needs review

Reading the patch and it makes sense but....I would ask the question if this issue should be fixed in core itself. I have no problem looking to commit this as a work around but it just feels kind of wrong to fix it at a module level rather than a core level.

I'll wait for Kylebrowning to weigh in. Marking as needs review to get some eyes.

Status: Needs review » Needs work

The last submitted patch, patch.diff, failed testing.

cotto’s picture

Assigned: Unassigned » cotto
cotto’s picture

StatusFileSize
new775 bytes

Here's a simpler patch that solves the problem for me.

cotto’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 1405202-file-getcwd-4.patch, failed testing.

kylebrowning’s picture

Status: Needs work » Reviewed & tested by the community

This looks great.

cotto’s picture

Status: Reviewed & tested by the community » Fixed

This issue should be fixed now. Thanks for reporting.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.