@Findus23 opened this Issue on November 26th 2017 Member

related to #10369

I tried to update a plugin but forgot to change the owner of the folder back to ẁww-data before, so Piwik couldn't create a file.
But the error message isn't displayed correctly:

<div id="notificationContainer">
    <div style="display:none" data-role="notification" data-id="CorePluginsAdmin_InstallPlugin" data-type="persistent"
         data-title="" data-noclear="0" data-context="error" data-raw="">Error while creating/copying file to &lt;code&gt;/var/www/piwik/plugins//ActivityLog/Widgets/GetActivityLog.php&lt;/code&gt;.
        &lt;br /&gt;Please check that the web server has enough permission to write to these files/directories:&lt;br /&gt;For
        example, on a GNU/Linux server if your Apache httpd user is www-data, you can try to execute:&lt;br /&gt;
        &lt;code&gt;chown -R www-data:www-data /var/www/piwik&lt;/code&gt;&lt;br /&gt;&lt;code&gt;chmod -R 0755
        /var/www/piwik&lt;/code&gt;&lt;br /&gt;
@sgiehl commented on November 26th 2017 Member

Not sure but maybe this would fix it:

diff --git a/core/Filesystem.php b/core/Filesystem.php
index 7fbd63b..f1a2a8a 100644
--- a/core/Filesystem.php
+++ b/core/Filesystem.php
@@ -10,6 +10,7 @@ namespace Piwik;

 use Exception;
 use Piwik\Container\StaticContainer;
+use Piwik\Exception\MissingFilePermissionException;
 use Piwik\Plugins\Installation\ServerFilesGenerator;
 use Piwik\Tracker\Cache as TrackerCache;
 use Piwik\Cache as PiwikCache;
@@ -502,7 +503,9 @@ class Filesystem
             if (!<a class='mention' href='https://github.com/copy'>@copy</a>($source, $dest)) {
                 $message = "Error while creating/copying file to <code>$dest</code>. <br />"
                     . Filechecks::getErrorMessageMissingPermissions(self::getPathToPiwikRoot());
-                throw new Exception($message);
+                $exception = new MissingFilePermissionException($message);
+                $exception->setIsHtmlMessage();
+                throw $exception;
Powered by GitHub Issue Mirror