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

Memory Issue: wc_bookings_get_block_minutes_array #262

Open
2 tasks
MCKLtech opened this issue Sep 4, 2020 · 0 comments
Open
2 tasks

Memory Issue: wc_bookings_get_block_minutes_array #262

MCKLtech opened this issue Sep 4, 2020 · 0 comments
Labels
type: bug The issue is a confirmed bug.

Comments

@MCKLtech
Copy link

MCKLtech commented Sep 4, 2020

Affected ticket(s)

N/A

What I expected

N/A

What happened instead

Memory Issue: wc_bookings_get_block_minutes_array

In the standard WC Bookings use case, adding increments of minutes to an array is acceptable as most bookings will be less than a few hours.

However, for accommodations, this can cause a PHP memory leak as bookings can be multiple days or even months.

function wc_bookings_get_block_minutes_array( $block, $interval ) {
	$block_array = [];
	for( $i = 0; $i < $interval; $i++ ) {
        
        /* This can get too large and cause memory errors */
		$block_array[ $block + ( $i * MINUTE_IN_SECONDS ) ] = 0;
	}
	return $block_array;
}

Usual error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 167772160 bytes)

Steps to reproduce the issue

See above code block, simply use a large enough time range for an accommodation product.


  • Issue assigned to next milestone.
  • Issue assigned a priority (will be assessed by maintainers).
@vikrampm1 vikrampm1 added the type: bug The issue is a confirmed bug. label Mar 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug The issue is a confirmed bug.
Projects
None yet
Development

No branches or pull requests

2 participants