Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the manual update documentation to prevent obsolete files left after an upgrade where a dimension was removed but file still exists #17399

Closed
satphil opened this issue Mar 27, 2021 · 27 comments · Fixed by #20195
Assignees
Labels
Bug For errors / faults / flaws / inconsistencies etc. c: Documentation For issues related to in-app product help messages, or to the Matomo knowledge base.
Milestone

Comments

@satphil
Copy link

satphil commented Mar 27, 2021

Expected Behavior

When you run

php "$PUBLIC_DIR/console" core:update

to upgrade matomo from 3.13.5 to 4.2.1, the database restructure should succeed:

Executing UPDATE piwik_archive_numeric_2021_03 SET name = 'done' WHERE name = 'done.';... Done. [291 / 294]

Executing ALTER TABLE piwik_log_visit MODIFY COLUMN profilable TINYINT(1) NULL, MODIFY COLUMN visitor_seconds_since_first INT(11) UNSIGNED NULL, MODIFY COLUMN visitor_seconds_since_order INT(11) UNSIGNED NULL, MODIFY COLUMN visitor_count_visits INT(11) UNSIGNED NOT NULL DEFAULT 0, MODIFY COLUMN visit_total_interactions MEDIUMINT UNSIGNED DEFAULT 0, MODIFY COLUMN referer_name VARCHAR(255) NULL, MODIFY COLUMN referer_url VARCHAR(1500) NULL, MODIFY COLUMN config_browser_name VARCHAR(40) NULL, ADD COLUMN config_client_type TINYINT( 1 ) NULL DEFAULT NULL, MODIFY COLUMN visitor_seconds_since_last INT(11) UNSIGNED NULL, MODIFY COLUMN location_region char(3) DEFAULT NULL;... Done. [292 / 294]

Executing ALTER TABLE piwik_log_conversion MODIFY COLUMN visitor_seconds_since_first INT(11) UNSIGNED NULL, MODIFY COLUMN visitor_seconds_since_order INT(11) UNSIGNED NULL, MODIFY COLUMN visitor_count_visits INT(11) UNSIGNED NOT NULL DEFAULT 0, MODIFY COLUMN referer_name VARCHAR(255) NULL, ADD COLUMN config_browser_name VARCHAR(40) NULL, ADD COLUMN config_client_type TINYINT( 1 ) NULL DEFAULT NULL, MODIFY COLUMN location_region char(3) DEFAULT NULL;... Done. [293 / 294]

Executing ALTER TABLE piwik_log_link_visit_action MODIFY COLUMN search_cat VARCHAR(200) NULL, MODIFY COLUMN search_count INTEGER(10) UNSIGNED NULL, ADD COLUMN idaction_product_cat INT(10) UNSIGNED NULL, ADD COLUMN idaction_product_cat2 INT(10) UNSIGNED NULL, ADD COLUMN idaction_product_cat3 INT(10) UNSIGNED NULL, ADD COLUMN idaction_product_cat4 INT(10) UNSIGNED NULL, ADD COLUMN idaction_product_cat5 INT(10) UNSIGNED NULL, ADD COLUMN idaction_product_name INT(10) UNSIGNED NULL, ADD COLUMN product_price DOUBLE NULL, ADD COLUMN idaction_product_sku INT(10) UNSIGNED NULL;... Done. [294 / 294]

Matomo has been successfully updated!

Current Behavior

output as follows:

Executing UPDATE `piwik_archive_numeric_2021_03` SET `name` = 'done' WHERE `name` = 'done.';... Done. [291 / 294]

Error trying to execute the migration 'ALTER TABLE `piwik_log_visit` MODIFY COLUMN `profilable` TINYINT(1) NULL, MODIFY COLUMN `visitor_seconds_since_first` INT(11) UNSIGNED NULL, MODIFY COLUMN `visitor_seconds_since_order` INT(11) UNSIGNED NULL, MODIFY COLUMN `visitor_count_visits` INT(11) UNSIGNED NOT NULL DEFAULT 0, MODIFY COLUMN `visit_total_interactions` MEDIUMINT UNSIGNED DEFAULT 0, MODIFY COLUMN `referer_name` VARCHAR(255) NULL, MODIFY COLUMN `referer_url` VARCHAR(1500) NULL, MODIFY COLUMN `config_browser_name` VARCHAR(40) NULL, ADD COLUMN `config_client_type` TINYINT( 1 ) NULL DEFAULT NULL, MODIFY COLUMN `visitor_seconds_since_last` INT(11) UNSIGNED NULL, 

MODIFY COLUMN `location_region` char(3) DEFAULT NULL, 

MODIFY COLUMN `location_region` char(3) DEFAULT NULL;'.

The error was: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'location_region' in 'piwik_log_visit'

Note the repetition of the modify column location_region at the end of the statement (I've added line breaks for clarity), which I believe causes the error.

Possible Solution

I suspect 2 bugs.

  • Bug 1
    The matomo upgrade code that creates the SQL statement get confused by obsolete files and isn’t checking that the same column is modified twice.

  • Bug 2
    The install instructions for matomo don’t seem to take account of obsolete files left behind.

At matomo upgrade guide

https://matomo.org/docs/update/#the-manual-three-step-update

down at section

Replace the Matomo files with the latest version

it says

" It is not needed to delete your old Matomo files before transferring the new ones. The new files should overwrite all the old files with the same names."

I believe the error you are seeing occurs because it is necessary to delete obsolete Matomo files. The above instructions don’t make this expicit.

Otherwise files that are deleted in future releases get left behind, and cause the grief you are seeing.

In my case, some of the files like the following (dated 28 Apr 2020, v3.13.5?) got left behind

    /var/www/piwik/plugins/DevicePlugins/Columns/PluginDirector.php
    /var/www/piwik/plugins/DevicePlugins/Columns/PluginGears.php
    /var/www/piwik/plugins/Actions/Columns/InteractionPosition.php
    /var/www/piwik/plugins/VisitorInterest/Columns/VisitsByDaysSinceLastVisit.php

These files are no longer included in the piwik.zip file from the matomo 4.2.1 release (dated 1 Mar 2021).

I suspect these define columns that are no longer in the table and confuse the upgrade SQL statements which Bug 1 fails to spot.

It also leads to later errors like

Column not found: 1054 Unknown column ‘config_director’ in ‘field list’

or

PHP Fatal error:  Uncaught Error: Call to undefined method 
Piwik\Tracker\Request::getDaysSinceLastVisit() 
in /var/www/piwik/plugins/VisitorInterest/Columns/VisitsByDaysSinceLastVisit.php:38

My solution was to find all files not dated 1 Mar 2021 and renaming them out of my /var/www/piwik/plugins directory to a tmp directory.

Alternatively, save the config/config.ini.php file, delete the old piwik directory, copy over the contents of the new piwik.zip file and then return the saved config/config.ini.php file.

Steps to Reproduce (for Bugs)

  1. Get a database from the 3.13.5 release. Copy some obsolete files into the /var/www/piwik/plugins directory. In my case, the obsolete files (i.e. files without a 1 March 2021 date) were:

    drwxr-xr-x 2 www-data www-data 4096 Apr 28 2020 ./CoreHome/angularjs/dialogtoggler
    -rw-r--r-- 1 www-data www-data 3253 Apr 28 2020 ./CoreHome/angularjs/dialogtoggler/dialogtoggler.controller.js
    -rw-r--r-- 1 www-data www-data 710 Apr 28 2020 ./CoreHome/angularjs/dialogtoggler/dialogtoggler.directive.js
    -rw-r--r-- 1 www-data www-data 3589 Apr 28 2020 ./CoreHome/angularjs/dialogtoggler/dialogtoggler-urllistener.service.js
    -rw-r--r-- 1 www-data www-data 1363 May 13 2019 ./CoreHome/angularjs/dialogtoggler/ngdialog.less
    -rw-r--r-- 1 www-data www-data 5845 Apr 28 2020 ./CoreHome/javascripts/donate.js
    -rw-r--r-- 1 www-data www-data 13527 Oct 29 2019 ./CoreHome/javascripts/iframeResizer.contentWindow.min.js
    -rw-r--r-- 1 www-data www-data 12917 Oct 29 2019 ./CoreHome/javascripts/iframeResizer.min.js
    -rw-r--r-- 1 www-data www-data 2383 Apr 28 2020 ./CoreHome/LoginWhitelist.php
    -rw-r--r-- 1 www-data www-data 75831 Apr 28 2020 ./Morpheus/fonts/piwik.svg
    -rw-r--r-- 1 www-data www-data 26300 Apr 28 2020 ./Morpheus/fonts/piwik.ttf
    -rw-r--r-- 1 www-data www-data 26376 Apr 28 2020 ./Morpheus/fonts/piwik.woff
    -rw-r--r-- 1 www-data www-data 10936 Apr 28 2020 ./Morpheus/fonts/piwik.woff2
    -rw-r--r-- 1 www-data www-data 2636 May 13 2019 ./Morpheus/images/paypal_subscribe.png
    -rw-r--r-- 1 www-data www-data 4045 May 13 2019 ./Morpheus/images/smileyprog_0.png
    -rw-r--r-- 1 www-data www-data 4268 May 13 2019 ./Morpheus/images/smileyprog_1.png
    -rw-r--r-- 1 www-data www-data 4292 May 13 2019 ./Morpheus/images/smileyprog_2.png
    -rw-r--r-- 1 www-data www-data 4589 May 13 2019 ./Morpheus/images/smileyprog_3.png
    -rw-r--r-- 1 www-data www-data 4733 May 13 2019 ./Morpheus/images/smileyprog_4.png
    -rw-r--r-- 1 www-data www-data 477 Jun 24 2019 ./TagManager/Template/Variable/PreConfigured/FormDestionationVariable.php
    drwxr-xr-x 3 www-data www-data 4096 Mar 27 16:04 ./Actions/Columns
    -rw-r--r-- 1 www-data www-data 1448 Apr 28 2020 ./Actions/Columns/InteractionPosition.php
    -rw-r--r-- 1 www-data www-data 806 Apr 28 2020 ./API/Renderer/Json2.php
    -rw-r--r-- 1 www-data www-data 2227 Apr 28 2020 ./API/Renderer/Php.php
    -rw-r--r-- 1 www-data www-data 757 Oct 29 2019 ./CoreUpdater/ReleaseChannel/Latest2XBeta.php
    -rw-r--r-- 1 www-data www-data 689 Oct 29 2019 ./CoreUpdater/ReleaseChannel/Latest2XStable.php
    -rw-r--r-- 1 www-data www-data 763 Apr 28 2020 ./CoreUpdater/ReleaseChannel/Latest3XBeta.php
    -rw-r--r-- 1 www-data www-data 695 Apr 28 2020 ./CoreUpdater/ReleaseChannel/Latest3XStable.php
    -rw-r--r-- 1 www-data www-data 759 Apr 28 2020 ./CustomVariables/Columns/SearchCategory.php
    drwxr-xr-x 2 www-data www-data 4096 Mar 27 16:06 ./DevicePlugins/Columns
    -rw-r--r-- 1 www-data www-data 789 Apr 28 2020 ./DevicePlugins/Columns/PluginDirector.php
    -rw-r--r-- 1 www-data www-data 785 Apr 28 2020 ./DevicePlugins/Columns/PluginGears.php
    -rw-r--r-- 1 www-data www-data 2786 Apr 28 2020 ./Diagnostics/Diagnostic/LoadDataInfileCheck.php
    drwxr-xr-x 2 www-data www-data 4096 Apr 28 2020 ./GeoIp2/Columns
    -rw-r--r-- 1 www-data www-data 462 Apr 28 2020 ./GeoIp2/Columns/Region.php
    -rw-r--r-- 1 www-data www-data 697 Apr 28 2020 ./SegmentEditor/SegmentList.php
    drwxr-xr-x 2 www-data www-data 4096 Apr 28 2020 ./UserCountry/angularjs/location-provider-updater
    -rw-r--r-- 1 www-data www-data 5824 Apr 28 2020 ./UserCountry/angularjs/location-provider-updater/location-provider-updater.controller.js
    -rw-r--r-- 1 www-data www-data 1172 Apr 28 2020 ./UserCountry/angularjs/location-provider-updater/location-provider-updater.directive.js
    -rw-r--r-- 1 www-data www-data 1556 Apr 28 2020 ./UserCountry/Columns/Provider.php
    -rw-r--r-- 1 www-data www-data 24951 Apr 28 2020 ./UserCountry/GeoIPAutoUpdater.php
    drwxr-xr-x 2 www-data www-data 4096 Apr 28 2020 ./UserCountry/LocationProvider/GeoIp
    -rw-r--r-- 1 www-data www-data 11176 Apr 28 2020 ./UserCountry/LocationProvider/GeoIp/Pecl.php
    -rw-r--r-- 1 www-data www-data 8313 Apr 28 2020 ./UserCountry/LocationProvider/GeoIp.php
    -rw-r--r-- 1 www-data www-data 14862 Apr 28 2020 ./UserCountry/LocationProvider/GeoIp/Php.php
    -rw-r--r-- 1 www-data www-data 10381 Apr 28 2020 ./UserCountry/LocationProvider/GeoIp/ServerBased.php
    -rw-r--r-- 1 www-data www-data 540 Apr 28 2020 ./UserCountry/Tasks.php
    -rw-r--r-- 1 www-data www-data 3115 Apr 28 2020 ./UserCountry/templates/_updaterManage.twig
    -rw-r--r-- 1 www-data www-data 377 Apr 28 2020 ./UserCountry/templates/_updaterNextRunTime.twig
    drwxr-xr-x 2 www-data www-data 4096 Mar 27 16:07 ./VisitorInterest/Columns
    -rw-r--r-- 1 www-data www-data 1062 Apr 28 2020 ./VisitorInterest/Columns/VisitsByDaysSinceLastVisit.php

run:

php "$PUBLIC_DIR/console" core:update

Context

I was trying to update the matomo release from 3.13.5 to 4.2.1.

See my reply #4 in https://forum.matomo.org/t/problems-updating-matomo-from-version-3-5-1-to-version-4-2-1/41019

Your Environment

  • Matomo Version: 4.2.1
  • PHP Version: 8.0
  • Server Operating System: debian 10.8 for amd64
  • Additionally installed plugins: none as far as I know

``

@satphil satphil added the Potential Bug Something that might be a bug, but needs validation and confirmation it can be reproduced. label Mar 27, 2021
@satphil
Copy link
Author

satphil commented Mar 27, 2021

Correction: add step 2.

Steps to Reproduce (for Bugs)

  1. Get a database from the 3.13.5 release.
  2. Download matomo 4.2.1 piwik.zip file, unzip into /var/www/piwik.
  3. Copy some obsolete files into the /var/www/piwik/plugins directory.

@sgiehl
Copy link
Member

sgiehl commented Mar 27, 2021

Hi @satphil Thanks for creating the issue. I'm quite sure we already had a similar report in the past, but wasn't able to find it on the fly.
The colum location_region actually should have already been there before Matomo 4. Do you maybe have an backup from before the update where you could check if that column was there before or not?

@satphil
Copy link
Author

satphil commented Mar 27, 2021 via email

@diosmosis diosmosis added Bug For errors / faults / flaws / inconsistencies etc. c: Documentation For issues related to in-app product help messages, or to the Matomo knowledge base. and removed Potential Bug Something that might be a bug, but needs validation and confirmation it can be reproduced. labels Mar 28, 2021
@diosmosis
Copy link
Member

diosmosis commented Mar 28, 2021

Hi @satphil, thanks for creating this issue!

I can confirm the faq on the three step upgrade omits the requirement to remove no longer used files. In the OneClickUpdater we explicitly do this (for the reasons described in the issue description): https://github.com/matomo-org/matomo/blob/4.x-dev/plugins/CoreUpdater/Model.php#L26-L36, the manual upgrade should mirror this.

I'm not sure what the best solution here is since we don't keep a list of files that were removed but diff between what is in the archive and the current install, but it might require a new core command. Or some pre tested bash functions. But the process will become more complicated since it's no longer just a "FTP and upload".

@tsteur
Copy link
Member

tsteur commented Mar 28, 2021

" It is not needed to delete your old Matomo files before transferring the new ones. The new files should overwrite all the old files with the same names."

The initial files should be removed before uploading the new files and the guide should be updated ideally. There has been a similar issue before (I think eg #17181). Otherwise there might be still some dimensions that should be removed etc.

@tsteur tsteur added this to the 4.3.0 milestone Mar 28, 2021
@satphil
Copy link
Author

satphil commented Mar 28, 2021 via email

@Berbe
Copy link

Berbe commented Apr 21, 2021

This is very disturbing.

Please either:

  • make core:update clean obsolete files (core application + shipped plugins)
  • update documentation to state this needs to be done manually
    Also consider updating https://matomo.org/changelog/matomo-4-0-0/ to make an explicit statement about it.

While the former would involve way more work but would eventually be way more rewarding (keeping the promise of simplicity), the latter could be done swiftly.

@sgiehl
Copy link
Member

sgiehl commented Apr 21, 2021

@Berbe we are already planning to improve it for the next release.

@uncled1023
Copy link

I went to upgrade recently and was wondering why everything was failing. Only after hunting down this issue was I able to find that I needed to remove all the old files first. The documentation still says to just copy and override existing files. This should really be at least changed in the documentation.

@Berbe
Copy link

Berbe commented Aug 24, 2021

@Berbe 2021-04-21
Please either:

[...] the latter could be done swiftly.

@sgiehl 2021-04-21
@Berbe we are already planning to improve it for the next release.

@mattab removed this from the 4.3.0 milestone on 26 May
@mattab added this to the 4.4.0 milestone on 26 May
@tsteur removed this from the 4.4.0 milestone on 23 Jul
@tsteur added this to the 4.7.0 milestone on 23 Jul

@tsteur tsteur modified the milestones: 4.8.0, 4.9.0 Feb 9, 2022
@tsteur tsteur modified the milestones: 4.9.0, 4.10.0 Mar 2, 2022
@sgiehl
Copy link
Member

sgiehl commented Apr 4, 2022

@tsteur would you mind to summarize what we should do here? Is it only about updating the documentation? Or shall we also implement a possibility to automatically remove those files in the UI or maybe within core:update?

@tsteur
Copy link
Member

tsteur commented Apr 4, 2022

The first step would be definitely to update the guide.

Not sure what else we can do to solve this issue in the future so it won't happen again? Can we do something that eg when files are left there, the updates still work?

Maybe we can detect files that shouldn't be there and ignore them? Or does it maybe make sense before the DB upgrade to show again if some files need to be deleted?

Or maybe we could detect when this error happens and give users clear instructions on what to do solve this issue? Like remove these files and try again?

I'm assuming there are various ways but I'm not too deep into it right now to know how to best solve the issue without taking too much time and while providing a good user experience.

@satphil
Copy link
Author

satphil commented Apr 5, 2022

The matomo software implicitly depends on the presence or absence of files, so it is imperative that obsolete files are removed during upgrades. Commands like rsync have switches like "--delete-after - receiver deletes extraneous files from dest dirs after transfer, not during".
One approach, mentioned in my original bug report: save the config/config.ini.php file, delete the old piwik directory, copy over the contents of the new piwik.zip file and then return the saved config/config.ini.php file.

@justinvelluppillai justinvelluppillai removed this from the 4.10.0 milestone Apr 13, 2022
@justinvelluppillai justinvelluppillai added this to the 4.12.5 milestone Nov 4, 2022
@justinvelluppillai justinvelluppillai modified the milestones: 4.12.5, 4.13.2 Nov 28, 2022
@justinvelluppillai justinvelluppillai modified the milestones: 4.13.2, 4.13.1 Dec 8, 2022
@mattab mattab added the 4.13.1 label Jan 4, 2023
@bx80
Copy link
Contributor

bx80 commented Jan 8, 2023

Deleting the directory and then copying back the config.ini.php file works well, but could in some cases could potentially change existing directory permissions/owner and delete custom .htaccess rules.

An alternative could be to provide a command to delete all files in the Matomo installation directory except the config.ini.php file and any .htaccess files (if they exist):

$find . ! -name .htaccess ! -name config.ini.php -type f -delete

Proposed documentation change:

It is not needed to delete your old Matomo files before transferring the new ones. The new files should overwrite all the old files with the same names

It is recommended to delete your old Matomo files before transferring the new ones, be sure to preserve config/config.ini.php and any .htaccess files.

# go into the the directory that contains your existing "matomo/" installation 

# download latest version
$ wget https://builds.matomo.org/matomo.zip

# remove old files
$find . ! -name .htaccess ! -name config.ini.php -type f -delete

# extract the new release files
$ unzip -o matomo.zip # extract it to "matomo/" directory

# delete the archive and read below the next step
$ rm matomo.zip 

@mattab
Copy link
Member

mattab commented Jan 9, 2023

@bx80 Feedback: could we update instructions to account for:

@sgiehl
Copy link
Member

sgiehl commented Jan 9, 2023

@bx80 in addition to config.ini.php and .htaccess files we should also keep:

  • misc directory, as it might contain a geoip database, that would be lost otherwise
  • config.php file as it might contain some custom di configuration
  • Any plugin that is not part of the Matomo package

@mattab mattab changed the title obsolete files left over from previous releases cause errors in 4.2.1 upgrade database restructure and runtime obsolete files left (after a manual update) over from previous releases cause errors in 4.2.1 upgrade database restructure and runtime Jan 9, 2023
@mattab mattab changed the title obsolete files left (after a manual update) over from previous releases cause errors in 4.2.1 upgrade database restructure and runtime Update the manual update documentation to prevent obsolete files left after an upgrade where a dimension was removed but file still exists Jan 9, 2023
@bx80
Copy link
Contributor

bx80 commented Jan 9, 2023

Updated to ignore everything in the misc/ directory, common.config.ini.php and config.php.

Only deleting plugins provided by the release isn't as straight forward as we don't have a naming system or directory structure to identify them. I can make the main delete command skip the plugins directory and then add a second command to just delete files in a fixed list of plugins directories. This does make for a large command to paste and will need to be updated in the future if we add new plugins to the release, but it will preserve custom plugins. Open to any better ideas!

# remove old files, excluding all plugins
find . ! -name .htaccess ! -name config.ini.php ! -name config.php ! -name common.config.ini.php ! -path "./misc/*" \ 
! -path "./plugins/*" -type f -delete

# remove old files from plugins that are part of the main matomo release
find plugins/API plugins/Actions plugins/Annotations plugins/BulkTracking \
plugins/Contents plugins/CoreAdminHome plugins/CoreConsole plugins/CoreHome \
plugins/CorePluginsAdmin plugins/CoreUpdater plugins/CoreVisualizations \
plugins/CoreVue plugins/CustomDimensions plugins/CustomJsTracker \
plugins/DBStats plugins/Dashboard plugins/DevicePlugins \
plugins/DevicesDetection plugins/Diagnostics \
plugins/Ecommerce plugins/Events plugins/Feedback plugins/GeoIp2 plugins/Goals \
plugins/Heartbeat plugins/ImageGraph plugins/Insights plugins/Installation \
plugins/Intl plugins/IntranetMeasurable plugins/LanguagesManager plugins/Live \
plugins/Login plugins/Marketplace plugins/MobileAppMeasureable \
plugins/MobileMessages plugins/Monolog plugins/Morpheus plugins/MultiSites \
plugins/Overlay plugins/PagePerformance plugins/PrivacyManager \
plugins/ProfessionalServices plugins/Proxy plugins/Referrers \
plugins/Resolution plugins/RssWidget plugins/SEO plugins/ScheduledReports \
plugins/SegmentEditor plugins/SitesManager plugins/TagManager plugins/Tour \
plugins/Transitions plugins/TwoFactorAuth plugins/UserCountry \
plugins/UserCountryMap plugins/UserId plugins/UserLanguage \
plugins/UsersManager plugins/VisitFrequency plugins/VisitTime \
plugins/VisitorInterest plugins/VisitsSummary plugins/WebsiteMeasurable \
plugins/Widgetize -type f -delete

@mattab
Copy link
Member

mattab commented Jan 10, 2023

The only other way i can think of, is that we could provide a command that would output this text and dynamically generate it so that we don't have to maintain the page up to date in the future. Would it maybe make sense to have a console command to generate these shell commands?

@tsteur
Copy link
Member

tsteur commented Jan 10, 2023

Or they could run diagnostics:run command after updating files and then delete any extra file that shouldn't be there? Maybe it's the easiest and works across OS etc?

Like after updating files you need to run the ./console diagnostics:run command to identify which files need to be deleted....

@bx80
Copy link
Contributor

bx80 commented Jan 11, 2023

Thanks for the ideas, a console command sounds like a much nicer approach than copying shell commands 👍

Getting the list of unexpected files from the diagnostics FileIntegrity class would be good as it will always be up to date based on the release manifest. However there is a twenty line cut off to the list of unexpected files shown on the diagnostic report and the output is formatted which would make manually deleting multiple files from the command line a chore.

To improve the experience I've linked a PR which adds two extra options to the diagnostic command:

./console diagnostics:run --show-unexpected-files which will just output a raw list of unexpected file names, this could be piped to a file, less or directly to the OS delete command (eg. ./console diagnostics:run --show-unexpected-file | xargs rm -f)

./console diagnostics:run --delete-unexpected-files which will attempt to delete the unexpected files using the Filesystem::deleteFileIfExists method.

The documentation can then be updated to something like:
Run the ./console diagnostics:run --show-unexpected-files command and review the list of unexpected files.
Run the ./console diagnostics:run --delete-unexpected-files to delete the files.

@justinvelluppillai justinvelluppillai modified the milestones: 4.13.1, 4.13.2 Jan 11, 2023
@bx80
Copy link
Contributor

bx80 commented Jan 16, 2023

Once the linked PR has passed review and has been released, the manual three step update FAQ can be updated as follows:

### 2) Replace the Matomo files with the latest version

You can download the latest Matomo release from [builds.matomo.org/matomo.zip][3]. After downloading it, 
you can extract it to your computer.

If you upload these files using FTP to your Matomo server, please make sure all files are transferred in 
binary mode. 

If you have SSH access to your server you can download the latest version and extract it directly from the 
server hosting Matomo:

    # go into the the directory that contains your existing "matomo/" installation 
    $ wget https://builds.matomo.org/matomo.zip # download latest version
    $ unzip -o matomo.zip # extract it to "matomo/" directory
    $ rm matomo.zip # delete the archive
    $ ./console diagnostics:run --show-unexpected-files # check for any obsolete files, Matomo 4.13.2+ only
    $ ./console diagnostics:run --delete-unexpected-files # delete any obsolete files, Matomo 4.13.2+ only
    # read below for the next step

@satphil
Copy link
Author

satphil commented Jan 17, 2023 via email

@bx80
Copy link
Contributor

bx80 commented Jan 17, 2023

Thanks for the feedback @satphil, a different filesystem hierarchy would certainly make things easier for this issue 👍

Unfortunately at this point I think the rework involved would significantly outweigh the eventual benefits. Code, build scripts, test scripts and documentation would all have to be changed and retested. Rearranging the directory structure on all existing Matomo installations could then break security rules, permissions and scripts, most of which would require manual intervention to fix.

It might be less disruptive to split user provided plugins from Matomo release provided plugins at some point, e.g. matomo/plugins vs matomo/plugins_release but would still be a lot of work.

@mlalpho
Copy link

mlalpho commented Jan 23, 2023

thank you all for the work on this. we were upgrading from 3.13.5 and had issues with the files we had left hanging around.

Executing ./console --matomo-domain="xxxx" plugin:uninstall "ExampleTheme"... PHP Fatal error:  Access level to Piwik\Plugins\CustomVariables\Columns\CustomVariableName::configureSegments() must be public (as in class Piwik\Columns\Dimension) in /xxx/plugins/CustomVariables/Columns/CustomVariableName.php on line 15

cheers!

@sgiehl sgiehl modified the milestones: 4.13.2, 4.13.3, 4.13.4 Jan 25, 2023
@kosarko
Copy link

kosarko commented Apr 28, 2023

The guide at https://matomo.org/docs/update/#the-manual-three-step-update still reads as:

It is not needed to delete your old Matomo files before transferring the new ones. The new files should overwrite all the old files with the same names.

@bx80
Copy link
Contributor

bx80 commented Apr 30, 2023

Thanks for heads up @kosarko, I've now updated the guide 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For errors / faults / flaws / inconsistencies etc. c: Documentation For issues related to in-app product help messages, or to the Matomo knowledge base.
Projects
None yet
Development

Successfully merging a pull request may close this issue.