Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

After upgrade from 2.6 to 3.1.x cannot write templates_c

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Installation and Setup
View previous topic :: View next topic  
Author Message
jguerra
Smarty Rookie


Joined: 15 Mar 2017
Posts: 6

PostPosted: Wed Mar 15, 2017 6:37 pm    Post subject: After upgrade from 2.6 to 3.1.x cannot write templates_c Reply with quote

Upgrading to support PHP 7. Setup new Smarty into same as old Smarty location. Repositories that contain templates being used are unchaged. templates_c folder under repository is setup chmod 777. Whole site at this point is chmod 777. Still get error:


Fatal error: Uncaught --> Smarty: unable to write file /var/www/html/africa.xxx.com/smarty_templates/templates_c/4e/5f/e3/wrt58c9895a03b275_90087900 <-- thrown in /var/www/html/smarty/libs/sysplugins/smarty_internal_runtime_writefile.php on line 49

Ran the Smarty installation test:
Smarty Installation test...
Testing template directory...
/var/www/html/africa.xxx.com/smarty_templates/templates is OK.
Testing compile directory...
FAILED: /var/www/html/africa.xxx.com/smarty_templates/templates_c is not writable.
Testing plugins directory...
/var/www/html/smarty/libs/plugins is OK.
Testing cache directory...
FAILED: /var/www/html/africa.xxx.com/smarty_templates/cache is not writable.
Testing configs directory...
/var/www/html/africa.xxx.com/configs/ is OK.
Testing sysplugin files...
... OK
Testing plugin files...
... OK
Tests complete.


Why does Smarty believe these folders to be not writable? I setup a test.php from within the same folder and was able to write to the templates_c folder without a problem. I have been working on this for 2 days now and have tried everything I can think of.. HELP!?
Back to top
View user's profile Send private message
jguerra
Smarty Rookie


Joined: 15 Mar 2017
Posts: 6

PostPosted: Wed Mar 15, 2017 8:07 pm    Post subject: update -- still not working Reply with quote

Set folders to 777 . still get the same error.

Tested, logged in as a nobody user -- can write to that folder. Smarty still thinks it cannot.
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Wed Mar 15, 2017 9:48 pm    Post subject: Reply with quote

Please restore correct permissions and check your setup and PHP logs more carefully.
Back to top
View user's profile Send private message
jguerra
Smarty Rookie


Joined: 15 Mar 2017
Posts: 6

PostPosted: Thu Mar 16, 2017 1:36 pm    Post subject: setup and php logs Reply with quote

To which logs are you referring? I would imagine that smarty reporting that it is unable to write to the folder means the failure lies within that initialization function.

The php error logs are empty. is there a separate "setup log" somewhere? I just dropped the new smarty in, is there something I missed? I didnt see any "setup" documentation for upgrading smarty.

I did some debugging inside of sysplugins/smarty_internal_runtime_writefile.php and it appears that file_put_contents is returning false, but $file_contents is empty, so I am unsure of what it is actually trying to put. Maybe it is failing to retrieve the Content from the database and so is thinking it's a failed write?

Thanks for the reply. I am new to smarty. I find it very strange that our old smarty 2.6.20 works fine but as soon as I upgrade smarty now suddenly there are fatal errors and none of our sites will work. I have at least 8 websites that use smarty and they all exhibit the same behavior. I was hoping for some suggestions on debugging this.
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Thu Mar 16, 2017 5:12 pm    Post subject: Reply with quote

If your PHP logs are empty, enable logging.
Back to top
View user's profile Send private message
jguerra
Smarty Rookie


Joined: 15 Mar 2017
Posts: 6

PostPosted: Thu Mar 16, 2017 8:56 pm    Post subject: still broken Reply with quote

This is the bane of open source software. when the community is not active, you have no recourse. I didn't mean the log was literally empty, just that the only php error is the error that I already displayed in my original post.

I was hoping someone had a similar problem where a folder that it writeable by the webserver user in linux was still throwing an error from smarty class saying that smarty could not write to the folder.

"check log files more thoroughly" .. is that really the best the whole community here has to offer? I guess it's time to get rid of smarty.

At least "AnrDaemon" responded, as mindless and unhelpful as the responds were.
Back to top
View user's profile Send private message
AnrDaemon
Administrator


Joined: 03 Dec 2012
Posts: 1785

PostPosted: Fri Mar 17, 2017 11:54 am    Post subject: Reply with quote

Debugging YOUR applications is YOUR responsibility.
Trying to place the blame on somebody else's shoulders is not going to work.
Back to top
View user's profile Send private message
jguerra
Smarty Rookie


Joined: 15 Mar 2017
Posts: 6

PostPosted: Wed Mar 22, 2017 5:36 pm    Post subject: Resolved!!! Reply with quote

Ok, well strictly speaking not a Smarty, issue, but it is very relevant to anyone who is running Smarty under Linux.

I learned about something called SELinux aka Security Enhanced Linux - This was enabled on our servers, unbeknownst to me. I was able to resolve the problem by executing:
chcon -t httpd_sys_rw_content_t "templates_c" from within the smarty_templates folder. I also did cache and templates.. alternately, if it's your machine, you could disable SELinux entirely, though that may not be ideal.

http://stackoverflow.com/questions/5417610/php-cant-open-or-write-file-despite-777-permisions
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Installation and Setup All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP