Added 'SmartdateHandler' for the 'smart_date' contrib module.#371
Conversation
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Code coverage (threshold: 95%) Per-class coverage |
Summary
Adds
SmartdateHandler, a dedicated field handler for thesmartdatefield type provided by thedrupal/smart_datecontrib module. Prior to v3.0, unknown multi-column fields were silently passed throughDefaultHandler; v3.0 hardenedDefaultHandlerto throw aRuntimeExceptionfor any field with multiple storage columns it cannot recognise. Becausesmartdatestores six columns (value,end_value,duration,rrule,rrule_index,timezone), every attempt to write a smart date field via the driver triggered that exception. The new handler closes the gap by normalising positional or named input records, parsing numeric orstrtotime()-compatible date strings, auto-deriving duration when not supplied, and emitting the six-column shape that Drupal's smart date storage expects.Changes
Handler implementation -
src/Drupal/Driver/Core/Field/SmartdateHandler.phpNew
SmartdateHandlerextendsAbstractHandler. Accepts a single positional pair[start, end], a single named record['value' => ..., 'end_value' => ...], or a list of either form for multi-delta fields. Numeric values pass through as Unix timestamps; non-numeric strings are parsed viastrtotime()and resolve toNULLwhen unparseable. Duration is auto-derived as(end - start) / 60clamped to zero when both endpoints are present and no explicit duration is supplied.Unit test -
tests/Drupal/Tests/Driver/Unit/Core/Field/SmartdateHandlerTest.phpFourteen data-provider cases cover: empty input, non-array input, positional pair, named record, multi-delta list, explicit duration override, single-endpoint default, NULL endpoints, reversed-endpoint clamping,
strtotime()string parsing, rrule/timezone passthrough, unparseable string, numeric string casting, and non-array record skipping.Kernel test -
tests/Drupal/Tests/Driver/Kernel/Core/Field/SmartdateHandlerKernelTest.phpRound-trip test via the
Coredriver that attaches asmartdatefield to a node, writes a named record with numeric timestamps and explicit duration through the driver, and asserts Drupal stores and returns the payload intact.README handler table -
src/Drupal/Driver/Core/Field/README.mdAdded H11 row documenting the
smartdatefield type,SmartdateHandlerclass, and the six-column auto-duration behaviour.Dev dependency -
composer.jsonAdded
drupal/smart_date: ^4.2torequire-devso the kernel test environment can install the module.Before / After