Warning Required Private Directories

Hi,
the system check gives me the follwing warnings:

WARNING: ..../plugins/Diagnostics/Diagnostic/RequiredPrivateDirectories.php(138): Warning - trim() expects parameter 1 to be string, array given - Matomo 4.3.1 - Please report this message in the Matomo forums: https://forum.matomo.org (please do a search first as it might have been reported already) (Module: Installation, Action: systemCheckPage, In CLI mode: false)

and:
WARNING: /home/mgdata/domains/mgdata.se/public_html/stats/plugins/Diagnostics/Diagnostic/RequiredPrivateDirectories.php(142): Warning - strpos() expects parameter 1 to be string, array given - Matomo 4.3.1 -

and also the message:
/config/config.ini.php
We found that the above URLs are accessible via the browser, but they should NOT be. …
We also found that Matomo’s config directory is publicly accessible. …

The errors did not exist until some time ago.
I’m on a shared host (Litespeed) and have no idea what to do. I also have the impression that visitor tracking collects incorrect values, but that is perhaps another topic

Hi,

It turns out there is indeed a bug in one part of this check. This should fix it:

You can apply this change to the plugins/Diagnostics/Diagnostic/RequiredPrivateDirectories.php file by replacing the lines in red with the ones in green (so adding ['data'] twice)

diff --git a/plugins/Diagnostics/Diagnostic/RequiredPrivateDirectories.php b/plugins/Diagnostics/Diagnostic/RequiredPrivateDirectories.php
index 74d41756819..40be4ee1e42 100644
--- a/plugins/Diagnostics/Diagnostic/RequiredPrivateDirectories.php
+++ b/plugins/Diagnostics/Diagnostic/RequiredPrivateDirectories.php
@@ -135,11 +135,11 @@ private function isAccessible(DiagnosticResult $result, $testUrl, $publicIfRespo
                     return true;
                 }
 
-                if (trim($response) === $publicIfResponseEquals) {
+                if (trim($response['data']) === $publicIfResponseEquals) {
                     // we assume it is publicly accessible because either the exact expected content is returned or because we don't check for content match
                     $result->addItem(new DiagnosticResultItem(DiagnosticResult::STATUS_ERROR, $testUrl));
                     return true;
-                } elseif (strpos($response, $publicIfResponseContains) !== false) {
+                } elseif (strpos($response['data'], $publicIfResponseContains) !== false) {
                     // we assume it is publicly accessible because a unique content is included in the response or because we don't check for content contains
                     $result->addItem(new DiagnosticResultItem(DiagnosticResult::STATUS_ERROR, $testUrl));
                     return true;
1 Like

Thanks a lot for the fast help!
Solved the problem for me.

1 Like