Hi,

I keep getting these messages to my dblog and I think that is not normal...

The error message is:

file_exists() [function.file-exists]: open_basedir restriction in effect. File(/js/e8fe2cb7e9cde7487f544efef96c68c9.jsmin.js.gz) is not within the allowed path(s): (/srv/hosts/drupal6/) - /srv/hosts/drupal6/docs/sites/all/modules/javascript_aggregator/javascript_aggregator.module - line 104

After this I can find another:

realpath() [function.realpath]: Unable to access /js/e8fe2cb7e9cde7487f544efef96c68c9.jsmin.js.gz - /srv/hosts/drupal6/docs/includes/file.inc - line 182

I watched the code and think that the 'files' directory is not properly get and that's why it says '/js/.....' against 'sites/teecee.hu/files/js/....'. The file is in the proper place.
The site is working and so does the JS minified file!
Please note that I have set the correct paths in the 'filesystem' page!

Do you have any idea about how to solve this?

Thanks, BYE:
TeeCee, alias Tamas Szugyi :o)

Comments

threading_signals’s picture

Last Edit: within the .module file, replace line 104 with: if (!file_exists(file_directory_path() . $jsmin_file .'.gz')) {

Difference of file_directory_path() I think fixed it. Will leave another comment if that is false.

Edit: Skip to second comment.

I'm getting same error.

warning: file_exists() [function.file-exists]: open_basedir restriction in effect. File(/js/16b691d3e390f15669573434224ab.jsmin.js.gz) is not within the allowed path(s): (/var/www/myaccount/data:.) in /var/www/myaccount/data/www/example.com/sites/all/modules/javascript_aggregator/javascript_aggregator.module on line 104.

From the looks of it, it does not seem to be a syntax issue: (/var/www/myaccount/data:.) where teecee doesn't have the semicolon or period. (I haven't formally learned the syntax yet, I don't know if that's for apache or php.)

From research, when I go to Administer > Site Configuration > File System it does not like my attempts. By default, sites/default/files is there, so I'm not sure if it is having a relative path problem due to two www/ in the path?

If this module used the default or user configured drupal tmp path as set by File System, that would be the quickest fix right?

Alternatively php.ini seems to be another way to fix it for some.

threading_signals’s picture

There's also the matter of public_html folder which could cause issues?

Edit: This seems to be a common design problem for many configurations, modules, and not drupal or this module specific.

If drupal is installed, then modules should have a relative path which shouldn't be within the root folder, due to security issues, but perhaps recommended practice is that they have access within their module folder only? Makes me wonder what the performance penalty for long path names are. I'm struggling to understand this problem in particular for some reason. It's my first week.. ^_^

Previous patch dealt with this issue:

http://drupal.org/node/344131 but the problem has resurfaced?

This weblink gave me some clues to the problem after I noticed that this module uses .htaccess files:

http://www.shaw.ca/en-ca/CustomerCare/InternetSupport/Business/WebSpace/...

Drupal has "sites/default/files" as the relative directory when you look in Administer > Site Configuration > File System

and after using the locate command in CentOS shell prompt, there were four directories where the file was found.

Previous patch linked above may have fixed it for a portion of the code, but this version may have code using htaccess that may cause the path configuration to be broken again for VPS and shared solutions.

Tried to correct the code, but I don't have enough expertise.

open_basedir restriction in effect doesn't seem to be the main problem. drupal seems to be giving a reflexive error message because it is not finding the file where it thinks it is?

It is looking in root when the file is within the module js folder it seems?

Also, adjusting path in File System breaks themes thus you have to disable the CSS cache in Administer > Site Configuration > Performance which is unacceptable for the purpose of this module, so this module has to get the correct path by itself.

derjochenmeyer’s picture

Also, adjusting path in File System breaks themes thus you have to disable the CSS cache in Administer > Site Configuration > Performance which is unacceptable for the purpose of this module, so this module has to get the correct path by itself.

Did you mean CSS cache? This module minifies JS files.

threading_signals’s picture

I understand.

The purpose of this module is to enhance performance, not break anything. ^_^

Also, the above inclusion of code works. No error messages now.

tjerkameel’s picture

Just changing line 104 didn't work for me, I had replace '$jsmin_file' to '$jsmin_file_path' in both line 104 and 105.

if (!file_exists($jsmin_file_path .'.gz')) {
file_save_data(gzencode($contents, 9), $jsmin_file_path .'.gz', FILE_EXISTS_REPLACE);
}

derjochenmeyer’s picture

Status: Active » Closed (duplicate)
h_dries’s picture

Version: 6.x-1.2 » 6.x-1.4

fix #5 still seems necessary in 6.x-1.4, except you can now find it on line 126
clear your caches after you changed it

mvalverde’s picture

Title: open_basedir restriction on javascript_aggregator.module line 104 and 182 » open_basedir restriction on javascript_aggregator.module line 135 and 136

... problem still remains with verison 6.x-1.5. now the replacement has to be done in lines 135 & 135 $jsmin_file_name against $jsmin_file_path

// Create the GZip file if it doesn't already exist.
if (!file_exists($jsmin_file_path .'.gz')) {
file_save_data(gzencode($contents, 9), $jsmin_file_path .'.gz', FILE_EXISTS_REPLACE);
}

Marco Valverde
www.explido-software.de

derjochenmeyer’s picture

This is a duplicate of #936588: open_basedir restriction in effect or vice versa.

Please test the patch in the issue mentioned above. If it solves the problem I'll commit it to dev.

Thanks for reporting this.