CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • 4.5.3 failed to open stream: No such file or directory Smarty.class.php:1264
Pages: [1]

Author Topic: 4.5.3 failed to open stream: No such file or directory Smarty.class.php:1264  (Read 489 times)

ken

  • I live on this forum
  • *****
  • Posts: 916
  • Karma: 53
    • City Bible Forum
  • CiviCRM version: 4.6.3
  • CMS version: Drupal 7.36
  • MySQL version: 5.5.41
  • PHP version: 5.3.10
4.5.3 failed to open stream: No such file or directory Smarty.class.php:1264
November 17, 2014, 02:50:02 am
Since upgrading to CiviCRM 4.5.3 I've seen messages like the following in my logs ...

Quote
include(/var/www/drupal/sites/default/files/civicrm/templates_c/en_US//%%EC/ECC/ECCA13B3%%1416194583410931235.php):  [warning]
failed to open stream: No such file or directory
Smarty.class.php:1264
include(): Failed opening                                              [warning]
'/var/www/drupal/sites/default/files/civicrm/templates_c/en_US//%%EC/ECC/ECCA13B3%%1416194583410931235.php'
for inclusion
(include_path='[redacted]')
Smarty.class.php:1264

Here's what's going on ...
  • In my Drupal install files are owned by 'user' and the group is 'www-data'
  • 'user' is a member of group 'www-data'
  • Only 'user' has write access, except for files under /var/www/drupal/sites/default/files where 'www-data' also has access
  • So file ownership is user:www-data and permissions are 640 except under 'files' where permissions are 660
  • Directory ownership is user:www-data and permissions are 750 except under 'files' where permissions are 770
  • The idea is to restrict the web browser's ability to modify files, while giving 'user' write access
  • 'user' runs the Drupal cron job using drush, but most processing is done by 'www-data'
  • Smarty creates template files with ownership www-data:www-data and the directory permissions are 751 and the file permissions are 644
  • The problem is that the Drush jobs run by 'user' can't write to those directories
  • Smarty creates directories at /packages/Smarty/internals/core.create_dir_structure.php on line 68 which has a call to mkdir($_new_dir, $smarty->_dir_perms)
  • _dir_perms is 0771 but because the umask is 0022 the directories get created with 751

The following patch resolves the issue for me ...

Code: [Select]
--- ./packages/Smarty/internals/core.create_dir_structure.php 2014-11-06 06:47:04.000000000 +1100
+++ /var/www/citybibleforum/sites/all/modules/civicrm/packages/Smarty/internals/core.create_dir_structure.php 2014-11-17 21:40:13.863912712 +110
0
@@ -65,7 +65,7 @@
                 $_make_new_dir = true;
             }
 
-            if ($_make_new_dir && !file_exists($_new_dir) && !@mkdir($_new_dir, $smarty->_dir_perms) && !is_dir($_new_dir)) {
+            if ($_make_new_dir && !file_exists($_new_dir) && (!@mkdir($_new_dir) || !@chmod($_new_dir, 0775)) && !is_dir($_new_dir)) {
                 $smarty->trigger_error("problem creating directory '" . $_new_dir . "'");
                 return false;
             }

What this change does is ensure the file has the permissions I want, irrespective of the umask. I don't understand why this only became an issue with 4.5.3 but I'm posting it here in case others find it helpful.
« Last Edit: November 17, 2014, 01:28:05 pm by ken »

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • 4.5.3 failed to open stream: No such file or directory Smarty.class.php:1264

This forum was archived on 2017-11-26.