matomo-org / matomo-for-wordpress

Get a fully functioning Matomo Analytics for your WordPress. Star us on Github? +1. Matomo is the leading open alternative to Google Analytics that gives you full control over your data. Privacy is built-in. 100% data ownership, no one else can see your data. We love Pull Requests!
https://matomo.org
GNU General Public License v3.0
119 stars 25 forks source link

PHP Warning: Failed to open stream #1194

Closed jcastillo-johngroup closed 2 months ago

jcastillo-johngroup commented 2 months ago

After installing the plugin, I saw a notification: There are some errors in the Matomo Diagnostics System report that may prevent the plugin for working normally.

On following the link to view reports, I find this PHP warning at the top of the page.

file_put_contents(/code/wp-content/plugins/matomo/app/tmp/empty): Failed to open stream: No such file or directory in /code/wp-content/plugins/matomo/app/plugins/Diagnostics/Diagnostic/RecommendedPrivateDirectories.php on line 22

I dug into the code and found this:

    public function __construct(Translator $translator)
    {
        parent::__construct($translator);
        Filesystem::mkdir(PIWIK_INCLUDE_PATH . '/tmp');
        file_put_contents(PIWIK_INCLUDE_PATH . '/tmp/empty', 'test');
    }

It looks like other code in the plugin are using PIWIK_INCLUDE_PATH. Is there a different recommendation to change these tmp file paths to somewhere else? Web host is Pantheon, who recommends to point all things that need "write" permission to the uploads directory. I know we can manually make changes to this file, but updating the plugin will always revert the changes. We want to avoid that too.

System Report

              # Matomo

Endpoints

Crons

Mandatory checks

Optional checks

Matomo Settings

Logs

WordPress

Server

PHP cli

Database

Browser

diosmosis commented 2 months ago

Hi @jcastillo-johngroup the tmp path that Matomo for WordPress uses is actually different to PIWIK_INCLUDE_PATH . '/tmp'. The code that's causing this error for you is more relevant for our core product.

If you replace the /path/to/wordpress/wp-content/plugins/matomo/config/config.php file with https://raw.githubusercontent.com/matomo-org/matomo-for-wordpress/2c02169a25bc09d44813941ca601627be02e5687/config/config.php, it will disable the check and remove that specific warning. Note: this change will be included in future versions.