@mattab opened this Issue on March 12th 2018 Member

Context

When a custom dimension is delete, and possibly when it's deactivated (to be tested), then any segment that still use this custom dimension, will fail to process.

  • When the segment is processed from cron, it leads to the whole archiving process to fail and error, preventing other reports to run. The error looks like: ERROR [2018-03-12 00:12:06] Got invalid response from API request: ?module=API&method=API.get&idSite=2&period=day&date=last52&format=php&trigger=archivephp. Response was 'a:2:{s:6:"result";s:5:"error";s:7:"message";s:81:"Segment 'dimension7' is not a supported segment. - caused by plugin CustomReports";}'
  • When the segment is processed via the UI only, the user would see the error message in the UI Segment 'dimension7' is not a supported segment. - caused by plugin CustomReports

Solution

The goal of this issue is to address the problem of the Cron archive only. Proposed solution:

  • Whenever a custom dimension is deleted (and likely also when it is de-activated), then we look for all segments that use this custom dimension
  • for each segment, we mark them as "autoArchive = false" (see SegmentEditor.add/update API parameter), which maps to auto_archive=0 in the segment table

As a result, the cron processing will not fail anymore, and all reports will be available, as expected.

@tsteur commented on March 12th 2018 Member

FYI: Custom reports stores its segment definition in a custom reports table. So ideally this solution would trigger an event that lets other plugins know to modify all segments (this would be needed in custom dimensions, but maybe we can use some generic event so it also works in the future for other things maybe, not needed though), and offer a simple method to manipulate a segment (this would be needed in core), eg removeSegmentCondition(fullSegment, segmentNameToRemove).

@tsteur commented on March 12th 2018 Member

BTW the segment archiving problem is more a general core problem and does not only apply to custom dimensions. Same problem exists when deactivating a plugin that provides segments etc. Maybe the segment filter in core should simply ignore such failures and leave a segment filter out when it is not available? Whether the segment is valid would then be only checked when editing or adding a segment etc.

@mattab commented on March 12th 2018 Member

:+1: so to summarise the solution could be to do 2 separate changes:

  1. add a check in the core:archive command, where at the start of the process, or before triggering archiving for a particular segment, we would check if the segment will work. If not, it's skipped and a message displayed on screen (but not an error).
  2. additionally handle the "Custom reports" use case specifically, since the segment is built-in the custom report, and does not use the standard Segment feature (so the "check if the segment will work in core:archive" won't cover the custom reports segments). The custom reports plugin would need to handle this case specifically.
Powered by GitHub Issue Mirror