I'm getting the error "Could not update calendar because a locked event is blocking the update - you need to unlock any locked events in that period" when trying to add 2 days to the beginning of a booking. Days are marked available.
I've reviewed the code and database table entries for `rooms_booking_locks` states, and don't understand exactly what is being stored. The $state_diff_confirmed = array_diff($states_confirmed, $valid_states); code is definitely where the error is thrown, but I'm not sure what is "wrong" - perhaps a record in that table that should have been deleted?

Hoping for some insight, thanks!

Comments

ben.hamelin’s picture

Category: support » bug

I've spent a few hours on this, and am hitting a wall. The states appear to be arbitrary "event ids" representing a booking, so when looking into the rooms_availability day column values you see these integers, in sequence. When the state arrays are tested in the rooms_booking.admin.inc function "rooms_booking_edit_form_validate(" the state values (e.g. '88' or '33') are returned and the tests fail.

I think there is simply a logic bug in this code, but I'm not familiar enough with the architecture to evaluate this further.

I tested with another booking in the same unit, earlier in the month. No problem.

Right now the only difference is that the booking I am attempting to edit spans moths (June 27 - July 6). I'm attempting to add 6/25 and 6/26.

I will follow up on this after some more testing, hoping for some insight though.
Thanks

ben.hamelin’s picture

Component: Rooms Booking » Rooms Availability
Priority: Normal » Major

After some additional testing today, it appears that the issue is related to editing a booking where the departure date is not available. I've tested numerous bookings in our system, and only when this condition occurs do I get the "Could not update calendar because a locked event is blocking the update - you need to unlock any locked events for the selected date range" error.

This error is thrown due to the "confirmed" array containing a state value of "0" (ROOMS_NOT_AVAILABLE) value.

This issue is present even when leaving the dates alone during edit. I am simply trying to update custom fields for a booking.

This only appears to be a problem with the end date. I found a booking in our system that has the day PRIOR to arrival day blocked (another booking) and am able to edit the booking as expected. (The booking that precedes it I of course can NOT edit.)

Appears to be an issue then in the class `UnitCalendar` -> `getStates()` method

ben.hamelin’s picture

The for loop on line 321 in rooms_availability.unit_calendar.inc, in the getRawDayData() method initializes $i to "endDay()+1"
This allows the departure date of the booking to be included in the states returned, which in the scenarios described above will return a booking state of a new booking arriving on that day.

When I removed the +1 from the initialize function, I was able to edit my problem booking, HOWEVER other bookings in that month were affected, where the arrival (or departure ) date was marked as available - I didn't catch how that happened.

Hope this bit of information helps.

ben.hamelin’s picture

In an effort to help better define this bug, I've created a fresh install.
Added one room type, one unit, and created 2 bookings with arrival of #2 same as departure of #1.
This bug is present, I am unable to edit booking #1.

gianfrasoft’s picture

Same problem here: in file
rooms_availability.booking_event.inc

I see:

  public function unlock() {
    db_delete('rooms_booking_locks')
    ->condition('state', $this->id)
    ->execute();
  }

After a lot of debug I found that the value passed inside variable $this->id has a "-" char before the number(!!!). I watchdog I see that the value stored in $this->id is:
-90 instead of 90, or
-91 instead of 91, etc.

If I revert this value everything goes well:

  public function unlock() {
    $id = 0 - $this->id;
    
    db_delete('rooms_booking_locks')
    ->condition('state', $id)
    ->execute();
  }

I can't understand why! Any help?

gianfrasoft’s picture

Ok, I found the problem inside the file:

rooms_availability.module

in witch the function:

/**
 * Sets event ids
 *
 * @todo - Make this depend on a paramenter
 */
function rooms_availability_assign_id($id, $status = 0) {
  // Add eleven for now - this allows for 10 states that do not
  // refer to a specific booking
  $id = $id + 11;

  if ($status == '0') {
    return -($id);
  }
  else {
    return $id;
  }
}

inverts the booking_id value. Why?

djevans’s picture

Negative values of $id on rooms_bookings entities represent 'unpublished' (unconfirmed) bookings. From rooms_booking.install:

/**
 * Create booking_status field in rooms_booking table
 */
function rooms_booking_update_7001() {
  $booking_status = array(
    'description' => 'The booking status (1 published, 0 unpublished).',
    'type' => 'int',
    'not null' => TRUE,
    'default' => 0,
    'initial' => 1,
  );

  db_add_field('rooms_bookings', 'booking_status', $booking_status);

  return t('Add field booking_status in Rooms Booking table.');
}
ronald_istos’s picture

Assigned: Unassigned » ronald_istos
Issue summary: View changes
Issue tags: +7.1

Working on this

citlacom’s picture

Assigned: ronald_istos » citlacom
ashzade’s picture

Any updates on this? I also have the locked booking problem.

jwilson3’s picture

Issue tags: -7.1 +7.2

Will try to get this in next release.

plopesc’s picture

Assigned: citlacom » Unassigned
Status: Active » Postponed

Hello

I'm trying to reproduce this bug again in our local development repo, so I think it could be closed.

However, postponing until rooms-7.x-1.3 will be ready to go waiting for feedback then.

Regards

jwilson3’s picture

Status: Postponed » Postponed (maintainer needs more info)
Issue tags: -7.2

Rooms 1.3 is out now.

Would it be possible for the original bug reporter to test with the latest version to see if this locking error is still present?

joeebel’s picture

I have upgraded to 7-1.3 and still have a locking error. Also, rooms marked as 'unavailable' are bookable.

Dang!

If marked as 'On request' they act like 'unavailable'.

I'll try a fresh install...

ben.hamelin’s picture

Status: Postponed (maintainer needs more info) » Fixed

Original bug reporter here!
I can confirm w/ a fresh install (Commerce 1.10, Rooms 1.3) that this is no longer an issue.
I'm marking this as fixed.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

tradenet’s picture

Status: Closed (fixed) » Active

This seems to have resurfaced in 7.x-1.4+16-dev

yalu’s picture

Just tested this in 7.x-1.4+16-dev - works for me without any problem.

tradenet’s picture

Funny it seem to clear itself. I created an anonymous booking for that date and it appears again.

andrew.eatherington@gmail.com’s picture

I'm getting this issue on 7.x-1.7. A booked event that spans the next day blocks.

This might be down to the UI and the fact that bookings span from half of arrival date and half of departure date. I know that a booking is overnight and therefore depart the next day.

If you select a single day and create a booking the subsequent day populates for departure (e.g 2nd Mar arrival, 3rd Mar departure). If you select a range (e.g 2-3rd Mar) the 3rd is the departure date. This seems inconsistent.

If an approach was adopted whereby a day is selected and the departure was always the next day I'm sure the issue of blocked events would go away. The logic would only have to act on the days selected as you would not be selecting the departure day - that's a given.

andrew.eatherington@gmail.com’s picture

I'm getting this issue on 7.x-1.7. A booked event that spans the next day blocks.

This might be down to the UI and the fact that bookings span from half of arrival date and half of departure date. I know that a booking is overnight and therefore depart the next day.

If you select a single day and create a booking the subsequent day populates for departure (e.g 2nd Mar arrival, 3rd Mar departure). If you select a range (e.g 2-3rd Mar) the 3rd is the departure date. This seems inconsistent.

If an approach was adopted whereby a day is selected and the departure was always the next day I'm sure the issue of blocked events would go away. The logic would only have to act on the days selected as you would not be selecting the departure day - that's a given.

andrew.eatherington@gmail.com’s picture

Always applying the extra date for departure:

// If we select one day from the calendar, postpone the departure date.
// UPDATE: Departure date should always be the day after selected date
//if ($start_date == $end_date) {
$book_end_date = $book_end_date->add(new DateInterval('P1D'));
//}