reinstate se_event_get_dates() for legacy sites#46
Conversation
|
Caution Review failedThe pull request is closed. Walkthroughse_event_get_dates now calls se_event_get_event_dates, maps each new-format date (start_date, end_date, all_day) to the legacy shape (datetime_start, datetime_end, all_day), and returns that mapped array. The legacy filter path for se_event_get_dates was removed and se_event_get_event_dates no longer applies the legacy se_event_get_dates filter; dates are returned only via the se_event_get_event_dates filter. Docblocks for se_event_get_dates were updated to mark the $event_dates parameter as not used and to specify a precise array return type. Possibly related PRs
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (3)
src/event-functions.php (3)
133-142: Cast to int/bool to match declared return shape.
se_event_get_event_dates()currently returns timestamps as strings (fromget_post_meta+esc_attr). Cast here to honor the docblock and avoid subtle numeric/string comparisons downstream.$dates = array_map( function ( $date ) { return array( - 'datetime_start' => $date['start_date'], - 'datetime_end' => $date['end_date'], - 'all_day' => $date['all_day'], + 'datetime_start' => (int) $date['start_date'], + 'datetime_end' => (int) $date['end_date'], + 'all_day' => (bool) $date['all_day'], ); }, $dates );
121-126: Docblock tweak: clarify legacy param (and quiet analyzers).Since
$event_datesexists for legacy BC (and is forwarded in the filter per above), clarify that in the docblock. If you decide not to forward it, add PHPMD suppression.- * @param array $event_dates Event dates, not used. + * @param array|null $event_dates Legacy event dates; forwarded to the `se_event_get_dates` filter for BC.Optional (only if not forwarding):
+ * @SuppressWarnings(PHPMD.UnusedFormalParameter)
129-131: Emit a runtime deprecation notice.Surface deprecation consistently (as done elsewhere) to help integrators migrate.
// Get dates in new format. +$deprecated_replacement = 'se_event_get_event_dates'; +_deprecated_function( __FUNCTION__, '2.0.0', $deprecated_replacement ); $dates = se_event_get_event_dates( $event_id );
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
src/event-functions.php(1 hunks)
🧰 Additional context used
🪛 PHPMD (2.15.0)
src/event-functions.php
127-127: Avoid unused parameters such as '$event_dates'. (undefined)
(UnusedFormalParameter)
🪛 GitHub Actions: PHP Coding Standards
src/event-functions.php
[warning] 127-127: PHPCS: The method parameter '$event_dates' is never used. (Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed)
🔇 Additional comments (1)
src/event-functions.php (1)
144-148: Preserve filter arg count — pass $event_dates as 3rd argument.Add the original $event_dates (may be null) to apply_filters() to preserve BC and avoid PHP 8 "Too few arguments" fatals / PHPCS warnings.
File: src/event-functions.php (around lines 144–148)
return apply_filters( 'se_event_get_dates', - $dates, - $event_id + $dates, + $event_id, + $event_dates );
Changes proposed in this Pull Request
This pull request updates legacy date handling in the event functions to better align with the new event date format and improve backward compatibility. The main focus is on ensuring that the deprecated
se_event_get_datesfunction returns data in the expected legacy structure while internally using the newse_event_get_event_datesfunction.Legacy compatibility and function updates:
se_event_get_datesfunction to internally callse_event_get_event_dates, then map the results to the legacy format expected by older code. The function now returns an array of associative arrays withdatetime_start,datetime_end, andall_daykeys, ensuring compatibility for code relying on the old structure.se_event_get_dates) from these_event_get_event_datesfunction to avoid double filtering and maintain a single source of truth for event date data.Testing instructions
Mentions #
Summary by CodeRabbit
Refactor
Documentation
Chores