@katebutler opened this Pull Request on September 4th 2019 Member

Fixes #14828

@tsteur commented on September 6th 2019 Member

Found one bug @katebutler

I had these segments (among some others):

INSERT INTO `piwik_segment` (`idsegment`, `name`, `definition`, `login`, `enable_all_users`, `enable_only_idsite`, `auto_archive`, `ts_created`, `ts_last_edit`, `deleted`)
VALUES
    (48, 'exclude funds library', 'customVariableValue1!<a class='mention' href='https://github.com/HTTP'>@HTTP</a>-Grabber%2520www.fundslibrary.co.uk', 'root', 0, 1, 1, '2019-04-08 02:43:54', '2019-08-30 22:48:49', 1),
    (49, 'tets3', 'actions>=1', 'root', 0, 0, 1, '2019-08-29 02:14:09', '2019-08-30 22:48:49', 0),
    (50, 'test23434', 'actions>=1', 'root', 0, 0, 1, '2019-08-29 02:14:54', '2019-08-30 22:48:49', 1),
    (51, 'tererer', 'actions>=1', 'root', 0, 3, 1, '2019-08-29 02:15:33', '2019-08-30 22:48:49', 0),
    (52, 'tererer', 'actions>=1', 'root', 0, 1, 1, '2019-08-29 02:15:42', '2019-08-30 22:48:49', 1);

and it generated this output

array (
  0 => 
  array (
    'definition' => 'customVariableValue1!<a class='mention' href='https://github.com/HTTP'>@HTTP</a>-Grabber%2520www.fundslibrary.co.uk',
    'enable_only_idsite' => '1',
    'idsites_to_preserve' => 
    array (
    ),
  ),
  1 => 
  array (
    'idsites_to_preserve' => 
    array (
      0 => '3',
    ),
  ),
)

Causing the deletion of regular segments. The problem is that it first was doing unset($deletedSegments[$i]); and then in the next iteration it was doing $deletedSegments[$i]['idsites_to_preserve'][] = $existing['enable_only_idsite'];. I reckon it might help to break the loop after calling unset($deletedSegments[$i]);.

@tsteur commented on September 6th 2019 Member

BTW Might be good to add a test for this particular case where the logic was failing

This Pull Request was closed on September 16th 2019
Powered by GitHub Issue Mirror