@Starker3 opened this Issue on December 2nd 2021 Contributor

When users run a database update and have segments that use unsupported segment conditions (For example when a plugin was removed or a dimension disabled) it results in an exception during the database upgrade.

For example, when a dimension is disabled but used in a segment we will see the following sort of error:

./console core:update --yes -vvv
*** Update ***
Database Upgrade Required
Your Matomo database is out-of-date, and must be upgraded before you can continue.
Matomo database will be upgraded from version 4.5.0 to the new version 4.6.1.

ERROR [2021-12-01 11:47:55] 51704 Uncaught exception: /matomo/core/Segment.php(215): Segment 'dimension1' is not a supported segment. [Query: , CLI mode: 1]
DEBUG [2021-12-01 11:47:55] 51704 Loaded plugins: (...)

[Exception]
Segment 'dimension1' is not a supported segment.

Exception trace:
(...)

It would be much easier to troubleshoot if we were to output the Segment name or Segment ID that has the unsupported condition.

@tsteur commented on December 2nd 2021 Member

refs https://github.com/matomo-org/matomo/issues/16152

As we don't usually no the segmentId there easily, we could additionally mention the idSite at least at some point and the full segment definition if possible.

Technically could also do DB queries to find out the idSegment under circumstances, but depending on the encoding and other things this might not always work etc.

@sgiehl commented on December 3rd 2021 Member

@tsteur I guess this might most likely also be a regression we should handle in 4.6.2. The problem is the update script, which tries to iterate over all segments here:
https://github.com/matomo-org/matomo/blob/4fe950ae94b0fe3bd13f928544ff876275fe6733/core/Updates/4.6.0-b4.php#L51-L77

I guess we should do a try/catch around the segment construct and simply skip segments that cause an exception

@tsteur commented on December 5th 2021 Member
@sgiehl commented on December 7th 2021 Member

@tsteur can't we actually close this issue now? The update problem should be solved. And all other issues regarding invalid segments should be covered with #16152

@tsteur commented on December 7th 2021 Member

@sgieh it depends how things are solved. If the segment class itself still throughs an exception, and it's eg used in an update script or in a command or anywhere else where it's not caught or handled etc, then it would be still useful to show more information what segment this comes from.

@sgiehl commented on December 7th 2021 Member

ah. ok. that makes sense

Powered by GitHub Issue Mirror