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

Fix update script should not fail if invalid segment defined #18451

Closed
tsteur opened this issue Dec 5, 2021 · 0 comments · Fixed by #18455
Closed

Fix update script should not fail if invalid segment defined #18451

tsteur opened this issue Dec 5, 2021 · 0 comments · Fixed by #18455
Assignees
Labels
Bug For errors / faults / flaws / inconsistencies etc.
Milestone

Comments

@tsteur
Copy link
Member

tsteur commented Dec 5, 2021

See #18436 (comment)

There is 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:

foreach ($idSites as $idSite) {
$segmentStrings = Rules::getSegmentsToProcess([$idSite]);
foreach ($segmentStrings as $segmentString) {
$segment = new Segment($segmentString, [$idSite]);
if ($segment->getOriginalString() === $segment->getString()) {
continue;
}
$segmentsToAppend = [VisitFrequencyAPI::NEW_VISITOR_SEGMENT, VisitFrequencyAPI::RETURNING_VISITOR_SEGMENT];
foreach ($segmentsToAppend as $segmentToAppend) {
// we need to migrate the existing archive
$oldSegmentString = Segment::combine($segment->getString(), SegmentExpression::AND_DELIMITER, $segmentToAppend);
$newSegmentString = Segment::combine($segment->getOriginalString(), SegmentExpression::AND_DELIMITER, $segmentToAppend);
$oldSegmentHash = Segment::getSegmentHash($oldSegmentString);
$newSegmentHash = Segment::getSegmentHash($newSegmentString);
if ($oldSegmentHash === $newSegmentHash) {
continue;
}
$doneFlagsToMigrate['done' . $oldSegmentHash . '.Goals'] = 'done' . $newSegmentHash . '.Goals';
$doneFlagsToMigrate['done' . $oldSegmentHash . '.VisitsSummary'] = 'done' . $newSegmentHash . '.VisitsSummary';
$doneFlagsToMigrate['done' . $oldSegmentHash . '.UserCountry'] = 'done' . $newSegmentHash . '.UserCountry';
}
}
}

We should do a try/catch around the segment construct and simply skip segments that cause an exception.

To prevent an error during update like this:

./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:
(...)
@tsteur tsteur added the Bug For errors / faults / flaws / inconsistencies etc. label Dec 5, 2021
@tsteur tsteur added this to the 4.6.2 milestone Dec 5, 2021
@sgiehl sgiehl self-assigned this Dec 6, 2021
@sgiehl sgiehl linked a pull request Dec 7, 2021 that will close this issue
11 tasks
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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants