breaks swfobject and gzip outside basedir
morningtime - June 1, 2009 - 00:04
| Project: | Javascript Aggregator |
| Version: | 6.x-1.2 |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | closed |
Description
OK Im experiencing two bugs:
- minified breaks swfobject (movies not loading, swfobject... gone?)
- gzipping tries to store files in /js/..., I mean outside the root/basedir, see below
warning: file_exists() [function.file-exists]: open_basedir restriction in effect. File(/js/fee3214e4e9b2438fcb68175b0ba0572.jsmin.js.gz) is not within the allowed path(s): (/var/www/vhosts/xxx.com/httpdocs:/tmp) in /var/www/vhosts/xxx.com/httpdocs/sites/all/modules/javascript_aggregator/javascript_aggregator.module on line 104.
So I cant use either function...

#1
Drupal core optimize javascript also breaks swfobject, so thats one down. But its still strange the gzip function tries to put files outside server root.
#2
I was able to solve the problem by changing:
if (!file_exists($jsmin_file .'.gz')) {file_save_data(gzencode($contents, 9), $jsmin_file .'.gz', FILE_EXISTS_REPLACE);
}
to
if (!file_exists($_SERVER['DOCUMENT_ROOT'] . $path . $jsmin_file .'.gz')) {file_save_data(gzencode($contents, 9), $_SERVER['DOCUMENT_ROOT'] . $path . $jsmin_file .'.gz', FILE_EXISTS_REPLACE);
}
So by adding $_SERVER['DOCUMENT_ROOT'] . $path in front of $jsmin_file. That seems to be necessary to get the real absolute path to the files. Otherwise I get drupal error messages about open basedir restrictions (because '/js/' is outside the server root, it should be '/var/www/vhosts/xxx.com/httpdocs/sites/default/files/js').
Anyone know why? Is it only me? Strange stuff. Because it does work with the errors, js files are put in the right place. So why the error messages?
#3
I am having the exact same error with the gzip function. It would probably be good to change the title and make a separate issue for the swfobject issue unless the two are related.
#4
Check this patch. Its exactly what mxistence suggested.
If you try this patch please give feedback!
#5
I'm using different ISP, and this problem says vaguely that:
* The selected file /tmp/filePG1ig9 could not be uploaded, because the destination is not properly configured.
* The selected file /tmp/filexotyGh could not be uploaded, because the destination is not properly configured.
Says it twice. The patch did not work for me, nor previous the solutions provided in duplicate thread.
This merits higher priority.
#6
Patch at http://drupal.org/node/482002
works for 1.2
#7