Empowering People Ethically with the leading open source alternative to Google Analytics that gives you full control over your data. Matomo lets you easily collect data from websites & apps and visualise this data and extract insights. Privacy is built-in. Liberating Web Analytics. Star us on Github? +1. And we love Pull Requests!
Warning: file_put_contents(/matomo-for-wordpress/app/tmp/empty): Failed to open stream: No such file or directory in RecommendedPrivateDirectories.php on line 23 #18684
Warning: file_put_contents(/var/www/matomo/matomo/matomo-for-wordpress/app/tmp/empty): Failed to open stream: No such file or directory in /var/www/matomo/matomo/matomo-for-wordpress/app/plugins/Diagnostics/Diagnostic/RecommendedPrivateDirectories.php on line 23
It doesn't use the correct path from DI as it uses a hard coded path but not everyone is using this.
I was going to create this PR
diff --git a/plugins/Diagnostics/Diagnostic/RecommendedPrivateDirectories.php b/plugins/Diagnostics/Diagnostic/RecommendedPrivateDirectories.php
index 4add05f395..f93215865b 100644
--- a/plugins/Diagnostics/Diagnostic/RecommendedPrivateDirectories.php
+++ b/plugins/Diagnostics/Diagnostic/RecommendedPrivateDirectories.php
@@ -8,6 +8,7 @@
*/
namespace Piwik\Plugins\Diagnostics\Diagnostic;
+use Piwik\Container\StaticContainer;
use Piwik\Filesystem;
use Piwik\Translation\Translator;
@@ -19,8 +20,9 @@ class RecommendedPrivateDirectories extends AbstractPrivateDirectories
public function __construct(Translator $translator)
{
parent::__construct($translator);
- Filesystem::mkdir(PIWIK_INCLUDE_PATH . '/tmp');
- file_put_contents(PIWIK_INCLUDE_PATH . '/tmp/empty', 'test');
+ $tmpDir = rtrim(StaticContainer::get('path.tmp'), '/');
+ Filesystem::mkdir($tmpDir);
+ file_put_contents($tmpDir . '/empty', 'test');
}
protected function addError(DiagnosticResult &$result)
However, I noticed that while this would use the correct tmp directory, it would still use the wrong URL to try and fetch that tmp file. It would always use $matomoUrl/tmp/empty but the tmp directory might be outside the root directory or it might be in a very different directory and therefore the URL used to check if the file is readable would be wrong.
Meaning if it's outside the root directory we would completely need to skip the check for tmp files and when it's inside the root directory, the URL would need to change.
I have upgraded from 4.7.1 to 4.9.0 today and I got the same error. All seems to work correctly but the message appears. I created a file named "empty" in /tmp/ and the message disappeared (logical).
In Matomo for WordPress we are getting this error
It doesn't use the correct path from DI as it uses a hard coded path but not everyone is using this.
I was going to create this PR
However, I noticed that while this would use the correct tmp directory, it would still use the wrong URL to try and fetch that tmp file. It would always use
$matomoUrl/tmp/empty
but the tmp directory might be outside the root directory or it might be in a very different directory and therefore the URL used to check if the file is readable would be wrong.Meaning if it's outside the root directory we would completely need to skip the check for
tmp
files and when it's inside the root directory, the URL would need to change.