Rentiva v4.58.1 — Critical: Double-Booking Fix on Same-Day Returns
AutoComplete cron compared dropoff_date < NOW() at date-only granularity. MySQL cast YYYY-MM-DD to YYYY-MM-DD 00:00:00, so any confirmed booking with a same-day dropoff was auto-completed at midnight — long before the actual return time. has_overlap() then skipped these wrongly-completed bookings (status filter excluded 'completed'), allowing the same vehicle to be double-booked for the remaining rental hours. This release fixes the cron, adds defense-in-depth at has_overlap(), opens a completed → in_progress Status transition, and ships a maintenance script to revert already-contaminated bookings.
This post is the record of a release that shipped before 6.0.0, which renamed the plugin's post types, taxonomies, options, meta keys and hooks. The identifiers below are the names those versions actually used, and they are kept that way on purpose. For the current names — and a conversion table — see the 6.0.7 release post.
A maintenance script lives in the GitHub repository at bin/cleanup-early-completed-bookings.php (intentionally not bundled in the production ZIP). If you suspect contaminated bookings (status completed while the real end_ts is still in the future), copy the file onto a deployed site and run:
# dry-run (default)
wp eval-file plugins/mhm-rentiva/bin/cleanup-early-completed-bookings.php
# revert to in_progress
wp eval-file plugins/mhm-rentiva/bin/cleanup-early-completed-bookings.php apply
The script routes through Status::update_status(), so audit hooks fire and the cache invalidates per fix. Idempotent — re-running after apply finds zero rows.
What's New
Critical Fix
- AutoComplete cron now uses datetime. Primary signal:
_mhm_end_ts(UNIX timestamp). Fallback:CONCAT(_mhm_dropoff_date, ' ', _mhm_dropoff_time), with23:59:59ifdropoff_timeis missing — never auto-completes mid-day. Legacy_mhm_end_datefallback preserved.
Defense-in-Depth
has_overlap()now flags'completed'bookings whoseend_tsis still in the future, blocking availability even if a future cron bug or manual mishap marks a booking complete early.
Feature
Statustransition matrix allowscompleted→in_progressfor early-completion correction (required by the cleanup script's audited update chain).
Tools
bin/cleanup-early-completed-bookings.php—wp eval-filescript. Default is dry-run; positionalapplyreverts contaminated rows viaStatus::update_status()somhm_rentiva_booking_status_changedfires for audit/cache invalidation. Idempotent.
Tests
11 new PHPUnit tests across AutoCompleteCronDatetime, HasOverlapStatusFilter, and StatusTransition suites — total 1,231 tests / 3,726 assertions, 7 documented saas_block env-quota baseline failures, 15 skipped. No regression.
