Skip to content

Conversation

@akemidx
Copy link
Member

@akemidx akemidx commented Nov 20, 2025

This is from rollbar#20541
User was out of range due to the min being 0, but the range starting at 1.
This allows for a negative range.

This fix should prevent that from 500ing again due to being out of range.

@akemidx akemidx requested a review from snipe as a code owner November 20, 2025 21:56
if($emptyRowsCount) {
// Create empty rows
$emptyRows = collect(range(1, $emptyRowsCount))->map(function () {
$emptyRows = collect(range(0, $emptyRowsCount))->map(function () {
Copy link
Member

Choose a reason for hiding this comment

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

This could prevent the error, but I think the problem lies with $emptyRowCount being a float. The range can accept floats but we need a non negative integer for the row count. Also starting at 0 will be N+1 rows. so if $emptyRowCount is 3, it would skip 4 rows.
I think casting $emptyRowsCount to an integer and round() the value might be the better fit here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh great catch! That's a good point.

Copy link
Member

Choose a reason for hiding this comment

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

easier yet, we could put a step=1 on the input.

Copy link
Collaborator

Choose a reason for hiding this comment

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

We would want to guard against manual database changes though so I think a code change in this chunk is still needed.

Copy link
Member Author

Choose a reason for hiding this comment

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

interesting. I didn't read the code as it being an n+1.
it read as here is the start and the end of the range. so, 0 to 1 is 1.

additionally in my db its listed as a long, and I could NOT force it to be a decimal manually in the db. would always reset itself back to 1.

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 you're inferring the wrong N+1, which in our context usually refers to DB queries

Copy link
Member

Choose a reason for hiding this comment

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

yea the php docs have a good example of this

@snipe snipe changed the title FIXED Label2 Empty Row Range Fixed: Label2 Empty Row Range Dec 3, 2025
@snipe snipe changed the title Fixed: Label2 Empty Row Range Fixed [RB-20541]: Label2 Empty Row Range Dec 3, 2025
@akemidx akemidx requested a review from Godmartinz December 3, 2025 22:38
@akemidx akemidx requested a review from Godmartinz December 9, 2025 19:12
@Godmartinz
Copy link
Member

@akemidx still need to revert the range start to 1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants