Fixed Forced Web upgrade after CLI upgrade. file_put_contents error

Marcus

Well-known member
1. web upgrade: message "board is too large, please do a cli upgrade"
2. immediately did cli upgrade
3. after finishing, domain.com/admin.php told me to still do a web upgrade. domain.com was not accessible

Then I get this error message
file_put_contents(xxx/public/internal_data/templates/S.42,L.5,account_external_accounts.php): failed to open stream: Permission denied

  1. XenForo_Application::handlePhpError()
  2. file_put_contents() in XenForo/Template/FileHandler.php at line 95
  3. XenForo_Template_FileHandler->_saveTemplate() in XenForo/Template/FileHandler.php at line 50
  4. XenForo_Template_FileHandler::save() in XenForo/Model/Template.php at line 1694
  5. XenForo_Model_Template->_insertCompiledTemplateRecord() in XenForo/Model/Template.php at line 1469
  6. XenForo_Model_Template->compileTemplateInStyleTree() in XenForo/Model/Template.php at line 1328
  7. XenForo_Model_Template->compileNamedTemplateInStyleTree() in XenForo/Model/Template.php at line 1267
  8. XenForo_Model_Template->compileAllTemplates() in XenForo/Deferred/Template.php at line 36
  9. XenForo_Deferred_Template->execute() in XenForo/Deferred/Atomic.php at line 66
  10. XenForo_Deferred_Atomic->execute() in XenForo/Model/Deferred.php at line 252
  11. XenForo_Model_Deferred->runDeferred() in XenForo/Model/Deferred.php at line 378
  12. XenForo_Model_Deferred->_runInternal() in XenForo/Model/Deferred.php at line 312
  13. XenForo_Model_Deferred->runByUniqueKey() in XenForo/Install/Controller/Abstract.php at line 34
  14. XenForo_Install_Controller_Abstract->_manualDeferredRunner() in XenForo/Install/Controller/Upgrade.php at line 221
  15. XenForo_Install_Controller_Upgrade->actionRunDeferred() in XenForo/FrontController.php at line 347
  16. XenForo_FrontController->dispatch() in XenForo/FrontController.php at line 134
  17. XenForo_FrontController->run() in xxx/public/install/index.php at line 18
 
I got a similar error after importing a new language. It worked after disabling public templates. I activated public templates after the import without any issues.
 
I has similar error before. Basically some files in the template directory were associated to a different owner on the server than the server user. I have not idea how that happened since I'm on a VPS, but it did. Changing the permissions of these files, solved my problem and I could proceed with my upgrade.
You can also try to check the CHMOD of /internal_data and its directories/files.
 
If your using nginx/centminmod.
You can run this command to fix it: chown -R nginx:nginx /home/nginx/domain/yoursite.com/public/
 
Last edited:
I'm more interested in why it told you to do a web upgrade. It sounds like the upgrade didn't actually complete via the CLI.

This is a tricky issue. In the past, we just 0777'd files that needed to be written by the web server, but that wasn't ideal, so we flipped to a detection-based system. The problem is then when you run the program as another user and the detection system gives different results -- or more significantly, it writes something that you can write but the webserver can't.

We actually have code that tries to detect this case, but it does require the posix_getuid() function (it would normally be available). The other case is when you explicitly set chmodWritableValue in config.php. Have you set that?
 
The CLI told me the update was finished. I guess the update was not, the same error happened like in the web upgrade process. As the upgrade was not finished, the web upgrade had to run.

I have not set the chmodWriteableValue in xenforos configuration.

My webserver is nginx, and while the public www web server directory is owned by nginx, all files within including the subdirectories are owned by root. I have changed ownership of all files now to the web server.

phpinfo gives me a posix entry with one single "Revision" entry. I don't have a posix entry in php.ini. It's possible to disable functions in php, but I do not know where they are disabled.
 
The CLI told me the update was finished. I guess the update was not, the same error happened like in the web upgrade process. As the upgrade was not finished, the web upgrade had to run.

I have not set the chmodWriteableValue in xenforos configuration.

My webserver is nginx, and while the public www web server directory is owned by nginx, all files within including the subdirectories are owned by root. I have changed ownership of all files now to the web server.

phpinfo gives me a posix entry with one single "Revision" entry. I don't have a posix entry in php.ini. It's possible to disable functions in php, but I do not know where they are disabled.
Are you using CentminMod?
I upgraded mine fine using the cli upgrade with root user.
After the upgrade is done, I just run "chown -R nginx:nginx /domain/public/"
 
What user did you run the upgrade as?
I run the upgrade as root.

1. downloaded xenforo zip file from xf.com
2. copied it to the server
3. logged in as root and unzipped it. copied it to the web directory. all files were owned by root
4. run the www upgrade, after the message
5. run the cli upgrade as root
 
After the upgrade is done, I just run "chown -R nginx:nginx /domain/public/"

Yes, I did the same after the upgrade. Next time I do it after copying the files to the web directory and before the upgrade process starts.

And check if nginx is running as user "nobody". Default compile, that's who the user is.

I added the line user nginx; in the nginx configuration files.
 
Running as root should always chmod the files to 0777. However, I have found that here we don't actually have the posix functions available, so it may be common in distros. I've added a workaround for that case -- I think that may be the cause.

Alternatively (and possibly recommended) would be to run the CLI upgrade as the same user that your forum will run as (varies depending on server setups).
 
Top Bottom