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

idsegments as option #15753

Closed
wants to merge 1 commit into from

Conversation

mikkeschiren
Copy link
Contributor

@mikkeschiren mikkeschiren commented Mar 30, 2020

fix #14763

Copy link
Member

@diosmosis diosmosis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @mikkeschiren for creating your first contribution! I left some comments in the review, let me know if you have any questions or need some help.

if (isset($idsegments)) {
$segments = array_merge($segments, $idsegments);
$segments = array_unique($segments);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the code here can be simplified. $segments = $this->getSegmentsToInvalidateFor($input, $sites); is executed no matter what but can be called twice if --segment is supplied. And the if (isset($idsegments)) { block could be located next to $idsegments w/o the if. Can you make these changes?

{
$idSegments = $input->getOption('idsegments');
$idSegments = trim($idSegments);
$idSegments = preg_replace('/\s/', '', $idSegments);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trim and preg_replace are redundant here. Only the preg_replace is needed.

$idSegments = trim($idSegments);
$idSegments = preg_replace('/\s/', '', $idSegments);
$idSegments = explode(",", $idSegments);
$idSegments = array_map('trim', $idSegments);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

W/ the preg_replace above, this call isn't necessary.

try {
$result[] = new Segment($segmentString, $idSites);
} catch (\Exception $e) {
return $e->getMessage();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this method should return an array of segments, if an error is encountered, can you just output a warning/error and ignore the segment?


if (empty($idSegments)) {
return array(null);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the reason for returning [null]? Should it instead return an empty array so nothing is invalidated? Given it's unexpected we could also output a warning here.

@tsteur
Copy link
Member

tsteur commented May 8, 2020

@mikkeschiren thanks a lot for this PR. Very appreciated. Do you mind looking at the comments from @diosmosis ?

@tsteur
Copy link
Member

tsteur commented Aug 27, 2020

@mikkeschiren as mentioned in previous comment could you look at the comments from @diosmosis ?

@tsteur
Copy link
Member

tsteur commented Aug 31, 2020

@mikkeschiren I'll close this PR for now as there has been no response to the comments in quite a while but we'll be very happy to do another review should you continue with this PR

@tsteur tsteur closed this Aug 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Review PRs that need a code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

core:invalidate-report-data command should accept --idsegments (easier to use than --segments)
3 participants