XF 2.1 SOLVED! Error trying to do manual upgrade from 2.1.8 PL1 to 2.1.8 PL2

djbaxter

Well-known member
I'm getting this:

Code:
ErrorException: [E_WARNING] file_put_contents(/home/politics/public_html/internal_data/code_cache/templates/l1/s0/public/_media_site_embed_applemusic.php): failed to open stream: Permission denied in src/vendor/league/flysystem/src/Adapter/Local.php at line 199

    XF::handlePhpError()
    file_put_contents() in src/vendor/league/flysystem/src/Adapter/Local.php at line 199
    League\Flysystem\Adapter\Local->update() in src/vendor/league/flysystem/src/Filesystem.php at line 99
    League\Flysystem\Filesystem->put()
    call_user_func_array() in src/vendor/league/flysystem-eventable-filesystem/src/EventableFilesystem.php at line 431
    League\Flysystem\EventableFilesystem\EventableFilesystem->callFilesystemMethod() in src/vendor/league/flysystem-eventable-filesystem/src/EventableFilesystem.php at line 395
    League\Flysystem\EventableFilesystem\EventableFilesystem->delegateMethodCall() in src/vendor/league/flysystem-eventable-filesystem/src/EventableFilesystem.php at line 57
    League\Flysystem\EventableFilesystem\EventableFilesystem->put() in src/vendor/league/flysystem/src/MountManager.php at line 595
    League\Flysystem\MountManager->put() in src/XF/Util/File.php at line 197
    XF\Util\File::writeToAbstractedPath() in src/XF/Service/Template/Compile.php at line 146
    XF\Service\Template\Compile->writeCompiled() in src/XF/Service/Template/Compile.php at line 43
    XF\Service\Template\Compile->recompile() in src/XF/Entity/Template.php at line 433
    XF\Entity\Template->_postSave() in src/XF/Mvc/Entity/Entity.php at line 1219
    XF\Mvc\Entity\Entity->save() in src/XF/Mvc/Entity/Entity.php at line 1213
    XF\Mvc\Entity\Entity->save() in src/XF/AddOn/DataType/BbCodeMediaSite.php at line 85
    XF\AddOn\DataType\BbCodeMediaSite->importAddOnData() in src/XF/Job/AddOnData.php at line 106
    XF\Job\AddOnData->run() in src/XF/Job/Atomic.php at line 38
    XF\Job\Atomic->run() in src/XF/Job/Manager.php at line 253
    XF\Job\Manager->runJobInternal() in src/XF/Job/Manager.php at line 195
    XF\Job\Manager->runJobEntry() in src/XF/Job/Manager.php at line 146
    XF\Job\Manager->runUnique() in src/XF/Install/Controller/AbstractController.php at line 24
    XF\Install\Controller\AbstractController->manualJobRunner() in src/XF/Install/Controller/Upgrade.php at line 257
    XF\Install\Controller\Upgrade->actionRunJob() in src/XF/Mvc/Dispatcher.php at line 350
    XF\Mvc\Dispatcher->dispatchClass() in src/XF/Mvc/Dispatcher.php at line 257
    XF\Mvc\Dispatcher->dispatchFromMatch() in src/XF/Mvc/Dispatcher.php at line 113
    XF\Mvc\Dispatcher->dispatchLoop() in src/XF/Mvc/Dispatcher.php at line 55
    XF\Mvc\Dispatcher->run() in src/XF/App.php at line 2184
    XF\App->run() in src/XF.php at line 391
    XF::runApp() in install/index.php at line 14
 

djbaxter

Well-known member
I reuploaded via FTP as user, not root, but I'm getting the same error:

Code:
ErrorException: [E_WARNING] file_put_contents(/home/politics/public_html/internal_data/code_cache/templates/l1/s0/public/_media_site_embed_applemusic.php): failed to open stream: Permission denied in src/vendor/league/flysystem/src/Adapter/Local.php at line 199

    XF::handlePhpError()
    file_put_contents() in src/vendor/league/flysystem/src/Adapter/Local.php at line 199
    League\Flysystem\Adapter\Local->update() in src/vendor/league/flysystem/src/Filesystem.php at line 99
    League\Flysystem\Filesystem->put()
    call_user_func_array() in src/vendor/league/flysystem-eventable-filesystem/src/EventableFilesystem.php at line 431
    League\Flysystem\EventableFilesystem\EventableFilesystem->callFilesystemMethod() in src/vendor/league/flysystem-eventable-filesystem/src/EventableFilesystem.php at line 395
    League\Flysystem\EventableFilesystem\EventableFilesystem->delegateMethodCall() in src/vendor/league/flysystem-eventable-filesystem/src/EventableFilesystem.php at line 57
    League\Flysystem\EventableFilesystem\EventableFilesystem->put() in src/vendor/league/flysystem/src/MountManager.php at line 595
    League\Flysystem\MountManager->put() in src/XF/Util/File.php at line 197
    XF\Util\File::writeToAbstractedPath() in src/XF/Service/Template/Compile.php at line 146
    XF\Service\Template\Compile->writeCompiled() in src/XF/Service/Template/Compile.php at line 43
    XF\Service\Template\Compile->recompile() in src/XF/Entity/Template.php at line 433
    XF\Entity\Template->_postSave() in src/XF/Mvc/Entity/Entity.php at line 1219
    XF\Mvc\Entity\Entity->save() in src/XF/Mvc/Entity/Entity.php at line 1213
    XF\Mvc\Entity\Entity->save() in src/XF/AddOn/DataType/BbCodeMediaSite.php at line 85
    XF\AddOn\DataType\BbCodeMediaSite->importAddOnData() in src/XF/Job/AddOnData.php at line 106
    XF\Job\AddOnData->run() in src/XF/Job/Atomic.php at line 38
    XF\Job\Atomic->run() in src/XF/Job/Manager.php at line 253
    XF\Job\Manager->runJobInternal() in src/XF/Job/Manager.php at line 195
    XF\Job\Manager->runJobEntry() in src/XF/Job/Manager.php at line 146
    XF\Job\Manager->runUnique() in src/XF/Install/Controller/AbstractController.php at line 24
    XF\Install\Controller\AbstractController->manualJobRunner() in src/XF/Install/Controller/Upgrade.php at line 257
    XF\Install\Controller\Upgrade->actionRunJob() in src/XF/Mvc/Dispatcher.php at line 350
    XF\Mvc\Dispatcher->dispatchClass() in src/XF/Mvc/Dispatcher.php at line 257
    XF\Mvc\Dispatcher->dispatchFromMatch() in src/XF/Mvc/Dispatcher.php at line 113
    XF\Mvc\Dispatcher->dispatchLoop() in src/XF/Mvc/Dispatcher.php at line 55
    XF\Mvc\Dispatcher->run() in src/XF/App.php at line 2184
    XF\App->run() in src/XF.php at line 391
    XF::runApp() in install/index.php at line 14
 

gerryvz

Well-known member
Hi @djbaxter

This same issue stumped me for many months, until I decided I was going to solve it. And I did. I had to use chown but finally got it licked, with a nudge from @AndyB.

I posted about it here:


And here:

 

djbaxter

Well-known member
Permissions are 0777 recursively for internal_data and all subdirectories.
Permissions are 0644 for files.

@gerryvz that may or may not have been the problem previously but right now I am stuck with 2.1.8 PL2 files uploaded to the site and those errors trying to do the actual upgrade.

I'm going to try to upload all the 2.1.8 PL1 files now and see if I can get out of this loop. :(
 

Mike

XenForo developer
Staff member
If your file ownership is wrong -- and it sounds like it is -- 0644 won't work. You'd either need to 0666 all of the files (or chown them to the PHP user).

They need to be writable as the user PHP is running as. We don't really know who that is in your scenario as there are two distinct cases (a generic user, usually the web server user, or a "real" user, usually the same you'd FTP in as; cPanel generally works as the later), so that may change your approach.
 

gerryvz

Well-known member
@Mike

How do I find out who is the PHP user?
Generally speaking, the php user is going to be the same as the apache user is running as.

You can create this php file and run it to determine, for sure:

Code:
<?php
    print shell_exec( 'whoami' );
?>

If using Apache, you can also enter this from the command line:

more /etc/apache2/envvars

And in the results, look for the user in these two lines (this is the result for my system):

Screen Shot 2020-03-20 at 10.57.45 AM.jpg

In my case, you can see that it is www-data (I am on Ubuntu 18.04.3, running apache).

It's highly unlikely that (if using apache) that php is running as ANYTHING OTHER THAN www-data or apache.
 
Last edited:

gerryvz

Well-known member
If your file ownership is wrong -- and it sounds like it is -- 0644 won't work. You'd either need to 0666 all of the files (or chown them to the PHP user).

They need to be writable as the user PHP is running as. We don't really know who that is in your scenario as there are two distinct cases (a generic user, usually the web server user, or a "real" user, usually the same you'd FTP in as; cPanel generally works as the later), so that may change your approach.
@Mike's post really says it all.

In my case I had root set up as owner/group. Changing it to www-data solved all of the permissions issues (because www-data was the user and group owners for apache and php). Once everything came into alignment, I was able to use the built-in XF upgrader.

Here is the contents of my public_html folder. You can see for my XF install (the "forums" directory), that the owner and group is www-data. This is what I had to change (via chown/chmod) to enable things.

Screen Shot 2020-03-20 at 11.11.06 AM.jpg
 

Mike

XenForo developer
Staff member
If PHP is running as nobody, then (virtually) all of the files in XF's data/ and internal_data/ directories would also be owned by nobody (as they are created by PHP). You indicate that they're owned by your user, so either something changed in terms of the PHP configuration with regards to the user it's running as or the ownership of those files changed somehow.

At this point, the simplest thing to do would be to 0666 all of the files in the mentioned directories.
 
Top