Hi,
This is the same bug as the 2559429, but it occurs when the drupal multi-languages is enabled.
To reproduce :
- Install fresh Drupal 7 and configure default file download method as 'Private local files served by Drupal'. Private file system path: sites/default/files/private.
- Tune your front web-server properly. For nginx it's:
location ^~ /sites/default/files/private/ { internal; } - Configure some module that manages private files access rights. I use this one: https://www.drupal.org/project/private_files_download_permission. Configure it so that the root private files path (sites/default/files/private/) be accessible for e.g. admin.
- Download and enable UC:
drush dl ultimate_cron && drush en -y ultimate_cron - Enable Locale module
- Add a new language (for example French) : admin/config/regional/language/add : Select 'French' and click "Add language"
- Configure language detection method : admin/config/regional/language/configure : Enable URL method (Determine the language from the URL (Path prefix or domain)) and click "Save settings"
- Configure part of the URL that determines language : admin/config/regional/language/configure/url : Choose "Path prefix" and click "Save configuration"
- Go to your private directory and create a dummy file:
cd <Drupal_Root>/sites/default/files/private/; dd if=/dev/zero of=test400.dat bs=1M count=400 - Try to download (as an admin) with url : http://your-site/system/files/test400.dat => Download OK
- Try to download (as an admin) with url : http://your-site/fr/system/files/test400.dat => Download KO with PHP error :
PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 132136960 bytes) in /var/www/drupal/includes/file.inc on line 1994
When multi-languages is enabled file_create_url() method with private file return an URI with current language prefix.
For example: if current language is french, file_create_url('private://test400.dat'); return an URI like fr/system/files/test400.dat.
So when :
- a module uses
file_create_url() - private files are used
- multi-languages is enabled
- downloaded file size exceeds the memory limit
the issue occurs.
Aurélien
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | private_file_system_is-2998782-1.patch | 502 bytes | aurm |
Comments
Comment #2
aurm commentedAs you can see in the patch, to fix the bug (and in agreement with the fix for issue 2559429), we propose to modify the regular expression that detects the call to system/files in ultimate_cron.poorman.inc.
Comment #3
aurm commentedComment #4
aurm commentedComment #5
ahmed_h commentedThe fix provided by aurm is feasible. Please review.
Comment #6
ahmed_h commentedThe fix provided by aurm is feasible. Please review.
Comment #8
arnested commentedThank you for your contribution.
I have committed your page.
In a perfect world I would have prefered if we could do a more precise check for private files, but this is fine and since a false positive will just result in poormans cron not being run on that particular path we are way better off with your patch than without.
Thanks again and sorry for the delay.