#1 An error has occured while trying to publish the content

Hi,

After pressing publish “#1 An error has occured while trying to publish the content.” appears - although when the page is opened in a fresh browser the changes do appear to have been published - however the error log from the server does indicate errors. Does anyone what is causing this and how to fix it please?

We are running php 5.6 on Apache 2.

Thanks and regards
Glynne

The error log is follows

[2017-06-16 10:10:27] Warning: Warning (2): unlink(/srv/www/virtual/coffee/htdocs/mail/contact_me.php): Permission denied in [/srv/www/virtual/coffee/htdocs/sitecake/2.4.4/vendor/league/flysystem/src/Adapter/Local.php, line 252]
Trace:
#0 Sitecake\Error\ErrorHandler::logError() called at [/srv/www/virtual/coffee/htdocs/sitecake/2.4.4/src/Sitecake/Error/ErrorHandler.php:272]
#1 Sitecake\Error\ErrorHandler::handleError()
#2 unlink() called at [/srv/www/virtual/coffee/htdocs/sitecake/2.4.4/vendor/league/flysystem/src/Adapter/Local.php:252]
#3 League\Flysystem\Adapter\Local->delete() called at [/srv/www/virtual/coffee/htdocs/sitecake/2.4.4/vendor/league/flysystem/src/Filesystem.php:236]
#4 League\Flysystem\Filesystem->delete() called at [/srv/www/virtual/coffee/htdocs/sitecake/2.4.4/src/Sitecake/Site.php:1403]
#5 Sitecake\Site->publishDraft() called at [/srv/www/virtual/coffee/htdocs/sitecake/2.4.4/src/Sitecake/Services/Content/ContentService.php:43]
#6 Sitecake\Services\Content\ContentService->publish() called at [/srv/www/virtual/coffee/htdocs/sitecake/2.4.4/src/Sitecake/Dispatcher.php:78]
#7 Sitecake\Dispatcher->response() called at [/srv/www/virtual/coffee/htdocs/sitecake/2.4.4/src/Sitecake/Dispatcher.php:72]
#8 Sitecake\Dispatcher->execute() called at [/srv/www/virtual/coffee/htdocs/sitecake/2.4.4/src/Sitecake/Dispatcher.php:43]
#9 Sitecake\Dispatcher->dispatch() called at [/srv/www/virtual/coffee/htdocs/sitecake/2.4.4/src/app.php:16]
#10 {closure}()
#11 call_user_func_array() called at [/srv/www/virtual/coffee/htdocs/sitecake/2.4.4/vendor/symfony/http-kernel/HttpKernel.php:153]
#12 Symfony\Component\HttpKernel\HttpKernel->handleRaw() called at [/srv/www/virtual/coffee/htdocs/sitecake/2.4.4/vendor/symfony/http-kernel/HttpKernel.php:68]
#13 Symfony\Component\HttpKernel\HttpKernel->handle() called at [/srv/www/virtual/coffee/htdocs/sitecake/2.4.4/vendor/silex/silex/src/Silex/Application.php:496]
#14 Silex\Application->handle() called at [/srv/www/virtual/coffee/htdocs/sitecake/2.4.4/vendor/silex/silex/src/Silex/Application.php:477]
#15 Silex\Application->run() called at [/srv/www/virtual/coffee/htdocs/sitecake/2.4.4/src/app.php:43]

Like the message said, Sitecake doesn’t have permission to handle mail/contact_me.php file. If that file only serves to send emails and doesn’t actually have to be handled by sitecake (no editable content inside), add .scignore file to your site root and add line

mail/contact_me.php

and sitecake will ignore it. You can do same for any file/dir that doesn’t need to be handled by sitecake. Just state each file/dir in new line. You can check out more regarding .scignore functionality here.

Hi

Thank you for your prompt response. I understand what you are saying however the only file that was being changed was index.html - we were changing heading two text only and the template in use is agency downloaded from your site (and unadulterated). Added to which the mail/contact… file is world writable (666), so I do not understand why it is being written to, or why it then says that it cannot write to it.
Am a tad confused as it is all very mysterious:) Am I missing something please?

Sitecake is creating sitecake-temp dir where it stores draft copies of all files from site root. While user edits site, Sitecake is updating draft files in background. To speed up publishing process Sitecake doesn’t check what is changed and in which files. It just copies all current draft files back to site root dir when user hit Publish. Before, while sitecake was supporting only static html Sitecake was managing only site root html files, but since we are supporting PHP, Sitecake is handling all the files because it doesn’t know if some file is just PHP functionality, or it is include file with content.
Hope this clears things up.

Thank you - that fills in the gaps and makes complete sense in terms of the behaviour we were seeing. Most appreciated.