matomo-org / matomo

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!
https://matomo.org/
GNU General Public License v3.0
19.9k stars 2.65k forks source link

[Bug] Command line console does not work after upgrade to 5.0 #21718

Closed hyzteric closed 11 months ago

hyzteric commented 11 months ago

What happened?

I tried to upgrade to Matomo 5.0 and do it manually since I will do it on a high traffic website. When I wanted to run console commands, I got a PHP Fatal Error.

What should happen?

There should be no error when running the ./console help 😁

How can this be reproduced?

Download latest version wget https://builds.matomo.org/matomo.zip

Extract it to "matomo/" directory unzip -o matomo.zip

Set file ownership chown -R apache:apache /var/web/matomo

Disable Matomo Tracking and web interface via config/config.ini.php,

    [Tracker]
    record_statistics = 0
    [General]
    maintenance_mode = 1

Check for any obsolete files

cd matomo/
./console diagnostics:unexpected-files 

=> PHP Fatal error: Cannot override final method Piwik\Plugin\ConsoleCommand::execute() in /var/web/matomo/plugins/CoreConsole/Commands/GenerateAngularComponent.php on line 27

Then I tried this : ./console help => PHP Fatal error: Cannot override final method Piwik\Plugin\ConsoleCommand::execute() in /var/web/matomo/plugins/CoreConsole/Commands/GenerateAngularComponent.php on line 27

Then I put the backup back, run the same console command => No error

Matomo version

5.0

PHP version

8.1.25 (cli)

Server operating system

Rocky Linux 8.8

What browsers are you seeing the problem on?

Not applicable (e.g. an API call etc.)

Computer operating system

Windows 10

Relevant log output

No response

Validations

michalkleiner commented 11 months ago

Hi @hyzteric, thank you for raising the issue.

To be able to establish this is a true issue and not a one off or configuration specific issue, can you try if the same works/doesn't work on a different linux machine perhaps? I just tried following the same steps but didn't get any errors locally on a MacOS. Tried PHP 8.1, 8.2 and 8.3.

Is the above the only content in your config.ini.php file or did you put anything extra there?

sgiehl commented 11 months ago

The file plugins/CoreConsole/Commands/GenerateAngularComponent.php no longer exists in Matomo 5. Due to internal code changes in this major release old files might break Matomo. Like in this case. Removing it manually and should fix the problem.

Which version did you update from?

tsteur commented 11 months ago

Here we should be likely adding another update script that will remove these files automatically should someone not removing it themselves to avoid upgrade issues.

I believe we've done this in the past and noticed this was necessary to avoid some update issues for some people. We could check which dimensions and commands were removed and remove those files manually maybe?

It's something we probably also want to document as part of our process so it won't be forgotten next time.

hyzteric commented 11 months ago

Ok so I did delete those two files (supposing it was the same issue for the second one) and it went through:

Upgrading from 4.16

sgiehl commented 11 months ago

@tsteur That wouldn't help for that specific scenario. When simply overwriting the installation with new files, old files can always cause issues. Removing them in an update script would work fine when updating through the UI. But on command line running any console command would fail due to the old files. So the update command would fail as well.

hyzteric commented 11 months ago

@sgiehl I based my update from this page : https://fr.matomo.org/faq/on-premise/update-matomo/ I think it would be great to add on that page a link to the changelogs where a specific section should be added with required manual operations when needed.

hyzteric commented 11 months ago

Also, I was not (and still am) not too sure if I could just remove the old directory, extract the new one and just copy my old config.ini.php over it. Would it break something? If not then I would do that next time. And maybe the update page should mention it too (https://fr.matomo.org/faq/on-premise/update-matomo/)

sgiehl commented 11 months ago

@hyzteric If you don't have any additional plugins installed that works without problems. If you have any those would be lost and would need to be reinstalled.

hyzteric commented 11 months ago

Thanks. That's what I thought so I'll stick to overwriting then.

michalkleiner commented 11 months ago

Thanks for confirming that after manually removing the files you were able to finish the upgrade. Don't hesitate to open a new issue if you find any other (reproducible) bugs with Matomo 5.

MatomoForumNotifications commented 10 months ago

This issue has been mentioned on Matomo forums. There might be relevant details there:

https://forum.matomo.org/t/update-matomo-4-16-0-5-0-0-error/54668/4