PluginProbe
Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution / 2.5.0
Fluent Booking – The Ultimate Appointments Scheduling, Events Booking, Events Calendar Solution v2.5.0
2.5.0 2.4.0 2.3.0 2.2.5 2.2.0 2.1.2 2.1.1 trunk 1.10.0 1.10.01 1.10.02 1.5.0 1.5.01 1.5.02 1.5.1 1.5.10 1.5.20 1.5.21 1.5.22 1.5.23 1.5.24 1.5.25 1.6.0 1.7.0 1.7.1 All 34 releases
← All changes | app/Hooks/Scheduler/FiveMinuteScheduler.php +19 -9 2.4.0 → 2.5.0 View file →
@@ -37,12 +37,14 @@
37 37 if ($bookings->isEmpty()) {
38 38 return true;
39 39 }
40 40
41 - Booking::whereIn('id', $bookings->pluck('id'))
42 - ->update(['status' => 'completed']);
41 + foreach ($bookings as $booking) {
42 + // Flag each row just before its hook, so a run that dies mid-loop leaves the rest for the next run.
43 + if (!Booking::where('id', $booking->id)->where('status', 'scheduled')->update(['status' => 'completed'])) {
44 + continue;
45 + }
43 46
44 - foreach ($bookings as $booking) {
45 47 $booking->status = 'completed';
46 48 do_action('fluent_booking/booking_schedule_completed', $booking, $booking->calendar_event);
47 49 }
48 50
@@ -62,15 +64,19 @@
62 64 if ($bookings->isEmpty()) {
63 65 return true;
64 66 }
65 67
66 - Booking::whereIn('id', $bookings->pluck('id'))
67 - ->update([
68 + foreach ($bookings as $booking) {
69 + // Flag each row just before its hook, so a run that dies mid-loop leaves the rest for the next run.
70 + $flagged = Booking::where('id', $booking->id)->where('status', 'pending')->update([
68 71 'status' => 'cancelled',
69 72 'updated_at' => gmdate('Y-m-d H:i:s'), // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
70 73 ]);
71 74
72 - foreach ($bookings as $booking) {
75 + if (!$flagged) {
76 + continue;
77 + }
78 +
73 79 $booking->status = 'cancelled';
74 80 do_action('fluent_booking/booking_schedule_auto_cancelled', $booking, $booking->calendar_event);
75 81 }
76 82
@@ -93,15 +99,19 @@
93 99 if ($bookings->isEmpty()) {
94 100 return true;
95 101 }
96 102
97 - Booking::whereIn('id', $bookings->pluck('id'))
98 - ->update([
103 + foreach ($bookings as $booking) {
104 + // Flag each row just before its hook, so a run that dies mid-loop leaves the rest for the next run.
105 + $flagged = Booking::where('id', $booking->id)->where('status', 'pending')->update([
99 106 'status' => 'cancelled',
100 107 'updated_at' => gmdate('Y-m-d H:i:s'), // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
101 108 ]);
102 109
103 - foreach ($bookings as $booking) {
110 + if (!$flagged) {
111 + continue;
112 + }
113 +
104 114 $booking->status = 'cancelled';
105 115 do_action('fluent_booking/booking_schedule_auto_cancelled', $booking, $booking->calendar_event);
106 116 }
107 117